-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Multiple requires #2475
Multiple requires #2475
Conversation
I am not familiar with these features. I'll try to look into them and provide you a review afterward. Thanks for the submission! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i previously mentioned, I don't have experience with these util decorators. However, after looking into this code (assume the old code functioned correctly), your additions to handle arbitrary number of inheritances and requires makes sense to me.
I'm good with this after one other positive review!
luigi/util.py
Outdated
if len(self.tasks_to_require) == 1: | ||
return _self.clone_parent() | ||
|
||
return _self.clone_parents() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly make this a one-liner (equally clear, but prettier)
return _self.clone_parent() if len(self.tasks_to_require) == 1 else _self.clone_parents()
3829fec
to
e20e82e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. But would you mind testing this for a week or so in production before we merge?
class MySecondTask(luigi.Task): | ||
def requires(self): | ||
return self.clone_parents() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a 'note' that this was added after version 2.7.6?
test/decorator_test.py
Outdated
class shouldfail(luigi.Task): | ||
pass | ||
|
||
self.assertRaises(TypeError, create_task_with_empty_inheritance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace this with the with decorator for assertRaises?
test/decorator_test.py
Outdated
class shouldfail(luigi.Task): | ||
pass | ||
|
||
self.assertRaises(TypeError, create_task_with_empty_requires) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Huge thanks for updating the documentation as well! |
Interestingly, I just came across an attempt at this same intention almost 2 years ago in #1845 |
e20e82e
to
3829fec
Compare
@Tarrasch could you please explain how I should test it in production? |
I believe he just means use your own code for your own pipelines and verify it functions the way you expect. |
@Tarrasch @dlstadther I believe this is ready to be merged. |
Did production tests of this code function as expected in your "live" pipelines @StasDeep ? |
@dlstadther yes, everything works as expected. |
Add support for multiple task arguments for requires and inherits decorators
* upstream-master: (82 commits) S3 client refactor (spotify#2482) Rename to rpc_log_retries, and make it apply to all the logging involved Factor log_exceptions into a configuration parameter Fix attribute forwarding for tasks with dynamic dependencies (spotify#2478) Add a visiblity level for luigi.Parameters (spotify#2278) Add support for multiple requires and inherits arguments (spotify#2475) Add metadata columns to the RDBMS contrib (spotify#2440) Fix race condition in luigi.lock.acquire_for (spotify#2357) (spotify#2477) tests: Use RunOnceTask where possible (spotify#2476) Optional TOML configs support (spotify#2457) Added default port behaviour for Redshift (spotify#2474) Add codeowners file with default and specific example (spotify#2465) Add Data Revenue to the `blogged` list (spotify#2472) Fix Scheduler.add_task to overwrite accepts_messages attribute. (spotify#2469) Use task_id comparison in Task.__eq__. (spotify#2462) Add stale config Move github templates to .github dir Fix transfer config import (spotify#2458) Additions to provide support for the Load Sharing Facility (LSF) job scheduler (spotify#2373) Version 2.7.6 ...
* upstream-master: S3 client refactor (spotify#2482) Rename to rpc_log_retries, and make it apply to all the logging involved Factor log_exceptions into a configuration parameter Fix attribute forwarding for tasks with dynamic dependencies (spotify#2478) Add a visiblity level for luigi.Parameters (spotify#2278) Add support for multiple requires and inherits arguments (spotify#2475) Add metadata columns to the RDBMS contrib (spotify#2440) Fix race condition in luigi.lock.acquire_for (spotify#2357) (spotify#2477) tests: Use RunOnceTask where possible (spotify#2476) Optional TOML configs support (spotify#2457) Added default port behaviour for Redshift (spotify#2474) Add codeowners file with default and specific example (spotify#2465) Add Data Revenue to the `blogged` list (spotify#2472)
* upstream-master: Remove long-deprecated scheduler config variable alternatives (spotify#2491) Bump tornado milestone version (spotify#2490) Update moto to 1.x milestone version (spotify#2471) Use passed password when create a redis connection (spotify#2489) S3 client refactor (spotify#2482) Rename to rpc_log_retries, and make it apply to all the logging involved Factor log_exceptions into a configuration parameter Fix attribute forwarding for tasks with dynamic dependencies (spotify#2478) Add a visiblity level for luigi.Parameters (spotify#2278) Add support for multiple requires and inherits arguments (spotify#2475) Add metadata columns to the RDBMS contrib (spotify#2440) Fix race condition in luigi.lock.acquire_for (spotify#2357) (spotify#2477) tests: Use RunOnceTask where possible (spotify#2476) Optional TOML configs support (spotify#2457) Added default port behaviour for Redshift (spotify#2474) Add codeowners file with default and specific example (spotify#2465) Add Data Revenue to the `blogged` list (spotify#2472) Fix Scheduler.add_task to overwrite accepts_messages attribute. (spotify#2469) Use task_id comparison in Task.__eq__. (spotify#2462)
Description
Now
requires
decorator can take multiple tasks to require, as well asinherits
decorator (no need to stack them now). Butclone_parent
method becomes ambiguous in cases when there are 2+ tasks to inherit. I've kept it as is to not break anything and addedclone_parents
method, that is used insiderequires
decorator.Motivation and Context
Resolves #1934.
Have you tested this? If so, how?
I have included new unit tests.