Hi :slightly_smiling_face: tl;dr : remote executio...
# general
a
Hi 🙂 tl;dr : remote execution runs code locally - happy flow? or am i doing something wrong? I'm trying to use pants to run a code on a remote machine my setup is as follows: local machine: has the repo and pants remote machine: a buildgrid docker-server - like the one in the example in pants's repo In the repo i have a test file
test.py
that looks like this:
Copy code
with open("/tmp/A/file", "wt") as test_file:
    test_file.write("pliz work")
Also in my
pants.toml
i have this configured:
Copy code
remote_execution = true
remote_cache_read = true
remote_cache_write = true

remote_store_address = "grpc://<remote_ip>:50051"
remote_execution_address = "grpc://<remote_ip>:50051"
remote_instance_name = ""

process_execution_remote_parallelism = 4

pants_version = "2.19.1"
pantsd=false
...
...
[environments-preview.names]
remote = "//:buildgrid_remote"
and in the relevant
BUILD
file:
Copy code
pex_binary(
    name = "test",
    entry_point="test.py",
    environment="remote"
)
However when I run the command
pants run :test
the file
/tmp/A/file
is created on the local machine and not the remote server A. is this happy flow? and B. if so can i get pants to execute the code on the remote machine?
h
The semantics of
run
are that it always runs locally, because the process you run can be interactive, and is allowed to create side-effects on the local system. Remote execution is for "sandboxed" processes. For example, if you put your code into a
python_tests
target and run it with
pants test
you should get remote exec.
a
hmm I see well the name "remote execution" is a little confusing then because when using the
run
target what you get is more "remote build" then "remote execution" anyway thank you for the response it just saved me a lot of headaches lol I ended up opting for a different solution i'll explain it here shortly in case anyone needs it in the future 🙂 I set it so that you can run the code from the remote manually buy it will automatically update the code to what's on the local machine every time before pants "runs" (pants runs it and executes it just very early on) using rsync to get the file and running it from the
.pants.bootstrap
file if anyone is interested in more details and maybe an example feel free to reach out to me 🙂