Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct python version when running jobs #620

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

rebkwok
Copy link
Contributor

@rebkwok rebkwok commented Oct 17, 2024

In local dev environments, we run with just, which explicitly
uses the virtual env bin to run all commands, without the
user needing to manually activate it. However, dispatcher jobs are
run in a subprocess and just run with python ... and so don't
automatically use the virtualenv python.

In the Dockerfile (i.e. for production), we prepend the virtualenv
bin path to the PATH environment variable, which ensures that the
virtualenv python will be the first python encountered and used.

We now check for an ABSOLUTE_BIN env variable (set in the justfile, so this
will only apply for local envs, not prod) and ensure that it is first
in the PATH when running a job.

Note that we could set PATH itself in the justfile so that it is passed
through in os.environ to the job subprocess, but if we do,
it'll set the user's global PATH, which is not necessarily what they
want.

In local dev environments, we run with `just`, which explicitly
uses the virtual env bin to run all commands, without the
user needing to manually activate it. However, dispatcher jobs are
run in a subprocess and just run with `python ...` and so don't
automatically use the virtualenv python.

In the Dockerfile (i.e. for production), we prepend the virtualenv
bin path to the PATH environment variable, which ensures that the
virtualenv python will be the first python encountered and used.

We now check for an ABSOLUTE_BIN env variable (set in the justfile, so this
will only apply for local envs, not prod) and ensure that it is first
in the PATH when running a job.

Note that we could set PATH itself in the justfile so that it is passed
through in os.environ to the job subprocess, but if we do,
it'll set the user's global PATH, which is not necessarily what they
want.
The equivalent comment is already in the Dockerfile, but this is
included now with the entrypoint script for the benefit of future
us coming across it again.
Copy link
Contributor

@alarthast alarthast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that the new test fails as expected on ubuntu with the system python and passes after pulling down the changes in dispatcher.py and the justfile

@rebkwok rebkwok merged commit 53daf57 into main Oct 18, 2024
6 checks passed
@rebkwok rebkwok deleted the python-version-for-jobs branch October 18, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants