Skip to content

Add manager for jobs within a pipeline. #413

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

Merged
merged 3 commits into from
Jan 18, 2018

Conversation

kw217
Copy link
Contributor

@kw217 kw217 commented Jan 10, 2018

This PR adds a manager for jobs within a pipeline, so you can say gl.projects.get(prid).pipelines.get(plid).jobs.list() to list all of the jobs within a single pipeline (in GitLab v4).

Please let me know if there are any tests I should add. The existing UTs still pass.

Copy link
Contributor

@gpocentek gpocentek left a comment

Choose a reason for hiding this comment

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

Thanks for this change! Could you have a look at my comments and make the suggested modifications before I merge?

If could could add a couple examples (list and get) in the documentation that would be very nice.

Thanks again 👍

@@ -1940,6 +1942,12 @@ def create(self, data, **kwargs):
return CreateMixin.create(self, data, path=path, **kwargs)


class ProjectPipelineJobManager(RetrieveMixin, RESTManager):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use GetWithoutIdMixin instead of RetrieveMixin?

It looks like getting a single job is not possible with the GitLab API, but we can simulate this feature by looping through the list.

@@ -1940,6 +1942,12 @@ def create(self, data, **kwargs):
return CreateMixin.create(self, data, path=path, **kwargs)


class ProjectPipelineJobManager(RetrieveMixin, RESTManager):
_path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
_obj_cls = ProjectJob
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather use a new ProjectPipelineJob instead of ProjectJob. This is choice I made for other objects and managers, so I'd rather stick to this logic.

kw217 added 2 commits January 15, 2018 10:37
Review markup: better to use a distinct ProjectPipelineJob rather
than sharing ProjectJob. This is consistent with the other objects
and managers.
@kw217
Copy link
Contributor Author

kw217 commented Jan 15, 2018

Thanks @gpocentek - I've added some docs, distinguished the classes as you requested (I just made an pass subclass of the existing class - I hope that's what you wanted), and I've added get support via GetFromListMixin.

In principle we could implement get more efficiently by just calling ProjectJobManager.get and checking the result is in the same pipeline, but there wasn't a mixin to do this already and I wasn't sure how to get hold of the ProjectJobManager so I followed your suggestion instead.

Thanks.

@kw217
Copy link
Contributor Author

kw217 commented Jan 15, 2018

Not sure why the Python 2.7 build failed, but it looks like a connection error pulling one of the libraries, not related to my change :-(

Edit: it seems to have passed now.

@gpocentek gpocentek merged commit bdb6d63 into python-gitlab:master Jan 18, 2018
@gpocentek
Copy link
Contributor

@kw217 Thanks!

@kw217
Copy link
Contributor Author

kw217 commented Jan 18, 2018

Great, thank you!

@kw217 kw217 deleted the add-pipeline-job-manager branch January 18, 2018 11:18
@kw217
Copy link
Contributor Author

kw217 commented Jan 22, 2018

Hi @gpocentek - when are you likely to spin a new release containing this enhancement? I'd like to use it in a tool I'm writing, and it will be simpler to point people at PyPI than getting them to download master. Thanks.

@gpocentek
Copy link
Contributor

Hi @kw217

I'd like to fix a few bugs and merge #398 before doing a release. I hope I'll have this ready in a couple weeks.

@kw217
Copy link
Contributor Author

kw217 commented Jan 24, 2018

Super - that would be great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants