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

Feat/improve docs #83

Merged
merged 3 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/concepts/copying-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,61 @@

# Copying Task

While building your workflow, you might notice that some of your tasks resemble each other in many ways.

Zrb allows you to copy a Task and modify a limited set of attributes.

The following are the most commonly used methods when you copy a Task:

- `copy(self)`
- `set_name(self, new_name: str)`
- `set_description(self, new_description: str)`
- `set_icon(self, new_icon: str)`
- `set_color(self, new_color: str)`
- `set_should_execute(self, should_execute: str)`
- `set_retry(self, new_retry: int)`
- `set_retry_interval(self, new_retry_interval: int)`
- `set_checking_interval(self, new_checking_retry_interval: int)`
- `insert_checker(self, *checkers: AnyTask)`
- `add_checker(self, *checkers: AnyTask)`
- `insert_upstream(self, *upstreams: AnyTask)`
- `add_upstream(self, *upstreams: AnyTask)`
- `insert_input(self, *inputs: AnyInput)`
- `add_input(self, *inputs: AnyInput)`
- `insert_env(self, *envs: Env)`
- `add_env(self, *envs: Env)`
- `insert_env_file(self, *env_files: EnvFile)`
- `add_env_file(self, *env_files: EnvFile)`

Let's see the following example:

```python
from zrb import runner, CmdTask, BoolInput

dbt_run = CmdTask(
name='dbt-run',
cmd='dbt run'
)

# Copying dbt run, make it skippable
skippable_dbt_run = dbt_run.copy()
skippable_dbt_run.add_input(BoolInput(name='dbt-run', default=True))
skippable_dbt_run.set_should_execute('{{ input.dbt_run }}')

# register dbt-run
runner.register(dbt_run)

# Make dbt-test depends on skippable dbt run
dbt_test = CmdTask(
name='dbt-test',
cmd='dbt test',
upstreams=[skippable_dbt_run]
)

```

# Next

For more flexibility, you can extend [Task](extending-task.md) and [CmdTask](extending-cmd-task.md)

🔖 [Table of Contents](../README.md) / [Concepts](README.md)
Loading