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

WorkflowTemplate/ClusterWorkflowTemplate create_as_workflow #669

Merged
merged 12 commits into from
Jun 14, 2023

Conversation

elliotgunton
Copy link
Collaborator

Pull Request Checklist

Description of PR
Currently, the DevEx for a workflow template is either:

  • you have to iterate on a Workflow until it's ready to submit as a WorkflowTemplate; or
  • you submit a WorkflowTemplate to the cluster, and run it via workflowTemplateRef, templateRef or via CLI submit --from

This PR adds

  • the create_as_workflow function (reflecting existing naming in the Workflow class rather than run_as)
    • this modifies the kind in place, then submits to Argo through Workflow.create
    • we pass through wait and poll_interval (was hesitant to just use kwargs)
  • ClusterWorkflowTemplate as a subclass of WorkflowTemplate as it was missing, added to TWorkflow type
    • acts as a fairly light wrapper around WorkflowTemplate, as we need to call the right WorkflowService functions
    • build just converts the pydantic model to ClusterWorkflowTemplate.

@elliotgunton elliotgunton added type:enhancement A general enhancement semver:minor A change requiring a minor version bump labels Jun 5, 2023
@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Merging #669 (1bb292c) into main (948643e) will increase coverage by 1.6%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##            main    #669     +/-   ##
=======================================
+ Coverage   74.5%   76.1%   +1.6%     
=======================================
  Files         44      45      +1     
  Lines       3030    3088     +58     
  Branches     577     584      +7     
=======================================
+ Hits        2259    2352     +93     
+ Misses       597     566     -31     
+ Partials     174     170      -4     
Impacted Files Coverage Δ
src/hera/workflows/protocol.py 80.9% <ø> (ø)
src/hera/workflows/cluster_workflow_template.py 100.0% <100.0%> (ø)
src/hera/workflows/workflow.py 81.5% <100.0%> (+6.9%) ⬆️
src/hera/workflows/workflow_template.py 100.0% <100.0%> (+53.6%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

tests/test_hooks.py Outdated Show resolved Hide resolved
@elliotgunton elliotgunton mentioned this pull request Jun 5, 2023
elliotgunton added a commit that referenced this pull request Jun 6, 2023
While working on top of #669, thought we could work towards better
testing and because the patch coverage was so low I figured it would
help. Separate PR to highlight changes but will merge down
* Adds mocker `dev` dependency
* Create test_unit folder, added `Workflow.create` test to demonstrate
ideal usage
* Add `cov-report=term-missing` to pytest `make test` target to
encourage us to improve coverage - this will report a table back to us
in terminal of coverage and missing lines

---------

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
elliotgunton added a commit that referenced this pull request Jun 6, 2023
While working on top of #669, thought we could work towards better
testing and because the patch coverage was so low I figured it would
help. Separate PR to highlight changes but will merge down
* Adds mocker `dev` dependency
* Create test_unit folder, added `Workflow.create` test to demonstrate
ideal usage
* Add `cov-report=term-missing` to pytest `make test` target to
encourage us to improve coverage - this will report a table back to us
in terminal of coverage and missing lines

---------

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
@elliotgunton elliotgunton force-pushed the create-as-workflow branch 4 times, most recently from b6bbc0f to 87465ce Compare June 6, 2023 16:55
Copy link
Collaborator

@flaviuvadan flaviuvadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @elliotgunton 🎖️ I left a question re: interfacing with the generated name option. Will approve after the discussion/potential change

@elliotgunton elliotgunton force-pushed the create-as-workflow branch 3 times, most recently from 91323ec to 41af9fe Compare June 9, 2023 09:46
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
While working on top of #669, thought we could work towards better
testing and because the patch coverage was so low I figured it would
help. Separate PR to highlight changes but will merge down
* Adds mocker `dev` dependency
* Create test_unit folder, added `Workflow.create` test to demonstrate
ideal usage
* Add `cov-report=term-missing` to pytest `make test` target to
encourage us to improve coverage - this will report a table back to us
in terminal of coverage and missing lines

---------

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
* Remove pytest-mock usage (use unittest.mock)

Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
Copy link
Collaborator

@flaviuvadan flaviuvadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@elliotgunton elliotgunton merged commit 820c573 into main Jun 14, 2023
@elliotgunton elliotgunton deleted the create-as-workflow branch June 14, 2023 00:04
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.

Add run_as_workflow method
2 participants