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

Update Job executions #651

Merged
merged 5 commits into from
Oct 12, 2023
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
jrobinAV marked this conversation as resolved.
Show resolved Hide resolved
FlorianJacta marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
> You can download the code for
<a href="./../src/step_07.py" download>Step 7</a>
or all the steps <a href="./../src/src.zip" download>here</a>.
> You can download the code
<a href="/job_execution.py" download>here</a>. Here is the
<a href="/job_execution_toml.py" download>Python version</a>
with the
<a href="/config.toml" download>TOML file</a>
.

# Executing jobs

Expand All @@ -13,7 +16,7 @@ Changing the execution mode can be useful for running multiple tasks in parallel

- _development_ mode: synchronous. The default execution mode is _development_.

In this step, we define a new configuration and functions to showcase the two execution modes.
We define a configuration and functions to showcase the two execution modes.

```python
# Normal function used by Taipy
Expand All @@ -26,7 +29,7 @@ def add(nb):
return nb + 10
```

![](config_07.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" }
![Configuration](config.svg){ width=700 style="margin:auto;display:block;border: 4px solid rgb(210,210,210);border-radius:7px" }

This line of code alters the execution mode. Setting it to _standalone_ makes Taipy Core work asynchronously.
In this configuration, a maximum of two tasks can run simultaneously.
Expand Down Expand Up @@ -64,7 +67,7 @@ if __name__=="__main__":
scenario_1.submit(wait=True, timeout=5)
```

## Entire code
# Entire code


```python
Expand Down Expand Up @@ -92,20 +95,21 @@ output_cfg = Config.configure_data_node("output")

# Configuration of tasks
first_task_cfg = Config.configure_task("double",
double,
input_cfg,
intermediate_cfg)
double,
input_cfg,
intermediate_cfg)

second_task_cfg = Config.configure_task("add",
add,
intermediate_cfg,
output_cfg)
add,
intermediate_cfg,
output_cfg)

# Configuration of the pipeline and scenario
scenario_cfg = Config.configure_scenario(id="my_scenario",
task_configs=[first_task_cfg,
second_task_cfg])
task_configs=[first_task_cfg,
second_task_cfg])

Config.export("config_07.toml")

FlorianJacta marked this conversation as resolved.
Show resolved Hide resolved
if __name__=="__main__":
tp.Core().run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def add(nb):

# Configuration of the pipeline and scenario
scenario_cfg = Config.configure_scenario(id="my_scenario",
task_configs=[first_task_cfg,
second_task_cfg])
task_configs=[first_task_cfg,
second_task_cfg])

Config.export("config_07.toml")
Config.export("config.toml")

if __name__=="__main__":
tp.Core().run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def add(nb):
return nb + 10


Config.load('config_07.toml')
Config.load('config.toml')
Config.configure_job_executions(mode="standalone", max_nb_of_workers=2)


Expand Down
Loading