-
Notifications
You must be signed in to change notification settings - Fork 6
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
Changes from 3 commits
b43ac1a
f849719
ba2fbad
ae91831
1e2426a
1878389
d7f3f05
7e91c6d
343ee53
5b12d72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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): | ||||||||||||||||||||||
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'] | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do these affect behavior?
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} | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
# 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:') | ||||||||||||||||||||||
|
There was a problem hiding this comment.
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):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.
There was a problem hiding this comment.
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.