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 diff --git a/maap/maap.py b/maap/maap.py index 19514f1..704f92d 100644 --- a/maap/maap.py +++ b/maap/maap.py @@ -259,7 +259,7 @@ def cancelJob(self, jobid): job.id = jobid return job.cancel_job() - def listJobs(self, username=None, *, + def listJobs(self, *, algo_id=None, end_time=None, get_job_details=True, @@ -274,7 +274,6 @@ def listJobs(self, username=None, *, Returns a list of jobs for a given user that matches query params provided. Args: - username (str, optional): Platform user. If no username is provided, the profile username will be used. algo_id (str, optional): Algorithm type. end_time (str, optional): Specifying this parameter will return all jobs that have completed from the provided end time to now. e.g. 2024-01-01 or 2024-01-01T00:00:00.000000Z. get_job_details (bool, optional): Flag that determines whether to return a detailed job list or a compact list containing just the job ids and their associated job tags. Default is True. @@ -290,18 +289,11 @@ def listJobs(self, username=None, *, list: List of jobs for a given user that matches query params provided. Raises: - ValueError: If username is not provided and cannot be obtained from the user's profile. ValueError: If either algo_id or version is provided, but not both. """ - if username is None and self.profile is not None and 'username' in self.profile.account_info().keys(): - username = self.profile.account_info()['username'] - - if username is None: - raise ValueError("Unable to determine username from profile. Please provide a username.") - url = "/".join( segment.strip("/") - for segment in (self.config.dps_job, username, endpoints.DPS_JOB_LIST) + for segment in (self.config.dps_job, endpoints.DPS_JOB_LIST) ) params = { @@ -316,7 +308,6 @@ def listJobs(self, username=None, *, ("start_time", start_time), ("status", status), ("tag", tag), - ("username", username), ("version", version), ) if v is not None @@ -349,6 +340,10 @@ def listJobs(self, username=None, *, return response def submitJob(self, identifier, algo_id, version, queue, retrieve_attributes=False, **kwargs): + # 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) job = DPSJob(self.config) 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 "]