Merge lp:~abentley/launchpad/celery-everywhere-3 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Aaron Bentley on 2012-04-13 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15097 |
| Proposed branch: | lp:~abentley/launchpad/celery-everywhere-3 |
| Merge into: | lp:launchpad |
| Prerequisite: | lp:~abentley/launchpad/celery-everywhere-2 |
| Diff against target: |
628 lines (+204/-77) 10 files modified
lib/lp/code/model/branchmergeproposal.py (+4/-3) lib/lp/code/model/branchmergeproposaljob.py (+44/-50) lib/lp/code/model/tests/test_branchmergeproposaljobs.py (+100/-2) lib/lp/codehosting/scanner/tests/test_email.py (+6/-10) lib/lp/codehosting/scanner/tests/test_mergedetection.py (+1/-2) lib/lp/services/job/celeryjob.py (+9/-1) lib/lp/services/job/model/job.py (+12/-4) lib/lp/services/job/runner.py (+7/-4) lib/lp/services/job/tests/__init__.py (+8/-1) lib/lp/services/job/tests/test_job.py (+13/-0) |
| To merge this branch: | bzr merge lp:~abentley/launchpad/celery-everywhere-3 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| j.c.sackett (community) | 2012-04-12 | Approve on 2012-04-12 | |
| Richard Harding (community) | code* | 2012-04-11 | Approve on 2012-04-12 |
|
Review via email:
|
|||
Commit Message
Support running BranchMergeProp
Description of the Change
= Summary =
Implement Celery support for BranchMergeProp
== Proposed fix ==
Add BranchMergeProp
== Pre-implementation notes ==
None
== Implementation details ==
All jobs specify a config.
Some jobs send mail, so I extracted pop_remote_
Jobs which need access to branches are updated to use server(
BranchMergeProp
Some of BranchMergeProp
The contents of ReviewRequested
It turns out that apply_async(
== LOC ==
This code is part of a resourced arc that will reduce LOC
== Tests ==
bin/test -t TestViaCelery test_branchmerg
== Demo and Q/A ==
None
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
| Aaron Bentley (abentley) wrote : | # |
> - Are we allowed to do multiple imports on a single line if they're done as
> per the circular deps code in #10?
No. I'll fix it.
> - cant the config.
> the repetition?
It can. It shouldn't be. These values should all be different, because each job is supposed to have its own database user. However, currently all merge proposal jobs have the same database user (and config), so I've reproduced that here.
> - can the tests setup the context in the setUp method of the test class in
> TestViaCelery
It can, but I never use setUp if I can help it. It impedes code re-use and it's less explicit.
http://
| j.c.sackett (jcsackett) wrote : | # |
Aaron--
Very nice. Marking as improved, with a minor nag below.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -261,11 +261,18 @@
> from lp.code.
> BranchJob,
> )
> - store = IStore(BranchJob)
> - branch_job = store.find(
> - if branch_job is None:
> + from lp.code.
> + BranchMergeProp
> + )
> + store = IStore(Job)
> + for cls in [BranchJob, BranchMergeProp
> + base_job = store.find(cls, cls.job == job_id).one()
> + if base_job is not None:
> + break
> + if base_job is None:
> raise ValueError('No BranchJob with job=%s.' % job_id)
> - return branch_
> +
> + return base_job.
>
> @classmethod
> def switchDBUser(cls, job_id):
I'm assuming the imports within this method are b/c of circular import
issues; could you throw in a comment saying so?
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -194,10 +194,13 @@
> """Request that this job be run via celery."""
> # Avoid importing from lp.services.
> # avoid configuring Celery when Rabbit is not configured.
> - from lp.services.
> - return CeleryRunJob.
> - (self.job_id,), queue=self.
> - ignore_
> + from lp.services.
> + CeleryRunJob, CeleryRunJobIgn
> + if ignore_result:
> + cls = CeleryRunJobIgn
> + else:
> + cls = CeleryRunJob
> + return cls.apply_
Same comment as above.
| Aaron Bentley (abentley) wrote : | # |
> Aaron--
>
> Very nice. Marking as improved, with a minor nag below.
>
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > @@ -261,11 +261,18 @@
> > from lp.code.
> > BranchJob,
> > )
> > - store = IStore(BranchJob)
> > - branch_job = store.find(
> > - if branch_job is None:
> > + from lp.code.
> > + BranchMergeProp
> > + )
> > + store = IStore(Job)
> > + for cls in [BranchJob, BranchMergeProp
> > + base_job = store.find(cls, cls.job == job_id).one()
> > + if base_job is not None:
> > + break
> > + if base_job is None:
> > raise ValueError('No BranchJob with job=%s.' % job_id)
> > - return branch_
> > +
> > + return base_job.
> >
> > @classmethod
> > def switchDBUser(cls, job_id):
>
> I'm assuming the imports within this method are b/c of circular import
> issues; could you throw in a comment saying so?
Done.
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > @@ -194,10 +194,13 @@
> > """Request that this job be run via celery."""
> > # Avoid importing from lp.services.
> to
> > # avoid configuring Celery when Rabbit is not configured.
> > - from lp.services.
> > - return CeleryRunJob.
> > - (self.job_id,), queue=self.
> > - ignore_
> > + from lp.services.
> > + CeleryRunJob, CeleryRunJobIgn
> > + if ignore_result:
> > + cls = CeleryRunJobIgn
> > + else:
> > + cls = CeleryRunJob
> > + return cls.apply_
>
> Same comment as above.
There is already a comment explaining these imports: "Avoid importing from lp.services.

Aaron, thanks for the branch. Looks good. I've got a couple of questions, but approving as these are small items.
- Are we allowed to do multiple imports on a single line if they're done as per the circular deps code in #10? merge_proposal_ jobs be put on the super class to prevent the repetition?
- cant the config.
- can the tests setup the context in the setUp method of the test class in TestViaCelery