bitter-ability-32190
06/17/2022, 4:18 PMrun PR is how to switch between sandbox mode.
The friendliest solution IMO is a new run flag, however this flag is only relevant when `run`ning a "scripting" language ("compiled" languages wouldn't benefit). So pros/cons.
The alternative is a field on python_source and python_test targets, which is a bit funkier and has no obvious CLI support (we could add a "default" CLI option to python, but now we're talking even more machinery)
Thoughts y'all?hundreds-father-404
06/17/2022, 4:19 PMbitter-ability-32190
06/17/2022, 4:20 PMdocker_image or go_binary. 😞bitter-ability-32190
06/17/2022, 4:22 PMsparse-lifeguard-95737
06/17/2022, 4:24 PMsparse-lifeguard-95737
06/17/2022, 4:25 PMbitter-ability-32190
06/17/2022, 4:26 PMrun on a PEX target will be sandboxed, but that really won't matter anymore in the long run, as we'll be running the built PEX. We'll still set CWD to repo root as wellbitter-ability-32190
06/17/2022, 4:27 PMwitty-crayon-22786
06/17/2022, 4:39 PMI’m pretty sure the default value will (eventually) be the “run in repo” value, as it follows the element of least surprise.because it is not sandboxed, i don’t think that it will be a good default.
bitter-ability-32190
06/17/2022, 4:41 PMwitty-crayon-22786
06/17/2022, 4:41 PMwitty-crayon-22786
06/17/2022, 4:41 PM--loop or --changed broken?”bitter-ability-32190
06/17/2022, 4:42 PM--loop or --changed would be broken?witty-crayon-22786
06/17/2022, 4:42 PMwitty-crayon-22786
06/17/2022, 4:43 PMbitter-ability-32190
06/17/2022, 4:44 PMrun standalone vs run with those flags? I'm guessing at least an order of magnitude in differencewitty-crayon-22786
06/17/2022, 4:46 PMsome/dir, inference has detected that you depend on some/dir/a.py, but not on some/dir/b.py. when some/dir/b.py changes, --loop or --changed will not detect your script, because the file wasn’t a dep.witty-crayon-22786
06/17/2022, 4:47 PMbitter-ability-32190
06/17/2022, 4:48 PMb.py and I change it, why would I expect the run to be restarted?bitter-ability-32190
06/17/2022, 4:49 PMwitty-crayon-22786
06/17/2022, 4:50 PMwitty-crayon-22786
06/17/2022, 4:51 PMb.py as a dep as well. perhaps easier to imagine as a resource which needed to be explicitly declaredwitty-crayon-22786
06/17/2022, 4:52 PMand wrong for the 98% chance they aren’t
--changed is one of the two recommended modes of CI, so it’s more common than that.bitter-ability-32190
06/17/2022, 4:53 PMrun fail complaining about a missing file when we could make it succeed?bitter-ability-32190
06/17/2022, 4:53 PMis one of the two recommended modes of CI, so it’s more common than that.--changed
--changed with goals like fmt and lint? sure. Goals like run? Seems sketchy.hundreds-father-404
06/17/2022, 4:56 PMrun is a very weird goal that already violates several of our hermeticity expectations. For example, if you use a filesystem API like open(), you don't need to declare `file`/`resource` targets for those deps. We already do "bad" thingsbitter-ability-32190
06/17/2022, 4:56 PMmigrate.py script. It isn't used in prod, it isn't a part of a test. Let's allow users to fall into the Pit of Success.witty-crayon-22786
06/17/2022, 4:56 PM--changed-.. --filter=… list | xargs -L1 ./pants run is easier to imagine: “run changed deployment scripts”hundreds-father-404
06/17/2022, 4:56 PM--changed-.. --filter=… list | xargs -L1 ./pants run is easier to imagine: “run changed deployment scripts”We error if you don't give exactly 1 argument to
runwitty-crayon-22786
06/17/2022, 4:57 PMhundreds-father-404
06/17/2022, 4:57 PM--changed-since list and then loop over it calling ./pants run multiple timesbitter-ability-32190
06/17/2022, 4:58 PM--changed with list is part of a conversation about `run`'s sandbox behavior 😐witty-crayon-22786
06/17/2022, 4:58 PMbitter-ability-32190
06/17/2022, 4:59 PMrun flag"witty-crayon-22786
06/17/2022, 4:59 PMand ignore the rest?no, it runs them sequentially, one at a time.
Also I fail to see howbecause you won’t detect that it needs towith--changedis part of a conversation about `run`’s sandbox behaviorlist
run … it’s the same dependencies list.bitter-ability-32190
06/17/2022, 5:01 PMbecause you won’t detect that it needs toI'm really not following this 😅 You're just providing an arg to run and we run it.run
hundreds-father-404
06/17/2022, 5:03 PM--changed-dependees and --loop does not work properly. Even if the script executes, our understanding of your repo is incomplete, and we might not show something has been changed properly
My point is that this is already the case with the run goal. It's already an impure goal
Unclear to me what to decide here, thoughbitter-ability-32190
06/17/2022, 5:07 PMrun purity for `run`'s sake. If you want metadata purity, test your code.
"We don't run your code like normal because we might not have gotten all your dependencies right, and in the event you really rely on those dependencies being right, but aren't validating it through tests, we want to ensure you know it by failing your run " doesn't quite strike me as something ergonomic.bitter-ability-32190
06/17/2022, 5:09 PMsys.path anyways so we still "find" the in-repo file 🤷♂️hundreds-father-404
06/17/2022, 5:11 PMIf you want metadata purity, test your code.Or, your unowned-dependencies mechanism! I generally agree that
run is the wrong medium to be enforcing deps are bitter-ability-32190
06/17/2022, 5:12 PMWe should document that though as a warningYeah. Both options have thorns which need thorough documentation. IMO one options has less thorns 😛 --- Back on topic though.
run flag or field? 🙂bitter-ability-32190
06/20/2022, 12:47 AM--debug-adapter support, it will only work if we run the user's code in-repo. More frustratingly, nothing will crash or no errors or warnings will appear (unless we implement them) after connecting the client. Just silently runs the code in the sandbox to completion (because of the path mismatch).sparse-lifeguard-95737
06/21/2022, 2:25 AM2.13.0a0 was released without reverting the run_in_sandbox field on the pex_binary target, does that mean it will definitely be present in the 2.13.0 release? or there’s still a chance it’ll end up reverted?bitter-ability-32190
06/21/2022, 10:18 AMbitter-ability-32190
06/21/2022, 10:20 AMhappy-kitchen-89482
06/21/2022, 2:57 PM__path__ magic to determine a write location based on the location of a loaded module. But this is not super common.sparse-lifeguard-95737
06/21/2022, 2:57 PMhappy-kitchen-89482
06/21/2022, 2:58 PMrun_in_sandbox solves that case for youhappy-kitchen-89482
06/21/2022, 2:58 PMhappy-kitchen-89482
06/21/2022, 2:58 PMhappy-kitchen-89482
06/21/2022, 2:59 PM./pants run path/to/file.py to be equivalent to python path/to/file.py, where things ~just workbitter-ability-32190
06/21/2022, 2:59 PMBut this is not super common.It's very common for a lot of our scripts in-house 🙂 Even in Pants,
generate-docs would now be writing in-repo. As is generate_github_workflows and contributors.py 😉bitter-ability-32190
06/21/2022, 3:01 PMOTOH I see the argument that we might wantSo that's my proposal (in a nutshell) 😉 Remember Winston? He would be wasting time trying to figure out why running the script through Pants isn't working like when he runs it through his venv. We got off topic here, let me open a new threadto be equivalent to./pants run path/to/file.py, where things ~just workpython path/to/file.py
sparse-lifeguard-95737
06/21/2022, 3:02 PMrun_in_sandbox on pex_binary vs. un-sandboxed run directly on a python script - I can make either one work for my purposes. I’ve had people breathing down my neck about django management CLI + pants not working as expected, and was going to point at the new run_in_sandbox field and say “look it’s going to work soon!” when I saw chatter here about possibly reverting the addition of that field in 2.13. I don’t mind if it’s reverted, I just want to know if it’s going to be reverted so I don’t bait-and-switch my teambitter-ability-32190
06/21/2022, 3:05 PMbitter-ability-32190
06/21/2022, 3:06 PMbitter-ability-32190
06/21/2022, 3:06 PMsparse-lifeguard-95737
06/21/2022, 3:07 PMhappy-kitchen-89482
06/21/2022, 3:21 PMrun_in_sandbox until we have some alternative.bitter-ability-32190
06/22/2022, 1:11 AM