Skip to content

Commit 0b2f582

Browse files
authored
VADC 904 (#137)
* add username logic for archived workflows
1 parent c2bdbc1 commit 0b2f582

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/argowrapper/engine/argo_engine.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def retry_workflow(self, workflow_name: str, uid: str) -> str:
281281

282282
def _get_archived_workflow_wf_name_and_team_project(
283283
self, archived_workflow_uid
284-
) -> (str, str):
284+
) -> (str, str, str):
285285
"""
286286
Gets the name and team project details for the given archived workflow
287287
@@ -306,11 +306,13 @@ def _get_archived_workflow_wf_name_and_team_project(
306306
# get the workflow given name from the parsed details:
307307
given_name = workflow_details["wf_name"]
308308
team_project = workflow_details[GEN3_TEAM_PROJECT_METADATA_LABEL]
309+
gen3username = workflow_details[GEN3_USER_METADATA_LABEL]
309310
self.workflow_given_names_cache[archived_workflow_uid] = (
310311
given_name,
311312
team_project,
313+
gen3username,
312314
)
313-
return given_name, team_project
315+
return given_name, team_project, gen3username
314316

315317
def get_workflows_for_team_projects_and_user(
316318
self, team_projects: List[str], auth_header: str

src/argowrapper/engine/helpers/argo_engine_helper.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,16 @@ def parse_list_item(
115115
else:
116116
# this is needed because archived list items do not have metadata.annotations or meta.labels
117117
# returned by the list service...so we need to call another service to get it:
118-
wf_name, team_project = get_archived_workflow_wf_name_and_team_project(
118+
(
119+
wf_name,
120+
team_project,
121+
gen3username,
122+
) = get_archived_workflow_wf_name_and_team_project(
119123
workflow_details["metadata"].get("uid")
120124
)
121125
result["wf_name"] = wf_name
122126
result[GEN3_TEAM_PROJECT_METADATA_LABEL] = team_project
127+
result[GEN3_USER_METADATA_LABEL] = gen3username
123128

124129
result["uid"] = workflow_details["metadata"].get("uid")
125130
return result

test/test_argo_engine.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def test_argo_engine_get_workflows_for_user_and_team_projects_suceeded():
452452
assert "custom_name_active2" == uniq_workflow_list[0]["wf_name"]
453453
assert "custom_name_archived" == uniq_workflow_list[1]["wf_name"]
454454
assert "2023-03-22T19:59:59Z" == uniq_workflow_list[1]["submittedAt"]
455-
assert "" == uniq_workflow_list[1][GEN3_USER_METADATA_LABEL]
455+
assert "dummyuser" == uniq_workflow_list[1][GEN3_USER_METADATA_LABEL]
456456

457457

458458
def test_argo_engine_get_workflows_for_user_failed():
@@ -760,15 +760,18 @@ def test_get_archived_workflow_wf_name_and_team_project():
760760
mock_return_wf = {
761761
"wf_name": "dummy_wf_name",
762762
GEN3_TEAM_PROJECT_METADATA_LABEL: "dummy_team_project_label",
763+
GEN3_USER_METADATA_LABEL: "dummy_user",
763764
}
764765

765766
engine.get_workflow_details = mock.MagicMock(return_value=mock_return_wf)
766767
(
767768
given_name,
768769
team_project,
770+
gen3username,
769771
) = engine._get_archived_workflow_wf_name_and_team_project("dummy_uid")
770772
assert given_name == "dummy_wf_name"
771773
assert team_project == "dummy_team_project_label"
774+
assert gen3username == "dummy_user"
772775

773776
# test the internal caching that happens at _get_archived_workflow_wf_name_and_team_project,
774777
# by setting the get_workflow_details to return None and show that it was not called,
@@ -777,9 +780,11 @@ def test_get_archived_workflow_wf_name_and_team_project():
777780
(
778781
given_name,
779782
team_project,
783+
gen3username,
780784
) = engine._get_archived_workflow_wf_name_and_team_project("dummy_uid")
781785
assert given_name == "dummy_wf_name"
782786
assert team_project == "dummy_team_project_label"
787+
assert gen3username == "dummy_user"
783788

784789

785790
@freeze_time("Nov 16th, 2023")

test/test_argo_engine_helper.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_parse_list_item():
224224
assert parsed_item.get("uid") == "test_uid"
225225

226226
def dummy_get_archived_workflow_wf_name_and_team_project(workflow_uid):
227-
return "dummy_wf_name", "dummy_team_project"
227+
return "dummy_wf_name", "dummy_team_project", "dummy_user"
228228

229229
parsed_item = argo_engine_helper.parse_list_item(
230230
workflow_item,
@@ -233,6 +233,7 @@ def dummy_get_archived_workflow_wf_name_and_team_project(workflow_uid):
233233
)
234234
assert parsed_item.get("wf_name") == "dummy_wf_name"
235235
assert parsed_item.get(GEN3_TEAM_PROJECT_METADATA_LABEL) == "dummy_team_project"
236+
assert parsed_item.get(GEN3_USER_METADATA_LABEL) == "dummy_user"
236237

237238

238239
def test_remove_list_duplicates():

0 commit comments

Comments
 (0)