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

Change conda env validity checking to activate and run Python #48552

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

terraflops1048576
Copy link
Contributor

@terraflops1048576 terraflops1048576 commented Nov 4, 2024

Why are these changes needed?

Currently, we validate conda environments by checking the output of conda info --json to see if the environment is the list. Sometimes, one might install conda environments on some filesystem mounted across multiple machines. These environments can be activated with the absolute path: conda activate /path/to/environment but don't show up under the local conda installation's conda info --json. I figure that what we really care about is that one can activate the environment and run Python in it, as that is what the RuntimeEnv plugin ultimately does, so this is what the check has become.

Related issue number

None

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@rkooo567
Copy link
Contributor

rkooo567 commented Nov 5, 2024

cc @jjyao

@jcotant1 jcotant1 added the core Issues that should be addressed in Ray Core label Nov 18, 2024
@dayshah dayshah requested a review from jjyao November 19, 2024 18:59
Check if the given conda environment exists and is valid.
We try to `conda activate` it and check that python is runnable
"""
activate_cmd = get_conda_activate_commands(conda_env_name) + ["python", "--version"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to deactivate it afterwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, because conda activate sets environment variables and other things that aren't global state, which will be reset when the subprocess exits.

However, I did recently do some thinking about it, and I think conda activate does a lot of shell-specific things, so I've changed it to execute in a shell.

@rynewang
Copy link
Contributor

Can you also update unit tests?

I think this test will now fail (changed error msg)

assert "doesn't exist from the output of `conda info --json`" in str(

@rynewang rynewang added the go add ONLY when ready to merge, run all tests label Nov 20, 2024
Peter Wang added 2 commits December 13, 2024 10:59
…se_conda_env_without_list

Signed-off-by: Peter Wang <[email protected]>
Signed-off-by: Peter Wang <[email protected]>
@terraflops1048576
Copy link
Contributor Author

Oops, I guess I didn't notice that! I've made the change. Sorry for the delay.

…se_conda_env_without_list

Signed-off-by: Peter Wang <[email protected]>
Copy link
Contributor

@dayshah dayshah left a comment

Choose a reason for hiding this comment

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

@rynewang green now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants