From cb6f6282e25c4f877699159848df5f572d737d56 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 13:51:10 -0700 Subject: [PATCH 01/15] added print statements --- maap/maap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index 8b91695..2b69604 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -28,6 +28,8 @@ class MAAP(object): def __init__(self, maap_host=os.getenv('MAAP_API_HOST', 'api.maap-project.org')): + print("graceal1 maap host in init is") + print(maap_host) self.config = MaapConfig(maap_host=maap_host) self._CMR = CMR(self.config.indexed_attributes, self.config.page_size, self._get_api_header()) From ffbaec1bc0bc5052e64374ff22d501c87690c420 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 14:51:40 -0700 Subject: [PATCH 02/15] added print statements --- maap/maap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index 2b69604..ed0759f 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -261,6 +261,8 @@ def cancelJob(self, jobid): def listJobs(self, username=None, page_size=None, offset=None): if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): username = self.profile.account_info()['username'] + print("graceal1 username in listJobs in maap-py is ") + print(username) url = os.path.join(self.config.dps_job, username, endpoints.DPS_JOB_LIST) params = {k: v for k, v in (("page_size", page_size), ("offset", offset)) if v} From 0830b32c47d30912643ec54ff3ff65bace1b12b8 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 17:28:53 -0700 Subject: [PATCH 03/15] assigning username is not present for submitJob --- maap/maap.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index ed0759f..22598fd 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -279,6 +279,15 @@ def listJobs(self, username=None, page_size=None, offset=None): return response def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=False, **kwargs): + print("graceal1 in submitJob maap-py and kwargs is") + print(kwargs) + print(self.profile) + if not 'username' in kwargs and self.profile is not None and 'username' in self.profile.account_info().keys(): + print("graceal1 in submitJob and assigning username") + print(self.profile.account_info()['username']) + kwargs['username'] = self.profile.account_info()['username'] + print("graceal1 username in listJobs in maap-py outside if is ") + print(kwargs['username']) response = self._DPS.submit_job(request_url=self.config.dps_job, identifier=identifier, algo_id=algo_id, version=version, queue=queue, **kwargs) job = DPSJob(self.config) From b233030eecaefad6a34343ef88c4774fd5f38d12 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 17:47:12 -0700 Subject: [PATCH 04/15] modified print statement --- maap/maap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maap/maap.py b/maap/maap.py index 22598fd..5b5182d 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -28,7 +28,7 @@ class MAAP(object): def __init__(self, maap_host=os.getenv('MAAP_API_HOST', 'api.maap-project.org')): - print("graceal1 maap host in init is") + print("graceal1 maap host in init is TEST") print(maap_host) self.config = MaapConfig(maap_host=maap_host) @@ -259,6 +259,7 @@ def cancelJob(self, jobid): return job.cancel_job() def listJobs(self, username=None, page_size=None, offset=None): + print("graceal1 in listJobs") if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): username = self.profile.account_info()['username'] print("graceal1 username in listJobs in maap-py is ") From b7172af94743d6d98527f1d68b0ee1158779df05 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 18:29:59 -0700 Subject: [PATCH 05/15] added print statements --- maap/maap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index 5b5182d..4c9762c 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -260,6 +260,10 @@ def cancelJob(self, jobid): def listJobs(self, username=None, page_size=None, offset=None): print("graceal1 in listJobs") + print(username) + print(self.profile) + print(self.profile.account_info()) + print(self.profile.account_info().keys()) if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): username = self.profile.account_info()['username'] print("graceal1 username in listJobs in maap-py is ") From 8db49f393ae39b0bebdb07109fa8f07d8922fc5e Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 18:37:56 -0700 Subject: [PATCH 06/15] added more print statements --- maap/Profile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/maap/Profile.py b/maap/Profile.py index c6580bf..334dc17 100644 --- a/maap/Profile.py +++ b/maap/Profile.py @@ -20,6 +20,9 @@ def account_info(self): url=self._profile_endpoint, headers=self._api_header ) + print("graceal1 in account info ") + print(self._profile_endpoint) + print(self._api_header) if response: return json.loads(response.text) From 3d8bb11dc166b0153fc26c67ae04dc9165a760ac Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 19:24:58 -0700 Subject: [PATCH 07/15] hard coded in my username --- maap/Profile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maap/Profile.py b/maap/Profile.py index 334dc17..7fa6ca0 100644 --- a/maap/Profile.py +++ b/maap/Profile.py @@ -23,6 +23,8 @@ def account_info(self): print("graceal1 in account info ") print(self._profile_endpoint) print(self._api_header) + # Graceal need to remove this + return {"username": "grallewellyn"} if response: return json.loads(response.text) From d7e88c14c8bf50ed86880317c3c92c85c5c8c462 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 19:39:20 -0700 Subject: [PATCH 08/15] added print statements for listJobs request --- maap/maap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index 4c9762c..8b710c1 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -276,6 +276,10 @@ def listJobs(self, username=None, page_size=None, offset=None): logger.debug('GET request sent to {}'.format(url)) logger.debug('headers:') logger.debug(headers) + print("graceal1 making a request in listJobs to") + print(url) + print(headers) + print(params) response = requests.get( url=url, headers=headers, From 1482aa15a5351c4c3e5b5358f4b1086c3d6c9ee8 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 21:39:00 -0700 Subject: [PATCH 09/15] added print statements for submitting jobs and algorithms --- maap/dps/DpsHelper.py | 10 ++++++++++ maap/maap.py | 6 +++++- maap/utils/requests_utils.py | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/maap/dps/DpsHelper.py b/maap/dps/DpsHelper.py index e790939..34e1728 100644 --- a/maap/dps/DpsHelper.py +++ b/maap/dps/DpsHelper.py @@ -77,6 +77,10 @@ def submit_job(self, request_url, **kwargs): # ================================== # Part 2: Build & Send Request # ================================== + print("graceal1 in submit_job with") + print(fields) + print(params) + print(inputs) req_xml = '' ins_xml = '' @@ -102,6 +106,10 @@ def submit_job(self, request_url, **kwargs): # log request headers logging.debug('headers:') logging.debug(self._api_header) + print("graceal1 request and api header") + print(request_url) + print(req_xml) + print(self._api_header) # ------------------------------- # Send Request @@ -114,6 +122,8 @@ def submit_job(self, request_url, **kwargs): ) logging.debug('status code {}'.format(r.status_code)) logging.debug('response text\n{}'.format(r.text)) + print("graceal1 response is ") + print(r) # ================================== # Part 3: Check & Parse Response diff --git a/maap/maap.py b/maap/maap.py index 8b710c1..de9ed2b 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -145,6 +145,7 @@ def getQueues(self): return response def registerAlgorithm(self, arg): + print("graceal1 in registerAlgorithm") logger.debug('Registering algorithm with args ') if type(arg) is dict: arg = json.dumps(arg) @@ -156,6 +157,7 @@ def registerAlgorithm(self, arg): return response def register_algorithm_from_yaml_file(self, file_path): + print("graceal1 in register_algorithm_from_yaml_file") algo_config = algorithm_utils.read_yaml_file(file_path) return self.registerAlgorithm(algo_config) @@ -295,10 +297,12 @@ def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=Fal print("graceal1 in submitJob and assigning username") print(self.profile.account_info()['username']) kwargs['username'] = self.profile.account_info()['username'] - print("graceal1 username in listJobs in maap-py outside if is ") + print("graceal1 username in submitJob in maap-py outside if is ") print(kwargs['username']) response = self._DPS.submit_job(request_url=self.config.dps_job, identifier=identifier, algo_id=algo_id, version=version, queue=queue, **kwargs) + print("graceal1 response from submitting job is") + print(response) job = DPSJob(self.config) job.set_submitted_job_result(response) try: diff --git a/maap/utils/requests_utils.py b/maap/utils/requests_utils.py index 7a53a74..3f5d1e9 100644 --- a/maap/utils/requests_utils.py +++ b/maap/utils/requests_utils.py @@ -55,6 +55,12 @@ def make_request(url, config: MaapConfig, content_type=None, request_type: HTTPM # TODO: Add support for request type DELETE raise NotImplementedError(f"Request type {request_type} not supported") else: + print("graceal1 posting algorithm with ") + print(request_type.value) + print(url) + print(not self_signed) + print(headers) + print(kwargs) return requests.request( method=request_type.value, url=url, From 7e5a2f04bdf0a64c7e01541ee7f558da219f8103 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 21:56:45 -0700 Subject: [PATCH 10/15] removed hard coding username --- maap/Profile.py | 2 -- maap/maap.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maap/Profile.py b/maap/Profile.py index 7fa6ca0..334dc17 100644 --- a/maap/Profile.py +++ b/maap/Profile.py @@ -23,8 +23,6 @@ def account_info(self): print("graceal1 in account info ") print(self._profile_endpoint) print(self._api_header) - # Graceal need to remove this - return {"username": "grallewellyn"} if response: return json.loads(response.text) diff --git a/maap/maap.py b/maap/maap.py index de9ed2b..953ac0a 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -153,6 +153,8 @@ def registerAlgorithm(self, arg): response = requests_utils.make_request(url=self.config.algorithm_register, config=self.config, content_type='application/json', request_type=requests_utils.POST, data=arg) + print("graceal1 response of posting algorithm was ") + print(response) logger.debug('POST request sent to {}'.format(self.config.algorithm_register)) return response From 3b6a4327fc18ff1f8580c783f088146f9444c46d Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 21 Aug 2024 22:05:27 -0700 Subject: [PATCH 11/15] removed print statements --- maap/Profile.py | 3 --- maap/dps/DpsHelper.py | 10 ---------- maap/maap.py | 26 -------------------------- maap/utils/requests_utils.py | 6 ------ 4 files changed, 45 deletions(-) diff --git a/maap/Profile.py b/maap/Profile.py index 334dc17..c6580bf 100644 --- a/maap/Profile.py +++ b/maap/Profile.py @@ -20,9 +20,6 @@ def account_info(self): url=self._profile_endpoint, headers=self._api_header ) - print("graceal1 in account info ") - print(self._profile_endpoint) - print(self._api_header) if response: return json.loads(response.text) diff --git a/maap/dps/DpsHelper.py b/maap/dps/DpsHelper.py index 34e1728..e790939 100644 --- a/maap/dps/DpsHelper.py +++ b/maap/dps/DpsHelper.py @@ -77,10 +77,6 @@ def submit_job(self, request_url, **kwargs): # ================================== # Part 2: Build & Send Request # ================================== - print("graceal1 in submit_job with") - print(fields) - print(params) - print(inputs) req_xml = '' ins_xml = '' @@ -106,10 +102,6 @@ def submit_job(self, request_url, **kwargs): # log request headers logging.debug('headers:') logging.debug(self._api_header) - print("graceal1 request and api header") - print(request_url) - print(req_xml) - print(self._api_header) # ------------------------------- # Send Request @@ -122,8 +114,6 @@ def submit_job(self, request_url, **kwargs): ) logging.debug('status code {}'.format(r.status_code)) logging.debug('response text\n{}'.format(r.text)) - print("graceal1 response is ") - print(r) # ================================== # Part 3: Check & Parse Response diff --git a/maap/maap.py b/maap/maap.py index 953ac0a..03d4f24 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -28,8 +28,6 @@ class MAAP(object): def __init__(self, maap_host=os.getenv('MAAP_API_HOST', 'api.maap-project.org')): - print("graceal1 maap host in init is TEST") - print(maap_host) self.config = MaapConfig(maap_host=maap_host) self._CMR = CMR(self.config.indexed_attributes, self.config.page_size, self._get_api_header()) @@ -145,7 +143,6 @@ def getQueues(self): return response def registerAlgorithm(self, arg): - print("graceal1 in registerAlgorithm") logger.debug('Registering algorithm with args ') if type(arg) is dict: arg = json.dumps(arg) @@ -153,13 +150,10 @@ def registerAlgorithm(self, arg): response = requests_utils.make_request(url=self.config.algorithm_register, config=self.config, content_type='application/json', request_type=requests_utils.POST, data=arg) - print("graceal1 response of posting algorithm was ") - print(response) logger.debug('POST request sent to {}'.format(self.config.algorithm_register)) return response def register_algorithm_from_yaml_file(self, file_path): - print("graceal1 in register_algorithm_from_yaml_file") algo_config = algorithm_utils.read_yaml_file(file_path) return self.registerAlgorithm(algo_config) @@ -263,15 +257,8 @@ def cancelJob(self, jobid): return job.cancel_job() def listJobs(self, username=None, page_size=None, offset=None): - print("graceal1 in listJobs") - print(username) - print(self.profile) - print(self.profile.account_info()) - print(self.profile.account_info().keys()) if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): username = self.profile.account_info()['username'] - print("graceal1 username in listJobs in maap-py is ") - print(username) url = os.path.join(self.config.dps_job, username, endpoints.DPS_JOB_LIST) params = {k: v for k, v in (("page_size", page_size), ("offset", offset)) if v} @@ -280,10 +267,6 @@ def listJobs(self, username=None, page_size=None, offset=None): logger.debug('GET request sent to {}'.format(url)) logger.debug('headers:') logger.debug(headers) - print("graceal1 making a request in listJobs to") - print(url) - print(headers) - print(params) response = requests.get( url=url, headers=headers, @@ -292,19 +275,10 @@ def listJobs(self, username=None, page_size=None, offset=None): return response def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=False, **kwargs): - print("graceal1 in submitJob maap-py and kwargs is") - print(kwargs) - print(self.profile) if not 'username' in kwargs and self.profile is not None and 'username' in self.profile.account_info().keys(): - print("graceal1 in submitJob and assigning username") - print(self.profile.account_info()['username']) kwargs['username'] = self.profile.account_info()['username'] - print("graceal1 username in submitJob in maap-py outside if is ") - print(kwargs['username']) response = self._DPS.submit_job(request_url=self.config.dps_job, identifier=identifier, algo_id=algo_id, version=version, queue=queue, **kwargs) - print("graceal1 response from submitting job is") - print(response) job = DPSJob(self.config) job.set_submitted_job_result(response) try: diff --git a/maap/utils/requests_utils.py b/maap/utils/requests_utils.py index 3f5d1e9..7a53a74 100644 --- a/maap/utils/requests_utils.py +++ b/maap/utils/requests_utils.py @@ -55,12 +55,6 @@ def make_request(url, config: MaapConfig, content_type=None, request_type: HTTPM # TODO: Add support for request type DELETE raise NotImplementedError(f"Request type {request_type} not supported") else: - print("graceal1 posting algorithm with ") - print(request_type.value) - print(url) - print(not self_signed) - print(headers) - print(kwargs) return requests.request( method=request_type.value, url=url, From b237d36388dfef5cdb94eb7c281d6da6689ee02c Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Tue, 22 Oct 2024 17:23:46 -0700 Subject: [PATCH 12/15] added print statements --- maap/maap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/maap/maap.py b/maap/maap.py index 03d4f24..43bab3c 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -258,6 +258,8 @@ def cancelJob(self, jobid): def listJobs(self, username=None, page_size=None, offset=None): if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): + print("graceal1 in listJobs and setting username to ") + print(self.profile.account_info()['username']) username = self.profile.account_info()['username'] url = os.path.join(self.config.dps_job, username, endpoints.DPS_JOB_LIST) @@ -276,6 +278,8 @@ def listJobs(self, username=None, page_size=None, offset=None): def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=False, **kwargs): if not 'username' in kwargs and self.profile is not None and 'username' in self.profile.account_info().keys(): + print("graceal1 username was not defined and setting username to ") + print(self.profile.account_info()['username']) kwargs['username'] = self.profile.account_info()['username'] response = self._DPS.submit_job(request_url=self.config.dps_job, identifier=identifier, algo_id=algo_id, version=version, queue=queue, **kwargs) From d294363cf9888ac2c27b3b751006f026c8ffae96 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Fri, 25 Oct 2024 16:12:32 -0700 Subject: [PATCH 13/15] no longer need username for listJobs but keeping for submitJob --- maap/maap.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/maap/maap.py b/maap/maap.py index 43bab3c..a1f1ff8 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -256,13 +256,8 @@ def cancelJob(self, jobid): job.id = jobid return job.cancel_job() - def listJobs(self, username=None, page_size=None, offset=None): - if username==None and self.profile is not None and 'username' in self.profile.account_info().keys(): - print("graceal1 in listJobs and setting username to ") - print(self.profile.account_info()['username']) - username = self.profile.account_info()['username'] - - url = os.path.join(self.config.dps_job, username, endpoints.DPS_JOB_LIST) + def listJobs(self, page_size=None, offset=None): + url = os.path.join(self.config.dps_job, endpoints.DPS_JOB_LIST) params = {k: v for k, v in (("page_size", page_size), ("offset", offset)) if v} headers = self._get_api_header() @@ -277,9 +272,9 @@ def listJobs(self, username=None, page_size=None, offset=None): return response def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=False, **kwargs): - if not 'username' in kwargs and self.profile is not None and 'username' in self.profile.account_info().keys(): - print("graceal1 username was not defined and setting username to ") - print(self.profile.account_info()['username']) + # Note that this is temporary and will be removed when we remove the API not requiring username to submit a job + # Also this now overrides passing someone else's username into submitJob since we don't want to allow that + if self.profile is not None and self.profile.account_info() is not None and 'username' in self.profile.account_info().keys(): kwargs['username'] = self.profile.account_info()['username'] response = self._DPS.submit_job(request_url=self.config.dps_job, identifier=identifier, algo_id=algo_id, version=version, queue=queue, **kwargs) From b78b6347fb14e81ef3eb7ee2b7bd89490c14ad3f Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Fri, 25 Oct 2024 17:16:01 -0700 Subject: [PATCH 14/15] increased version number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bbec84b..7fb5548 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "maap-py" -version = "4.1.0a3" +version = "4.2.0" description = "Python client API for interacting with the NASA MAAP API" repository = "https://github.com/MAAP-Project/maap-py" authors = ["Jet Propulsion Laboratory "] From ca1900f10b1dfbadc1bbb3e3053504b3d5656ec8 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Mon, 28 Oct 2024 10:42:00 -0700 Subject: [PATCH 15/15] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b39d4f6..31f8b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +(post 4.1.1 release) ### Added ### Changed +- listJobs no longer takes username as an argument, you can only list jobs for the current `MAAP_PGT` token user +- submitJob gets the username from the `MAAP_PGT` token and not username being submitted as an argument ### Deprecated ### Removed ### Fixed