Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added more query params #98

Merged
merged 10 commits into from
Sep 4, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions maap/maap.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,22 @@ def cancelJob(self, jobid):
job.id = jobid
return job.cancel_job()

def listJobs(self, username=None, page_size=None, offset=None):
def listJobs(self, username=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should take an arbitrary kwargs parameter. I would lean towards adding explicit keyword arguments, as keyword-only parameters, something like this (incomplete):

def listJobs(self, *, username=None, algo_id=None, version=None, ...):
    ...

Otherwise, the only way to know the available options is to look at the source code.

I might be swayed to keep what you have only if you add a complete docstring describing all of the supported options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes no real difference to me. Any future updates to the param list will require a similar level of effort for code changes. I can make them explicit.

if username==None and self.profile is not None and 'username' in self.profile.account_info().keys():
marjo-luc marked this conversation as resolved.
Show resolved Hide resolved
username = self.profile.account_info()['username']

url = os.path.join(self.config.dps_job, username, endpoints.DPS_JOB_LIST)
marjo-luc marked this conversation as resolved.
Show resolved Hide resolved
params = {k: v for k, v in (("page_size", page_size), ("offset", offset)) if v}
valid_keys = ['algo_id', 'end_time', 'get_job_details', 'offset', 'page_size', 'priority', 'queue', 'start_time', 'status', 'tag', 'version']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these affect behavior?

  • start_time and end_time: what's the type and/or format, and does the API do an exact match on these?
  • get_job_details: is this a bool? if so, what does it do, simply return more details for each returned job?
  • priority: what is this? a number? what does it represent?

Regardless of whether you apply my suggestion to define explicit keyword parameters, please add a docstring that describes the data types and what they are for (particularly for the non-obvious ones I mentioned above)


params = {k: v for k, v in kwargs.items() if k in valid_keys and v is not None}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params = {k: v for k, v in kwargs.items() if k in valid_keys and v is not None}
params = {
k: v
for k, v in (
("username", username),
("algo_id", algo_id),
...
)
if v is not None
}


# DPS requests use 'job_type', which is a concatenation of 'algo_id' and 'version'
if 'algo_id' in params and 'version' in params:
params['job_type'] = params['algo_id'] + ':' + params['version']

params.pop('algo_id', None)
params.pop('version', None)
marjo-luc marked this conversation as resolved.
Show resolved Hide resolved

headers = self._get_api_header()
logger.debug('GET request sent to {}'.format(url))
logger.debug('headers:')
Expand Down