Skip to content

Commit

Permalink
Merge pull request #151 from AstraZeneca/improved_docs
Browse files Browse the repository at this point in the history
docs: working on it
  • Loading branch information
vijayvammi authored May 15, 2024
2 parents c66d170 + e65794b commit 6f184e3
Show file tree
Hide file tree
Showing 34 changed files with 337 additions and 2,818 deletions.
4 changes: 3 additions & 1 deletion docs/concepts/catalog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[tasks](task.md) might also need to pass ```files``` between them.

## Concept

For example:

```python linenums="1"
Expand All @@ -20,7 +22,7 @@ consume()
```


## Runnable representation
## Syntax

The same can be represented in ```runnable``` as [catalog](../reference.md/#catalog).

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pipeline.execute()
```


- ```runnable``` exposes the functions ```generate``` and ```consume``` as [tasks](task.md).
- ```runnable``` wraps the functions ```generate``` and ```consume``` as [tasks](task.md).
- Tasks can [access and return](parameters.md/#access_returns) parameters.
- Tasks can also share files between them using [catalog](catalog.md).
- Tasks are stitched together as [pipeline](pipeline.md)
Expand Down
939 changes: 158 additions & 781 deletions docs/concepts/map.md

Large diffs are not rendered by default.

620 changes: 88 additions & 532 deletions docs/concepts/parallel.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/concepts/parameters.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
```parameters``` are data that can be passed from one ```task``` to another.

## Concept

For example, in the below snippet, the parameters ```x``` and ```y``` are passed from
```generate``` to ```consume```.

Expand Down
23 changes: 14 additions & 9 deletions docs/concepts/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A ```workflow``` is a sequence of ```steps``` to perform.

<br>

## Concept

A visual example of a workflow:

Expand Down Expand Up @@ -57,20 +58,28 @@ and [stub](task.md/#stub).

=== "sdk"

- [x] The first step of the ```steps``` is the start of the workflow.
- [x] The order of execution follows the order of the tasks in the list.
- [x] The terminal nodes ```success``` and ```fail``` are added automatically.

```python linenums="1"
--8<-- "examples/02-sequential/traversal.py"
```

1. Start the pipeline.
2. The order of the steps is the execution order

- [x] The first step of the ```steps``` is the start of the workflow.
- [x] The order of execution follows the order of the tasks in the list.
- [x] The terminal nodes ```success``` and ```fail``` are added automatically.




=== "yaml"

- [x] The first step is the step corresponding to ```start_at```
- [x] The mapping defined in the steps.
- [x] The ```next``` step after a successful execution of a ```step```.
- [x] ```success``` as ```next``` node implies successful execution of the pipeline.

```yaml linenums="1"
--8<-- "examples/02-sequential/traversal.yaml"
```
Expand All @@ -80,10 +89,7 @@ and [stub](task.md/#stub).
3. Add the success and fail nodes.


- [x] The first step is the step corresponding to ```start_at```
- [x] The mapping defined in the steps.
- [x] The ```next``` step after a successful execution of a ```step```.
- [x] Needs explicit definition of ```success``` and ```fail``` nodes.


<br>

Expand All @@ -93,8 +99,7 @@ and [stub](task.md/#stub).
By default, any failure during the execution of step will traverse to ```fail``` node
marking the execution as failed.

The ```fail``` node is implicitly added to the pipeline in python SDK while it
has to be stated in the yaml.
The ```fail``` node is implicitly added to the pipeline.


This behavior can be over-ridden to follow a different path based on expected failures.
Expand Down
4 changes: 3 additions & 1 deletion docs/concepts/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ the python function/notebook/shell script/stubs.

## Python functions

Uses python functions as tasks.

[API Documentation](../reference.md/#pythontask)

### Example
Expand Down Expand Up @@ -106,7 +108,7 @@ ecosystem while shell provides a interface to non-python executables.

=== "yaml"

```yaml linenums="1" hl_lines="19-23"
```yaml linenums="1" hl_lines="16-23"
--8<-- "examples/01-tasks/scripts.yaml"
```

Expand Down
74 changes: 61 additions & 13 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,88 @@
## Catalog
## PythonTask

=== "sdk"

::: runnable.Catalog
::: runnable.PythonTask
options:
show_root_heading: true
show_bases: false
show_docstring_description: true
heading_level: 3

=== "yaml"


Attributes:

- ```name```: the name of the task
- ```command```: the dotted path reference to the function.
- ```next```: the next node to call if the function succeeds. Use ```success``` to terminate
the pipeline successfully or ```fail``` to terminate with fail.
- ```on_failure```: The next node in case of failure.
- ```catalog```: mapping of cataloging items
- ```overrides```: mapping of step overrides from global configuration.

```yaml
dag:
steps:
name: <>
type: task
command: <>
next: <>
on_failure: <>
catalog: # Any cataloging to be done.
overrides: # mapping of overrides of global configuration
```

<hr style="border:2px dotted orange">

## Stub

## NotebookTask

=== "sdk"

::: runnable.Stub
::: runnable.NotebookTask
options:
show_root_heading: true
show_bases: false
show_docstring_description: true
heading_level: 3

=== "yaml"

Attributes:

- ```name```: the name of the task
- ```command```: the path to the notebook relative to the project root.
- ```next```: the next node to call if the function succeeds. Use ```success``` to terminate
the pipeline successfully or ```fail``` to terminate with fail.
- ```on_failure```: The next node in case of failure.
- ```catalog```: mapping of cataloging items
- ```overrides```: mapping of step overrides from global configuration.

```yaml
dag:
steps:
name: <>
type: task
command: <>
next: <>
on_failure: <>
catalog: # Any cataloging to be done.
overrides: # mapping of overrides of global configuration
```


<hr style="border:2px dotted orange">

## PythonTask

## Catalog

=== "sdk"

::: runnable.PythonTask
::: runnable.Catalog
options:
show_root_heading: true
show_bases: false
show_docstring_description: true
heading_level: 3

=== "yaml"
Expand All @@ -47,15 +91,14 @@

<hr style="border:2px dotted orange">

## ShellTask
## Stub

=== "sdk"

::: runnable.ShellTask
::: runnable.Stub
options:
show_root_heading: true
show_bases: false
show_docstring_description: true
heading_level: 3

=== "yaml"
Expand All @@ -65,11 +108,12 @@
<hr style="border:2px dotted orange">


## NotebookTask

## ShellTask

=== "sdk"

::: runnable.NotebookTask
::: runnable.ShellTask
options:
show_root_heading: true
show_bases: false
Expand All @@ -79,8 +123,12 @@
=== "yaml"



<hr style="border:2px dotted orange">




## Parallel


Expand Down
8 changes: 0 additions & 8 deletions docs/yaml.md

This file was deleted.

7 changes: 2 additions & 5 deletions examples/06-parallel/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from runnable import NotebookTask, Parallel, Pipeline, PythonTask, ShellTask, Stub


def traversal(execute: bool = True):
def traversal():
"""
Use the pattern of using "execute" to control the execution of the pipeline.
Expand Down Expand Up @@ -46,17 +46,14 @@ def traversal(execute: bool = True):
# The order of execution follows the order of the tasks in the list.
pipeline = Pipeline(steps=[stub_task, python_task, shell_task, notebook_task])

if execute: # Do not execute the pipeline if we are using it as a branch
pipeline.execute()

return pipeline


def main():
parallel_step = Parallel(
name="parallel_step",
terminate_with_success=True,
branches={"branch1": traversal(execute=False), "branch2": traversal(execute=False)},
branches={"branch1": traversal(), "branch2": traversal()},
)

pipeline = Pipeline(steps=[parallel_step])
Expand Down
87 changes: 0 additions & 87 deletions examples/concepts/catalog.py

This file was deleted.

Loading

0 comments on commit 6f184e3

Please sign in to comment.