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

[PS-13958] - Extend options for listing jobs #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 16 additions & 2 deletions domino/domino.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,28 @@ def job_stop(self, job_id: str, commit_results: bool = True):
response = self.request_manager.post(url, json=request)
return response

def jobs_list(self, project_id: str, page_size=None):
def jobs_list(self,
project_id: str,
order_by: str = "number",
sort_by: str = "desc",
page_size: int = 3,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the page_size in None as a default value? If this default value is enforced by Domino (I see the 3 in the old description) and changes in the future, we might want to also have that change applied seamless here.

What do you think?

page_no: int = 1,
show_archived: str = "false",
status: str = "all",
tag: Optional[str] = None):
"""
Lists job history for a given project_id
:param project_id: The project to query
:param order_by: Field on which sort has to be applied– e.g. "title" (default "number")
:param sort_by: Sort "desc" (default) or "asc"
:param page_size: The number of jobs to return (default: 3)
:param page_no: Page number to fetch (default: 1).
:param show_archived: Show archived jobs in results (default: false)
:param status: Status of jobs to fetch– e.g. "completed" (default: "all")
:param tag: Optional tag filter
:return: The details
"""
url = self._routes.jobs_list(project_id, page_size)
url = self._routes.jobs_list(project_id, order_by, sort_by, page_size, page_no, show_archived, status, tag)
return self._get(url)


Expand Down
21 changes: 18 additions & 3 deletions domino/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,24 @@ def job_start(self):
def job_stop(self):
return f"{self.host}/v4/jobs/stop"

def jobs_list(self, project_id, page_size: Optional[str]):
page_size_query = f"&page_size={page_size}" if page_size else ""
return f"{self.host}/v4/jobs?projectId={project_id}{page_size_query}"
def jobs_list(self,
project_id,
order_by,
sort_by,
page_size,
page_no,
show_archived,
status,
tag):

order_by_query = f"&order_by={order_by}"
sort_by_query = f"&sort_by={sort_by}"
page_size_query = f"&page_size={page_size}"
page_no_query = f"&page_no={page_no}"
show_archived_query = "&show_archived=" + show_archived.lower()
status_from_query = "&status=" + status.lower()
tag_query = f"&tag={tag}" if tag else ""
return f"{self.host}/v4/jobs?projectId={project_id}{order_by_query}{sort_by_query}{page_size_query}{page_no_query}{show_archived_query}{status_from_query}{tag_query}"

def job_status(self, job_id):
return f"{self.host}/v4/jobs/{job_id}"
Expand Down