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

feature: custom annotations revisited #1568

Merged
merged 18 commits into from
Dec 20, 2024
Merged

Conversation

saikonen
Copy link
Collaborator

@saikonen saikonen commented Oct 4, 2023

reintroduces the feature first merged in #1442 which had to be reverted in #1516 due to a regression that broke annotations for recording user and project info.

This feature keeps the 'system annotations' outside of the decorator scope, as in many cases the current singleton is not initialized to its full extent.

Also reintroduces the ability to set custom Kubernetes labels via the decorator, instead of only the environment variable.

@saikonen saikonen linked an issue Oct 4, 2023 that may be closed by this pull request
@saikonen saikonen marked this pull request as ready for review October 9, 2023 21:51
@saikonen saikonen requested a review from savingoyal October 10, 2023 15:30
@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from 734de96 to b9ce0f2 Compare October 12, 2023 15:35
@tylerpotts
Copy link
Contributor

@saikonen Took this for a spin and everything is working as expected!

@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from b9ce0f2 to 8464b54 Compare October 12, 2023 20:48
Comment on lines 333 to 350
if self.parameters:
annotations.update({"metaflow/parameters": json.dumps(self.parameters)})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved the new convenience annotations to this helper as well. One thing to note though is that this applies all of them to the generic self.kubernetes_annotations, which is applied generously as a baseline set of annotations (including for Sensors)

Do these annotations make sense for all objects, or should they be kept out of this helper? This simplifies the setup somewhat at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

@savingoyal Do you have an opinion on this?

@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from 8464b54 to d4a2936 Compare January 15, 2024 13:28
@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from d4a2936 to e6ab77c Compare March 18, 2024 12:00
@nflx-mf-bot
Copy link
Collaborator

Testing[678] @ 6257d47

@nflx-mf-bot
Copy link
Collaborator

Testing[678] @ 6257d47 had 3 FAILUREs.

@saikonen saikonen requested a review from madhur-ob April 18, 2024 16:06
@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from 6257d47 to 617ead4 Compare April 29, 2024 10:26
@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from 617ead4 to ef85434 Compare November 18, 2024 16:17
@ggutierrez545
Copy link

Anything further need to be done here to push this PR along?

@saikonen saikonen force-pushed the feature/custom-annotations-fixed branch from d6f068b to 8f983a5 Compare December 9, 2024 14:22
metaflow/plugins/argo/argo_workflows.py Outdated Show resolved Hide resolved
metaflow/plugins/argo/argo_workflows.py Show resolved Hide resolved
metaflow/plugins/argo/argo_workflows.py Show resolved Hide resolved
metaflow/plugins/argo/argo_workflows.py Outdated Show resolved Hide resolved
metaflow/plugins/argo/argo_workflows.py Show resolved Hide resolved
metaflow/plugins/argo/argo_workflows.py Show resolved Hide resolved
metaflow/plugins/kubernetes/kube_utils.py Outdated Show resolved Hide resolved
@saikonen saikonen requested a review from savingoyal December 20, 2024 09:04
@saikonen saikonen dismissed savingoyal’s stale review December 20, 2024 09:04

changes completed

@saikonen saikonen merged commit 8c630a9 into master Dec 20, 2024
29 checks passed
@saikonen saikonen deleted the feature/custom-annotations-fixed branch December 20, 2024 17:19
.annotations(annotations)
.labels(self.kubernetes_labels)
Copy link
Contributor

Choose a reason for hiding this comment

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

@saikonen is there a reason that you remove these labels from the podMetadata section and instead repeat them in each task?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the podMetadata applying to all pods from the template wasn't a good fit for setting task-pod-specific labels, e.g.

@kubernetes(labels={"test-label": "first-step"})
@step
def first_step(self)
   ...

@kubernetes(labels={"test-label": "second-step"})
@step
def second_step(self)
   ...

as on the template level we can't make a choice which deco to pull the 'common' labels from.

The previous implementation did treat the common labels from the environment variable as shared, and set them in the podMetadata. Functionally there shouldn't be any difference though whether those are set here, or individually per-pod?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there an issue with repeating common labels on the pod level?

We can extend on this, as there is a todo for the future to provide separate label/annotation global env configuration for argo-workflows which would enable labeling all relevant resources (templates, sensors etc.)

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.

Annotations aren't working with the latest release of Metaflow
7 participants