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

Enable Pydantic I/O types in workflow context #1189

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Commits on Oct 9, 2024

  1. Factor out common _SCRIPT_PYDANTIC_IO_FLAG check

    Code to check if _SCRIPT_PYDANTIC_IO_FLAG is set and error if not occurs
    twice; factor out into a shared utility function.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    0dd8bcd View commit details
    Browse the repository at this point in the history
  2. Stop disabling declaring in _create_subnode

    _create_subnode temporarily disables _context.declaring to avoid
    triggering the altered `__getattribute__` behaviour in
    TemplateInvocatorSubNodeMixin in two situations:
    
     - Pydantic's implementation of `!=`, which is attempting to read field
       values, and will raise a validation error due to the altered field
       names being of incorrect type.
     - Accessing `__class__` on a Pydantic subnode object with no build_obj
       set.
    
    Instead, fix this by:
    
     - Using `is not` instead of `!=`, which is correct where we use it,
       and also faster.
     - Fixing `__getattribute__` to no longer fail if used on an object with
       no build_obj set.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    e22caac View commit details
    Browse the repository at this point in the history
  3. Enable Pydantic I/O types in workflow context

    Extend experimental Pydantic I/O support to allow passing Pydantic types
    into `@script`-decorated functions when inside a `with` workflow context
    block, and using fields on the returned Pydantic output as shorthand for
    the associated Hera template in subsequent steps.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    f5b912e View commit details
    Browse the repository at this point in the history
  4. Add tests for the new Pydantic I/O syntax

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    74520a9 View commit details
    Browse the repository at this point in the history
  5. Clear current task dependencies in DAG._add_sub

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    8b394e4 View commit details
    Browse the repository at this point in the history
  6. Allow passing depends in a @w.dag context

    Currently, TemplateDecoratorFuncMixin._create_subnode unconditionally
    adds a depends kwarg, causing a runtime error if the user also supplies
    one. Instead, prefer the user-supplied one.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    082f1b8 View commit details
    Browse the repository at this point in the history
  7. Move Step/Task creation to Steps/Parallel/DAG

    Move the logic that creates the right leaf node for Steps, Parallel and
    DAG to a _create_leaf_node method on those types. DAG now specifies how
    to default the depends parameter to Task based on its
    _current_task_depends field. This simplifies the duplicated logic in
    _meta_mixins to a simple isinstance check for any of those three types,
    followed by a _create_leaf_node call.
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    48124bb View commit details
    Browse the repository at this point in the history
  8. Move new syntax behind decorator_syntax feature

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    9972d0c View commit details
    Browse the repository at this point in the history
  9. Fix name of experimental feature message function

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    bed0b59 View commit details
    Browse the repository at this point in the history
  10. Update new examples to Python 3.9 (logical merge conflict)

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    991edd7 View commit details
    Browse the repository at this point in the history
  11. Create a new experimental flag

    Add a new experimental flag to gate use of Pydantic types in a workflow context manager
    
    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    f0456d1 View commit details
    Browse the repository at this point in the history
  12. Document incremental migration option

    Signed-off-by: Alice Purcell <[email protected]>
    alicederyn committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    f263f56 View commit details
    Browse the repository at this point in the history