[12.0] Add graph of dependencies between jobs#154
Conversation
93e3246 to
c1ded7a
Compare
|
I pushed new commits. I still have lots of docs to write and not everything is ready yet, but I would welcome feedback by people interested in the feature :) You can look at the doc of the 'base' model methods and at the tests to have an idea of the dependency API. |
| def load_many(cls, env, job_uuids): | ||
| """Read jobs in batch from the Database | ||
|
|
||
| Jobs not found are ignored. |
|
Something I'm really not sure about is how to deal with identity keys. Currently, I'm checking that if a graph contains some jobs with an identity key, if all the jobs in the graph with an identity key have another job in the db with the same key, then the whole graph is discarded. It doesn't seem very intuitive. What would make most sense to me is to have a single identity key for the whole graph. I'll think about how we could implement this. |
|
Remaining
|
3bc3f63 to
277d247
Compare
7cfa275 to
393259c
Compare
|
@guewen Do you need some help with this? |
5908baa to
ffda53d
Compare
|
@etobella The only thing yet to do I think is about handling the identity key for a whole graph. Well, there is an implementation now which is that if all jobs have an identity key and all these identity keys already exist, we skip the graph. I don't think this is how it should be done, rather have a single identity key for the whole graph. Anyway, I think this could be handled later, the "how" could become more clear at usage. This PR is in a safe enough state to be tested if you'd like :) I should open my PR soon, I'd like to improve the description first 😆 |
|
Beautiful work, as usual :) |
This is not something "on top" of the existing API, but an improvement of the current API to support graphs. Enqueuing a single job is now (aside a few details) enqueueing a graph of 1 job, the mechanism is generic for supporting both ( |
|
Congratulations, your PR was merged at 1bc8417. Thanks a lot for contributing to OCA. ❤️ |
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
on_done() is maybe a better choice, it is less ambiguous than then() (clearer on the fact it happens on done()) and done() (less confusion with set_done()). I'll do the renaming soon, unless you have other suggestions. Ref: OCA#154 (comment)
Issue described in #129.
Introduction
This PR adds a way to express dependencies between jobs, so called jobs graphs.
The delaying API has been rewritten in a way that allows to express these dependencies. Under the hood, an acyclic direct graph is built and stored in the job records. Jobs which depend on another or several other jobs are in a state
wait_dependencies, when a job is done, it finds the dependent jobs, which is set topendingif all the other dependent jobs are done as well.API changes
Single jobs
The new API is entirely backward compatible. Delaying a single job is done as before with:
A new concept of delayable is introduced to compose graph, the above is equivalent to:
Chains
A very simple graph, execute a job when the first is done, can be written as:
.delay()is called only on the root of the graph.If several jobs are chained, it can be easier to build a chain which are executed in sequence:
Groups
Dependencies permit depending on a group of jobs, the third method is executed when the two jobs of the group are done:
UI for graphs
Changes for the graphs and some various tweaks:
Improved testing
Unit tests
A new testing facility is added, which helps a lot to run assertions on enqueued jobs. It is strongly encouraged to write unit tests using this assert. It works on any jobs, this is not specially related to graphs.
Inside the
mock_jobscontext manager, jobs are never stored in database. However, they are kept in memory in the context manager instance, which allow running checks on them.Additionally, as the jobs are stored in the context manager instance, we can even choose to execute them in the test or not, depending on what we are testing.
Test jobs
The controller
/queue_job/create_test_jobcan now generate a random graph of jobs, using the parameters:Warnings
As of today, there is no correct handling of identity keys for graphs. We still need to figure out the most correct way to handle an identity key for a graph. However, the identity key still work the same way for single jobs.
Closes #129