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

New dag decorator #1059

Merged
merged 13 commits into from
May 15, 2024
Merged

New dag decorator #1059

merged 13 commits into from
May 15, 2024

Conversation

elliotgunton
Copy link
Collaborator

@elliotgunton elliotgunton commented May 7, 2024

Pull Request Checklist

Description of PR
Adds the new dag decorator from HEP0001.

  • Within the decorator function call we perform a static inspection of
    inputs and outputs, add a DAG object to the Workflow, and finally
    do a "run" of the DAG function code using a templated input to collect the tasks
  • Tasks that pass arguments simply take the templated input strings by using pydantic's construct method to skip validation, and then pass the strings around
  • The dependencies between tasks are inferred automatically via getattr calls
    on the Task object
  • Add varname as a dependency to be able to get the python variable name to use
    as the task name (in the YAML)
  • Make the _add_type_hints function work for any pydantic class

@elliotgunton elliotgunton added type:enhancement A general enhancement semver:minor A change requiring a minor version bump labels May 7, 2024
@elliotgunton elliotgunton added this to the HEP0001 - new decorators milestone May 7, 2024
@elliotgunton elliotgunton force-pushed the new-dag-decorator branch 2 times, most recently from 6b521e2 to c6a00ca Compare May 8, 2024 15:15
@elliotgunton elliotgunton changed the base branch from main to refactor-runner-io May 8, 2024 15:15
Base automatically changed from refactor-runner-io to main May 8, 2024 16:44
samj1912 pushed a commit that referenced this pull request May 8, 2024
* Use a new pair of mixin classes to hold the functions that are
compatible with Pydantic V1 and V2, meaning we no longer need to
maintain two sets of classes for each Pydantic version
* "RunnerIO" classes to be renamed to `Input` and `Output`, keeping the
old name as an alias for one release so we can announce the change

This PR splits out parts of commits from
#1059 that only refactored
RunnerIO

---------

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
src/hera/workflows/_meta_mixins.py Outdated Show resolved Hide resolved
src/hera/workflows/_meta_mixins.py Outdated Show resolved Hide resolved
@elliotgunton
Copy link
Collaborator Author

I want to add an inner-dag example with associated code fix in def dag_call_wrapper and then PR will be ready for review. The current code shouldn't change though if you want to take a look @samj1912 @flaviuvadan

@elliotgunton elliotgunton marked this pull request as ready for review May 10, 2024 16:34
@elliotgunton elliotgunton force-pushed the new-dag-decorator branch 6 times, most recently from f160b78 to 4b4e283 Compare May 13, 2024 15:27
pyproject.toml Outdated Show resolved Hide resolved
@elliotgunton elliotgunton force-pushed the new-dag-decorator branch 2 times, most recently from cd51680 to 6a2ca54 Compare May 14, 2024 10:48
* Within the decorator function call we perform a static inspection of
inputs and outputs, add a `DAG` object to the Workflow, and finally
do a "run" of the DAG function code using a templated input to collect the tasks
* Tasks that pass arguments simply take the templated input strings and pass them
around
* The dependencies between tasks are inferred automatically via __getattr__ calls
on the Task object
* Add varname as a dependency to be able to get the python variable name to use
as the task name (in the YAML)
* Make the _add_type_hints function work for *any* pydantic class

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Use a global declaring attribute on the _HeraContext
* Avoid recursion in __getattribute__ by using object.__getattribute__, and
not flipping the declaring value

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* `__init__` seemingly wasn't being called correctly in the V1 tests,
but this is because of the MRO going through the regular `BaseModel`
first and failing validation
* This changes v1.py to match v2.py

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Makes dags callable within dag-decorated functions

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Do not return super __init__
* Remove extra function metadata
* make init-files to fix __all__
* Fix example missing required param
* Fix create_subnode and regenerate examples

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Update github cicd

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Also add a BaseModel field to example

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* To protect usage of new decorator_syntax
* We should roll the multiple flags required (script_annotations,
script_pydantic_io and decorator_syntax) into levels, so that
script_annotations < script_pydantic_io < decorator_syntax, i.e.
you only need to set one flag to also use the experimental feature
required below it.

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
@elliotgunton elliotgunton force-pushed the new-dag-decorator branch 2 times, most recently from 5b01fb8 to 72d6534 Compare May 15, 2024 13:37
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
@samj1912 samj1912 merged commit 8004d4f into main May 15, 2024
20 checks passed
@samj1912 samj1912 deleted the new-dag-decorator branch May 15, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HEP0001 - new DAG decorator
2 participants