Skip to content

Commit

Permalink
Merge pull request #443 from Avaiga/feature/#450-get-entities-by-conf…
Browse files Browse the repository at this point in the history
…ig-id

feature/#450 added doc for get_entities_by_config_id
  • Loading branch information
toan-quach committed May 16, 2023
2 parents e0def58 + f340684 commit f4592eb
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 14 deletions.
23 changes: 22 additions & 1 deletion docs/manuals/core/entities/data-node-mgt.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ passing the data node id as parameter:
# data_node == data_node_retrieved
```

The data nodes that are part of a **scenario**, **pipeline** or **task** can be directly accessed as attributes:
# Get data nodes by config_id

The data nodes that are part of a **scenario**, **pipeline** or **task** can be directly accessed as attributes by
using their config_id:

!!! Example

Expand All @@ -70,6 +73,24 @@ The data nodes that are part of a **scenario**, **pipeline** or **task** can be
task.sales_history
```

Data nodes can be retrieved by using `taipy.get_entities_by_config_id()^` providing the config_id.
This method returns the list of all existing data nodes instantiated from the config_id provided as a parameter.

!!! Example

```python linenums="1"
import taipy as tp
import my_config

# Create 2 scenarios, which will also create 2 trained_model data nodes.
scenario_1 = tp.create_scenario(my_config.monthly_scenario_cfg)
scenario_2 = tp.create_scenario(my_config.monthly_scenario_cfg)

# Get all data nodes by config_id, this will return a list of 2 trained_model data nodes
# created alongside the 2 scenarios.
all_trained_model_dns = tp.get_entities_by_config_id("trained_model")
```

# Get all data nodes

All data nodes that are part of a **scenario** or a **pipeline** can be directly accessed as attributes:
Expand Down
38 changes: 29 additions & 9 deletions docs/manuals/core/entities/pipeline-mgt.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,40 @@ pipeline == pipeline_retrieved

Here the two variables `pipeline` and `pipeline_retrieved` are equal.

# Get pipeline by config id
# Get pipelines by config id

A pipeline can also be retrieved from a scenario by accessing the pipeline's config_id of the scenario.

```python linenums="1"
import taipy as tp
import my_config
!!! Example

scenario = tp.create_scenario(my_config.monthly_scenario_cfg)
```python linenums="1"
import taipy as tp
import my_config

# Get the pipelines by config id
sales_pipeline = scenario.sales
production_pipeline = scenario.production
```
scenario = tp.create_scenario(my_config.monthly_scenario_cfg)

# Get the pipelines by config id
sales_pipeline = scenario.sales
production_pipeline = scenario.production
```

Pipelines can also be retrieved using `taipy.get_entities_by_config_id()^` providing the config_id.
This method returns the list of all existing pipelines instantiated from the config_id provided as a parameter.

!!! Example

```python linenums="1"
import taipy as tp
import my_config

# Create 2 scenarios, which will also create 2 sales pipelines.
scenario_1 = tp.create_scenario(my_config.monthly_scenario_cfg)
scenario_2 = tp.create_scenario(my_config.monthly_scenario_cfg)

# Get all sale pipelines by config id, this will return a list of 2 sales pipelines
# created alongside the 2 scenarios.
all_sales_pipeline = tp.get_entities_by_config_id("sales")
```

# Get all pipelines

Expand Down
19 changes: 19 additions & 0 deletions docs/manuals/core/entities/scenario-cycle-mgt.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ scenario == scenario_retrieved

Here, the two variables `scenario` and `scenario_retrieved` are equal.

# Get scenarios by config id

Scenarios can also be retrieved using `taipy.get_entities_by_config_id()^` providing the config_id.
This method returns the list of all existing scenarios instantiated from the config_id provided as a parameter.

!!! Example

```python linenums="1"
import taipy as tp
import my_config

# Create 2 scenarios.
scenario_1 = tp.create_scenario(my_config.monthly_scenario_cfg)
scenario_2 = tp.create_scenario(my_config.monthly_scenario_cfg)

# Get all monthly scenarios by config id, this will return a list of 2 scenarios just created.
all_monthly_scenarios = tp.get_entities_by_config_id("scenario_configuration")
```

# Get all scenarios

All the scenarios can be retrieved using the method `taipy.get_scenarios()^`. This method returns the list of all
Expand Down
28 changes: 24 additions & 4 deletions docs/manuals/core/entities/task-mgt.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,36 @@ task_retrieved = tp.get(task.id)

Here, the two variables `task` and `task_retrieved` are equal.

A task can also be retrieved from a scenario or a pipeline, by accessing the task config_id attribute.
All the jobs can be retrieved using the method `taipy.get_tasks()^`.

# Get tasks by config id

A task can be retrieved from a scenario or a pipeline, by accessing the task config_id attribute.

```python linenums="1"
task_1 = scenario.predicting
task_1 = scenario.predicting # "predicting" is the config_id of the predicting Task in the scenario
pipeline = scenario.sales
task_2 - pipeline.predicting
task_2 = pipeline.predicting # "predicting" is the config_id of the predicting Task in the pipeline
# task_1 == task_2
```

All the jobs can be retrieved using the method `taipy.get_tasks()^`.
Tasks can also be retrieved using `taipy.get_entities_by_config_id()^` providing the config_id.
This method returns the list of all existing tasks instantiated from the config_id provided as a parameter.

!!! Example

```python linenums="1"
import taipy as tp
import my_config

# Create 2 scenarios, which will also create 2 trainig tasks.
scenario_1 = tp.create_scenario(my_config.monthly_scenario_cfg)
scenario_2 = tp.create_scenario(my_config.monthly_scenario_cfg)

# Get all training tasks by config id, this will return a list of 2 training tasks
# created alongside the 2 scenarios.
all_training_tasks = tp.get_entities_by_config_id("training")
```

# Get parent scenarios and pipelines

Expand Down
2 changes: 2 additions & 0 deletions docs/relnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Not published yet.
- All scenarios grouped by their cycles can be now retrieved by calling `taipy.get_cycles_scenarios()^`.
- All entities (cycles, scenarios, pipelines, tasks, data nodes, and jobs) expose two new methods: `get_label` and
`get_simple_label`, that can be used to display the entity.
- `taipy.get_entities_by_config_id()^` can be used to retrieve all entities that are based on
the provided configuration identifier.

## Community edition: 2.2

Expand Down

0 comments on commit f4592eb

Please sign in to comment.