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

Add KATIB_EXPERIMENT_NAME to pod env. #2488

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

Conversation

Electronic-Waste
Copy link
Member

What this PR does / why we need it:

Users sometimes may need experiment metadata for their customized applications like: #2473

As we discussed in #2390, we can get namespace of experiment from:

/var/run/secrets/kubernetes.io/serviceaccount/namespace

So we only need to pass experiment name as KATIB_EXPERIMENT_NAME to the Pod Env just like KATIB_TRIAL_NAME:)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2473
Also related to: #2390

Checklist:

  • Docs included if any changes are user facing

/cc @kubeflow/wg-automl-leads @mickvangelderen @helenxie-bit @tariq-hasan

@google-oss-prow google-oss-prow bot requested review from helenxie-bit and a team January 15, 2025 06:25
Copy link

@Electronic-Waste: GitHub didn't allow me to request PR reviews from the following users: mickvangelderen, tariq-hasan.

Note that only kubeflow members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

What this PR does / why we need it:

Users sometimes may need experiment metadata for their customized applications like: #2473

As we discussed in #2390, we can get namespace of experiment from:

/var/run/secrets/kubernetes.io/serviceaccount/namespace

So we only need to pass experiment name as KATIB_EXPERIMENT_NAME to the Pod Env just like KATIB_TRIAL_NAME:)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2473
Also related to: #2390

Checklist:

  • Docs included if any changes are user facing

/cc @kubeflow/wg-automl-leads @mickvangelderen @helenxie-bit @tariq-hasan

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

[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 andreyvelich 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

Name: consts.EnvExperimentName,
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: fmt.Sprintf("metadata.labels['%s']", consts.LabelExperimentName),
Copy link
Member Author

Choose a reason for hiding this comment

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

This label exists in Trial Pod. Here is an example:

Name:             tune-experiment-lhs5mrsh-9xqwd
Namespace:        kubeflow
Priority:         0
Service Account:  default
Start Time:       Wed, 15 Jan 2025 06:29:28 +0000
Labels:           batch.kubernetes.io/controller-uid=859791df-d3da-404d-841c-86eca6c9148f
                  batch.kubernetes.io/job-name=tune-experiment-lhs5mrsh
                  controller-uid=859791df-d3da-404d-841c-86eca6c9148f
                  job-name=tune-experiment-lhs5mrsh
                  katib.kubeflow.org/experiment=tune-experiment
                  katib.kubeflow.org/trial=tune-experiment-lhs5mrsh
Annotations:      sidecar.istio.io/inject: false
Status:           Running
...

Copy link

@mickvangelderen mickvangelderen Jan 15, 2025

Choose a reason for hiding this comment

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

Oh so we can already reference metadata.labels['katib.kubeflow.org/experiment'] in the spec? That means that the issue #2473 can already be closed as completed as we can obtain the namespace from /var/run/secrets/kubernetes.io/serviceaccount/namespace and the experiment name from the metadata.labels['katib.kubeflow.org/experiment'].

Still, I think it would be convenient to have these values exposed as environment variables by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mickvangelderen We could not access metadata.labels['katib.kubeflow.org/experiment'] directly since it's not included in .trialSpec.Labels field. The label lies in .Labels field in Trial and Pod.

And also, I agree with you that it will be more convenient if we could also pass KATIB_NAMESPACE to env of Pod by default. WDTY👀 @kubeflow/wg-automl-leads

Copy link
Member Author

Choose a reason for hiding this comment

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

@mickvangelderen And it will also be okay to pass namespace and trial name as env variables like this:

env:
- name: TRIAL_NAME
value: ${trialParameters.trialName}
- name: TRIAL_NAMESPACE
value: ${trialParameters.trialNamespace}

@Electronic-Waste
Copy link
Member Author

/rerun-all

3 similar comments
@Electronic-Waste
Copy link
Member Author

/rerun-all

@Electronic-Waste
Copy link
Member Author

/rerun-all

@Electronic-Waste
Copy link
Member Author

/rerun-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Experiment metadata to Trial Template
2 participants