From 2354879f82dece1eca74bed6d0e50b1e4f2b6f28 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Fri, 1 Mar 2024 14:01:00 -0600 Subject: [PATCH 1/4] refactor to allow other calls to cohort middleware --- config.ini | 2 +- src/argowrapper/auth/utils.py | 11 +++++++---- src/argowrapper/constants.py | 4 +--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config.ini b/config.ini index 5d450fa..2f285e4 100644 --- a/config.ini +++ b/config.ini @@ -2,4 +2,4 @@ ARGO_ACCESS_METHOD = access ARGO_HOST = http://argo-argo-workflows-server.argo.svc.cluster.local:2746 ARGO_NAMESPACE = argo -COHORT_DEFINITION_BY_SOURCE_AND_TEAM_PROJECT_URL = http://cohort-middleware-service/cohortdefinition-stats/by-source-id/{}/by-team-project?team-project={} +COHORT_MIDDLEWARE_SERVICE = http://cohort-middleware-service/ diff --git a/src/argowrapper/auth/utils.py b/src/argowrapper/auth/utils.py index 6ecd620..8fcd9f0 100644 --- a/src/argowrapper/auth/utils.py +++ b/src/argowrapper/auth/utils.py @@ -1,17 +1,20 @@ import requests from argowrapper import logger from argowrapper.constants import ( - COHORT_DEFINITION_BY_SOURCE_AND_TEAM_PROJECT_URL, + COHORT_MIDDLEWARE_SERVICE_URL, ) def get_cohort_ids_for_team_project(token, source_id, team_project): header = {"Authorization": token, "cookie": "fence={}".format(token)} - url = COHORT_DEFINITION_BY_SOURCE_AND_TEAM_PROJECT_URL.format( - source_id, team_project + api_url = ( + COHORT_MIDDLEWARE_SERVICE_URL + + "cohortdefinition-stats/by-source-id/{}/by-team-project?team-project={}" ) + api_url = api_url.format(source_id, team_project) + try: - r = requests.get(url=url, headers=header) + r = requests.get(url=api_url, headers=header) r.raise_for_status() team_cohort_info = r.json() team_cohort_id_set = set() diff --git a/src/argowrapper/constants.py b/src/argowrapper/constants.py index 25f43c0..a1095d9 100644 --- a/src/argowrapper/constants.py +++ b/src/argowrapper/constants.py @@ -21,9 +21,7 @@ logger.info(f"Access method: {config['DEFAULT']['ARGO_ACCESS_METHOD']}") ARGO_HOST: Final = config["DEFAULT"]["ARGO_HOST"] -COHORT_DEFINITION_BY_SOURCE_AND_TEAM_PROJECT_URL: Final = config["DEFAULT"][ - "COHORT_DEFINITION_BY_SOURCE_AND_TEAM_PROJECT_URL" -] +COHORT_MIDDLEWARE_SERVICE_URL: Final = config["DEFAULT"]["COHORT_MIDDLEWARE_SERVICE"] TEST_WF: Final = "test.yaml" WF_HEADER: Final = "header.yaml" ARGO_NAMESPACE: Final = config["DEFAULT"]["ARGO_NAMESPACE"] From 6b609c49f450564d59bb4d21e7b31b337d6fb8da Mon Sep 17 00:00:00 2001 From: tianj7 Date: Tue, 5 Mar 2024 10:04:48 -0600 Subject: [PATCH 2/4] add comment --- config.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/config.ini b/config.ini index 2f285e4..5fed638 100644 --- a/config.ini +++ b/config.ini @@ -2,4 +2,5 @@ ARGO_ACCESS_METHOD = access ARGO_HOST = http://argo-argo-workflows-server.argo.svc.cluster.local:2746 ARGO_NAMESPACE = argo +#Configurable URL for Cohort Middleware Service COHORT_MIDDLEWARE_SERVICE = http://cohort-middleware-service/ From 358515b58fb62a74f6944a696b6cd2f18ce380c1 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Tue, 5 Mar 2024 13:15:36 -0600 Subject: [PATCH 3/4] fix slashes --- config.ini | 2 +- src/argowrapper/auth/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.ini b/config.ini index 5fed638..bc96fe3 100644 --- a/config.ini +++ b/config.ini @@ -3,4 +3,4 @@ ARGO_ACCESS_METHOD = access ARGO_HOST = http://argo-argo-workflows-server.argo.svc.cluster.local:2746 ARGO_NAMESPACE = argo #Configurable URL for Cohort Middleware Service -COHORT_MIDDLEWARE_SERVICE = http://cohort-middleware-service/ +COHORT_MIDDLEWARE_SERVICE = http://cohort-middleware-service diff --git a/src/argowrapper/auth/utils.py b/src/argowrapper/auth/utils.py index 8fcd9f0..b2196f2 100644 --- a/src/argowrapper/auth/utils.py +++ b/src/argowrapper/auth/utils.py @@ -9,7 +9,7 @@ def get_cohort_ids_for_team_project(token, source_id, team_project): header = {"Authorization": token, "cookie": "fence={}".format(token)} api_url = ( COHORT_MIDDLEWARE_SERVICE_URL - + "cohortdefinition-stats/by-source-id/{}/by-team-project?team-project={}" + + "/cohortdefinition-stats/by-source-id/{}/by-team-project?team-project={}" ) api_url = api_url.format(source_id, team_project) From 497c055ba07d2e87b3f982a6636c0e59e069f9f6 Mon Sep 17 00:00:00 2001 From: tianj7 Date: Tue, 5 Mar 2024 13:23:18 -0600 Subject: [PATCH 4/4] remove dummy comment --- config.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/config.ini b/config.ini index bc96fe3..f957cd0 100644 --- a/config.ini +++ b/config.ini @@ -2,5 +2,4 @@ ARGO_ACCESS_METHOD = access ARGO_HOST = http://argo-argo-workflows-server.argo.svc.cluster.local:2746 ARGO_NAMESPACE = argo -#Configurable URL for Cohort Middleware Service COHORT_MIDDLEWARE_SERVICE = http://cohort-middleware-service