Skip to content

Commit

Permalink
Restructure examples for website (#884)
Browse files Browse the repository at this point in the history
**Pull Request Checklist**
- [x] Fixes #883 
- [x] Tests ~added~ updated
- [x] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Currently, all our `.py` examples are dumped into the
`examples/workflows` folder, or the `examples/workflows/upstream`
folder, making it very difficult to surface features and exemplify
usage. This PR enables any kind of recursive directory structure in
`/examples/workflows`, which will have the yaml generated by
`test_examples.py`. The `generate.py` script has also been updated to
copy over the arbitrary structure. The `mkdocs.yml` file is still
manipulated by hand, so you should add the examples in the order you
want there. Also NB, you need to add an `__init__.py` file for each
folder in `examples/workflows` so it can be detected as a module.

At the moment, I've added these folders in `examples/workflows`:
- artifacts
- dags
- experimental
- loops
- scripts
- steps
- upstream
- use-cases

And labelled the rest of the examples as ~`Unsorted`~ `Miscellaneous` in
the readthedocs site.

* Also renamed branch references as argo upstream moved to a `main`
branch, which broke the API fetch.

---------

Signed-off-by: Elliot Gunton <[email protected]>
  • Loading branch information
elliotgunton authored Dec 5, 2023
1 parent 9aad50b commit ec7e5ed
Show file tree
Hide file tree
Showing 270 changed files with 330 additions and 469 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ In order to add a new workflow test to test Hera functionality, do the following

### Upstream Hera examples

Tests that correspond to any [upstream Argo Workflow examples](https://github.com/argoproj/argo-workflows/tree/master/examples) should live in `examples/workflows/upstream/*.py`. These tests exist to ensure that Hera has complete parity with Argo Workflows and also to catch any regressions that might happen.
Tests that correspond to any [upstream Argo Workflow examples](https://github.com/argoproj/argo-workflows/tree/main/examples) should live in `examples/workflows/upstream/*.py`. These tests exist to ensure that Hera has complete parity with Argo Workflows and also to catch any regressions that might happen.

In order to add a new workflow test to test Hera functionality, do the following -

* Create a new file under `examples/workflows/upstream` that corresponds with the name of the upstream example yaml
file. If the yaml file has a hyphen, your python file name should replace those with an underscore. eg. if you are
trying to replicate
[archive-location.yaml](https://github.com/argoproj/argo-workflows/blob/master/examples/archive-location.yaml) your
[archive-location.yaml](https://github.com/argoproj/argo-workflows/blob/main/examples/archive-location.yaml) your
python file should be called `archive_location.py`
* Define your new workflow. Make sure that the target workflow you wish to export and test against is named `w`
* Run tests using `make test`. Hera tests will generate a golden copy of the output YAML with the name
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ init-files:
$(MAKE) format

.PHONY: examples
examples: ## Generate all the examples
examples: ## Generate documentation files for examples
@(cd docs && poetry run python generate.py)

.PHONY: regenerate-test-data
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ of course).

Since Hera Workflows is built for Argo Workflows, this section offers the Argo Workflows security docs:

- see [docs/security.md](https://github.com/argoproj/argo-workflows/blob/master/docs/security.md) for information about
- see [docs/security.md](https://github.com/argoproj/argo-workflows/blob/main/docs/security.md) for information about
securing your Argo Workflows instance
6 changes: 6 additions & 0 deletions docs/examples/about-upstream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Upstream Examples

The "Upstream" collection contains examples
[directly from the Argo Workflows repository](https://github.com/argoproj/argo-workflows/tree/6e97c7d/examples), such as
the [DAG Diamond example](dag_diamond.md), to demonstrate how the YAML spec maps to Hera classes. These examples are
generated and compared in Hera's CI/CD pipeline to ensure that all the examples are possible to recreate in Hera.
4 changes: 4 additions & 0 deletions docs/examples/about-use-cases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use-Cases and Integrations Examples

These examples show how to use third-party technologies in your Workflows, along with use-cases to show more in-depth
uses of Hera.
178 changes: 89 additions & 89 deletions docs/examples/workflows-examples.md

Large diffs are not rendered by default.

File renamed without changes.
104 changes: 0 additions & 104 deletions docs/examples/workflows/callable_coinflip.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/examples/workflows/complex_expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This example showcases how to string together complex expressions.
This example is a python replica of
https://github.com/argoproj/argo-workflows/blob/master/examples/expression-reusing-verbose-snippets.yaml
https://github.com/argoproj/argo-workflows/blob/main/examples/expression-reusing-verbose-snippets.yaml


=== "Hera"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_dag_with_param_get:hello_with_output
- examples.workflows.dags.callable_dag_with_param_get:hello_with_output
command:
- python
image: python:3.8
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_custom_volume:output_artifact_empty_dir
- examples.workflows.experimental.script_annotations_artifact_custom_volume:output_artifact_empty_dir
command:
- python
env:
Expand All @@ -166,7 +166,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_custom_volume:use_artifact
- examples.workflows.experimental.script_annotations_artifact_custom_volume:use_artifact
command:
- python
env:
Expand All @@ -187,7 +187,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_custom_volume:output_artifact_existing_vol
- examples.workflows.experimental.script_annotations_artifact_custom_volume:output_artifact_existing_vol
command:
- python
env:
Expand All @@ -210,7 +210,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_custom_volume:use_artifact_existing_vol
- examples.workflows.experimental.script_annotations_artifact_custom_volume:use_artifact_existing_vol
command:
- python
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_loaders:output_dict_artifact
- examples.workflows.experimental.script_annotations_artifact_loaders:output_dict_artifact
command:
- python
env:
Expand All @@ -120,7 +120,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_loaders:artifact_loaders
- examples.workflows.experimental.script_annotations_artifact_loaders:artifact_loaders
command:
- python
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_outputs_defaults:output_artifact
- examples.workflows.experimental.script_annotations_artifact_outputs_defaults:output_artifact
command:
- python
env:
Expand All @@ -117,7 +117,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_outputs_defaults:use_artifact
- examples.workflows.experimental.script_annotations_artifact_outputs_defaults:use_artifact
command:
- python
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_passing:output_artifact
- examples.workflows.experimental.script_annotations_artifact_passing:output_artifact
command:
- python
env:
Expand All @@ -113,7 +113,7 @@ This example will reuse the outputs volume across script steps.
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_artifact_passing:use_artifact
- examples.workflows.experimental.script_annotations_artifact_passing:use_artifact
command:
- python
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_inputs:output_dict_artifact
- examples.workflows.experimental.script_annotations_inputs:output_dict_artifact
command:
- python
env:
Expand Down Expand Up @@ -137,7 +137,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_inputs:echo_all
- examples.workflows.experimental.script_annotations_inputs:echo_all
command:
- python
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.script_annotations_outputs:script_param_artifact_in_function_signature_and_return_type
- examples.workflows.experimental.script_annotations_outputs:script_param_artifact_in_function_signature_and_return_type
command:
- python
env:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_script:my_function
- examples.workflows.scripts.callable_script:my_function
command:
- python
env:
Expand All @@ -174,7 +174,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_script:str_function
- examples.workflows.scripts.callable_script:str_function
command:
- python
env:
Expand All @@ -191,7 +191,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_script:another_function
- examples.workflows.scripts.callable_script:another_function
command:
- python
env:
Expand All @@ -213,7 +213,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_script:function_kebab
- examples.workflows.scripts.callable_script:function_kebab
command:
- python
env:
Expand All @@ -230,7 +230,7 @@
- -m
- hera.workflows.runner
- -e
- examples.workflows.callable_script:function_kebab_object
- examples.workflows.scripts.callable_script:function_kebab_object
command:
- python
env:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/archive_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/archive-location.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/archive-location.yaml).



Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/arguments_artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/arguments-artifacts.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/arguments-artifacts.yaml).



Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/arguments_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/arguments-parameters.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/arguments-parameters.yaml).



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/arguments-parameters-from-configmap.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/arguments-parameters-from-configmap.yaml).



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/artifact-disable-archive.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/artifact-disable-archive.yaml).



Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/artifact_gc_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/artifact-gc-workflow.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/artifact-gc-workflow.yaml).



Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/artifact_passing.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/artifact-passing.yaml).
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/artifact-passing.yaml).



Expand Down
Loading

0 comments on commit ec7e5ed

Please sign in to comment.