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

feat(client): adapt OpenAPI listJob #1173

Merged
merged 1 commit into from
Dec 22, 2021
Merged
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
14 changes: 9 additions & 5 deletions tensorbay/client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,14 @@ def _delete_job(self, job_id: str) -> None:

"""

def _generate_jobs(
def _list_jobs(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the _generate_jobs changes to _list_jobs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we do not need to get a generator. We will add the _generate job to SquashAndMerge.
SquashAndMerge.list_jobs -> SquashAndMerge._generate_jobs -> JobMixin._list_jobs

self,
job_type: str,
status: Optional[str] = None,
offset: int = 0,
limit: int = 128,
) -> Generator[Dict[str, Any], None, int]:
"""Get a generator of :class:`Job`.
) -> Dict[str, Any]:
"""Get a dict containing the information of :class:`Job` list.

Arguments:
job_type: Type of the Job.
Expand All @@ -659,10 +659,14 @@ def _generate_jobs(
offset: The offset of the page.
limit: The limit of the page.

Return:
The generator of job info.
Returns:
A dict containing the information of Job list.

"""
params = {"jobType": job_type, "status": status, "offset": offset, "limit": limit}

response = self._client.open_api_do("GET", "jobs", self._dataset_id, params=params)
return response.json() # type: ignore[no-any-return]


class SquashAndMerge(JobMixin):
Expand Down