Skip to content

Commit

Permalink
Move product label to _get_flow_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tmckay committed Jan 4, 2024
1 parent 1c63366 commit 0bae9d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 7 additions & 6 deletions metaflow/plugins/aip/aip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,21 +1041,25 @@ def _get_flow_labels(

ret_flow_labels[annotation_name] = annotation_value

zodiac_prefix = "zodiac.zillowgroup.net"

# - In context of Zillow CICD username == "cicd_compile"
# - In the context of a Zillow NB username == METAFLOW_USER (user_alias)
# - In the context of Metaflow integration tests username == USER=$GITLAB_USER_EMAIL
owner = username
if "@" in owner:
owner = owner.split("@")[0]
ret_flow_labels["zodiac.zillowgroup.net/owner"] = owner
ret_flow_labels[f"{zodiac_prefix}/owner"] = owner

# If the Zodiac environment variable is present in the notebook (individual profile notebooks only),
# the Zodiac service and team labels are added to the AIP pods and set. These labels are not added
# by the AIP webhook to support user-supplied Zodiac service per AIP Notebook. Workflows launched
# in project CICD profiles will still have these labels added via the AIP webhook.
if ZILLOW_ZODIAC_SERVICE and ZILLOW_ZODIAC_TEAM:
ret_flow_labels["zodiac.zillowgroup.net/service"] = ZILLOW_ZODIAC_SERVICE
ret_flow_labels["zodiac.zillowgroup.net/team"] = ZILLOW_ZODIAC_TEAM
ret_flow_labels[f"{zodiac_prefix}/service"] = ZILLOW_ZODIAC_SERVICE
ret_flow_labels[f"{zodiac_prefix}/team"] = ZILLOW_ZODIAC_TEAM

ret_flow_labels[f"{zodiac_prefix}/product"] = "batch"

return ret_flow_labels

Expand All @@ -1082,9 +1086,6 @@ def _set_container_labels(self, container_op: ContainerOp):
container_op.add_pod_label(
"tags.ledger.zgtools.net/ai-step-name", container_op.name
)
container_op.add_pod_label(
"zodiac.zillowgroup.net/product", "batch"
)
if self.experiment:
container_op.add_pod_label(
"tags.ledger.zgtools.net/ai-experiment-name", self.experiment
Expand Down
3 changes: 0 additions & 3 deletions metaflow/plugins/aip/argo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ def trigger_workflow_template(self, name: str, parameters: Optional[Dict] = None
"kind": "Workflow",
"metadata": {
"generateName": name + "-",
"labels": {
"zodiac.zillowgroup.net/product": "batch"
}
},
"spec": {
"workflowTemplateRef": {"name": name},
Expand Down
1 change: 1 addition & 0 deletions metaflow/plugins/aip/tests/run_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ def test_flow_labels():
assert tags["metaflow.org/tag_t1"] == "true"
assert tags["metaflow.org/tag_s1"] == "true"
assert tags["zodiac.zillowgroup.net/owner"] == "foo"
assert tags["zodiac.zillowgroup.net/product"] == "batch"

with pytest.raises(ValueError) as e:
KubeflowPipelines._get_flow_labels(
Expand Down

0 comments on commit 0bae9d3

Please sign in to comment.