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

JobDefinition env parameter to specify pip index url and host #419

Conversation

ChristianZaccaria
Copy link
Collaborator

Issue link

Resolves #408

What changes have been made

  • Created a function that checks for env variables in the DDPJobDefinition, and looks for the PIP_INDEX_URL and/or PIP_TRUSTED_HOST keys. If these keys are found, pip will leverage the dedicated index location provided with the mentioned env variables.

This allows the user to submit a job with the provided env variables for pip.

Verification steps

  • Checkout this PR
  • Install codeflare-sdk in your kubernetes cluster. Probably easiest way is to run poetry build, then install the generated wheel with pip install codeflare_sdk-0.0.0.dev0-py3-none-any.whl.
  • Clone the codeflare-sdk repository.
  • Run through the guided-demo notebook 2_basic_jobs.ipynb.
  • Add the env vars to the JobDefinition such as this example:
jobdef = DDPJobDefinition(
    name="mnisttest",
    script="mnist.py",
    env={"PIP_INDEX_URL": "https://pypi.org/simple", 
        "PIP_TRUSTED_HOST": "pypi.org"},
    # script="mnist_disconnected.py", # training script for disconnected environment
    scheduler_args={"requirements": "requirements.txt"}
)
job = jobdef.submit(cluster)
  • Go to your dashboard, look for your submitted job, and look at the Runtime environment used:
    image
  • Dependencies are installed from the trusted source provided.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • Testing is not required for this change

Copy link
Contributor

openshift-ci bot commented Dec 5, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign michaelclifford for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

pip_index_url = self.env.get("PIP_INDEX_URL")
requirements_path = Path("requirements.txt")

if requirements_path.exists():
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey Christian,
I followed your verification steps and it works as expected :) Good job.

One thing is, if this is also being used to add --trusted-host and --index-url if they are not yet set, should we also create a requirements.txt file if it does not exist?

@KPostOffice
Copy link
Collaborator

closing as jobs.py file no longer exists

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.

env parameter in DDPJobDefinition doesn't pass env variables to Ray
3 participants