Skip to content

Commit

Permalink
bug fix on recurringTask
Browse files Browse the repository at this point in the history
  • Loading branch information
goFrendiAsgard committed Dec 14, 2023
1 parent 3f04933 commit 5e64829
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
29 changes: 26 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,39 @@ Anytime you start working on your project, you should load `project.sh`.

Tasks are your most negligible unit of job definition.

Zrb has multiple task types, including `CmdTask`, `python_task`, `DockerComposeTask`, `RecurringTask`, `ResourceMaker`, etc.
Zrb has multiple Task Types, including `CmdTask`, `python_task`, `DockerComposeTask`, `RecurringTask`, `ResourceMaker`, etc.

Typically, a Zrb Task has multiple properties:
Typically, a Zrb Task has multiple settings:

- Retry mechanism
- Task Upstreams
- Task Environment and Environment File
- Task Input/Parameter
- Readiness Checker

In this Getting-Started tutorial, we will only cover a few Task Types.

## Use Case

Let's start with a use case:

- We want to serve a single HTML file
- The HTML file contains some information from environment variables and user inputs.
- Zrb should generate the HTML file based on a single HTML template.
- Whenever the HTML template is modified, Zrb should re-generate the HTML file.

We can break down the requirements into some tasks.

```
🥬 🧑‍🍳 🥗
Prepare Resources ────► Monitor and Rebuild ────► Serve
```

## Implementation




In this Getting-Started tutorial, we will only focus on `CmdTask` and `python_task`. So, let's focus on these two.

---

Expand Down
4 changes: 2 additions & 2 deletions src/zrb/builtin/say.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import datetime
import random

_MIN_WIDTH = 50
_MIN_WIDTH = 10
_MOTIVATIONAL_QUOTES = [
[
'The best time to plant a tree was 20 years ago.',
Expand Down Expand Up @@ -90,7 +90,7 @@
runner=runner
)
def say(*args: Any, **kwargs: Any):
width: int = kwargs.get('width', 50)
width: int = kwargs.get('width', 80)
if width < _MIN_WIDTH:
width = _MIN_WIDTH
text: str = kwargs.get('text', '')
Expand Down
9 changes: 5 additions & 4 deletions src/zrb/task/recurring_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from zrb.task.any_task_event_handler import (
OnTriggered, OnWaiting, OnSkipped, OnStarted, OnReady, OnRetry, OnFailed
)
from zrb.task.task import Task
from zrb.task_env.env import Env
from zrb.task_env.env_file import EnvFile
from zrb.task_group.group import Group
Expand Down Expand Up @@ -47,9 +48,10 @@ def __init__(
should_execute: Union[bool, str, Callable[..., bool]] = True,
return_upstream_result: bool = False
):
inputs = list(inputs) + task._get_combined_inputs()
envs = list(envs) + task._get_envs()
env_files = list(env_files) + task._get_env_files()
self._task: AnyTask = task.copy()
inputs = list(inputs) + self._task._get_combined_inputs()
envs = list(envs) + self._task._get_envs()
env_files = list(env_files) + self._task._get_env_files()
BaseTask.__init__(
self,
name=name,
Expand All @@ -75,7 +77,6 @@ def __init__(
should_execute=should_execute,
return_upstream_result=return_upstream_result,
)
self._task: AnyTask = task.copy()
self._triggers: List[AnyTask] = [
trigger.copy() for trigger in triggers
]
Expand Down

0 comments on commit 5e64829

Please sign in to comment.