Skip to content

[Fix][Core/Runtime] Revert PR 48552 and add validation for conda env folder path#52173

Merged
jjyao merged 5 commits intoray-project:masterfrom
MortalHappiness:bugfix/#51971-conda-env-cannot-load
Apr 10, 2025
Merged

[Fix][Core/Runtime] Revert PR 48552 and add validation for conda env folder path#52173
jjyao merged 5 commits intoray-project:masterfrom
MortalHappiness:bugfix/#51971-conda-env-cannot-load

Conversation

@MortalHappiness
Copy link
Copy Markdown
Member

@MortalHappiness MortalHappiness commented Apr 9, 2025

Why are these changes needed?

This PR reverts #48552. The original issue is that conda activate depends on a shell, and in Docker containers or Kubernetes pods, the entrypoint process is fixed and may not have a shell attached. Therefore, it should only be called when forking or spawning a subprocess, not during plugin creation validation. Currently, when we fork or spawn a subprocess, we run it with the bash shell, so calling conda activate is not an issue.

os.execvp("bash", args=["bash", "-c", " ".join(cmd)])

After this PR, the conda environment folder path is still supported, but we only perform minimal validation. Specifically, we only check whether the folder exists.

Related issue number

Closes: #51971

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

@MortalHappiness MortalHappiness added the go add ONLY when ready to merge, run all tests label Apr 9, 2025
…ray-project#48552)"

This reverts commit d9e27ab.

Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
@MortalHappiness MortalHappiness force-pushed the bugfix/#51971-conda-env-cannot-load branch from 8813ca1 to c7792f5 Compare April 9, 2025 13:25
@MortalHappiness MortalHappiness changed the title [Fix][Core/Runtime] Make conda activate command only depend on operating system [Fix][Core/Runtime] Revert PR 48552 and add validation for conda env folder path Apr 9, 2025
@MortalHappiness MortalHappiness force-pushed the bugfix/#51971-conda-env-cannot-load branch from c7792f5 to ef4cc09 Compare April 9, 2025 13:48
Closes: ray-project#51971
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
@MortalHappiness MortalHappiness force-pushed the bugfix/#51971-conda-env-cannot-load branch from ef4cc09 to 151d5b7 Compare April 9, 2025 13:50
@MortalHappiness MortalHappiness marked this pull request as ready for review April 9, 2025 16:19
@MortalHappiness
Copy link
Copy Markdown
Member Author

Manual tested locally via KubeRay:

apiVersion: ray.io/v1
kind: RayCluster
metadata:
  name: raycluster-2-44-1
spec:
  rayVersion: "2.44.1"
  headGroupSpec:
    rayStartParams: {}
    template:
      spec:
        containers:
          - name: ray-head
            image: 029272617770.dkr.ecr.us-west-2.amazonaws.com/anyscale/ray:pr-52173.151d5b-py39-cpu
            resources:
              limits:
                cpu: 1
                memory: 2G
              requests:
                cpu: 1
                memory: 2G
            ports:
              - containerPort: 6379
                name: gcs-server
              - containerPort: 8265
                name: dashboard
              - containerPort: 10001
                name: client
            readinessProbe:
              exec:
                command:
                  - bash
                  - -c
                  - exit 0
              failureThreshold: 10
              initialDelaySeconds: 10
              periodSeconds: 5
              successThreshold: 1
              timeoutSeconds: 2
            livenessProbe:
              exec:
                command:
                  - bash
                  - -c
                  - exit 0
              failureThreshold: 120
              initialDelaySeconds: 30
              periodSeconds: 5
              successThreshold: 1
              timeoutSeconds: 2

Apply the YAML and port-forward 8265 port of the head pod.

kubectl exec to get shell to the head pod and clone the base env to test-named-env and /home/ray/test-env.

image

conda_test.py

import ray
import subprocess

runtime_env = {"conda": "test-named-env"}
ray.init(address="auto", runtime_env=runtime_env)

@ray.remote
def f():
    stdout = subprocess.check_output(["conda", "env", "list"])
    print(stdout.decode("utf-8"))

ray.get([f.remote()])

Tested the following cases:

  • base
    image
  • test-named-env
    image
  • test-named-env1 (should error)
    image
  • /home/ray/test-env
    image
  • /home/ray/test-env1 (should error)
    image

Closes: ray-project#51971
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Closes: ray-project#51971
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
@jjyao jjyao merged commit 7eef3bf into ray-project:master Apr 10, 2025
5 checks passed
@jjyao
Copy link
Copy Markdown
Contributor

jjyao commented Apr 10, 2025

@MortalHappiness could you write a test for it to catch the issue in the future?

han-steve pushed a commit to han-steve/ray that referenced this pull request Apr 11, 2025
…folder path (ray-project#52173)

Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Signed-off-by: Steve Han <stevehan2001@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-backlog go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ray Serve] Conda environment can't be activated from image on ray==2.44.1

3 participants