Skip to content

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

Merged
jjyao merged 5 commits intoray-project:masterfrom
terraflops1048576:terraflops1048576/use_conda_env_without_list
Feb 25, 2025
Merged

Change conda env validity checking to activate and run Python#48552
jjyao merged 5 commits intoray-project:masterfrom
terraflops1048576:terraflops1048576/use_conda_env_without_list

Conversation

@terraflops1048576
Copy link
Copy Markdown
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

Closes #50720

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 :(

Signed-off-by: Peter Wang <peter.wang9812@gmail.com>
@rkooo567
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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.

Signed-off-by: Peter Wang <peter.wang9812@gmail.com>
@rynewang
Copy link
Copy Markdown
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 <peter.wang9812@gmail.com>
Signed-off-by: Peter Wang <peter.wang9812@gmail.com>
@terraflops1048576
Copy link
Copy Markdown
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 <peter.wang9812@gmail.com>
Copy link
Copy Markdown
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

@stale
Copy link
Copy Markdown

stale bot commented Feb 25, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Feb 25, 2025
@jjyao jjyao removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Feb 25, 2025
@jjyao jjyao merged commit d9e27ab into ray-project:master Feb 25, 2025
kevin85421 pushed a commit to kevin85421/ray that referenced this pull request Feb 28, 2025
…oject#48552)

Signed-off-by: Peter Wang <peter.wang9812@gmail.com>
Signed-off-by: kaihsun <kaihsun@anyscale.com>
xsuler pushed a commit to antgroup/ant-ray that referenced this pull request Mar 4, 2025
park12sj pushed a commit to park12sj/ray that referenced this pull request Mar 18, 2025
MortalHappiness added a commit to MortalHappiness/ray that referenced this pull request Apr 9, 2025
…ray-project#48552)"

This reverts commit d9e27ab.

Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
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.

[Core] specifying runtime_env using conda env fullpath no work

6 participants