Skip to content

taipy.core.Scenario

Bases: _Entity

Instance of a Business case to solve.

A scenario holds a list of pipelines (instances of Pipeline class) to submit for execution in order to solve the Business case.

Attributes:

Name Type Description
config_id str

The identifier of the ScenarioConfig.

pipelines List[Pipeline]

The list of pipelines.

properties dict[str, Any]

A dictionary of additional properties.

scenario_id str

The unique identifier of this scenario.

creation_date datetime

The date and time of the scenario's creation.

is_primary bool

True if the scenario is the primary of its cycle. False otherwise.

cycle Cycle

The cycle of the scenario.

subscribers Set[Callable]

The set of callbacks to be called on Job's status change.

tags Set[str]

The list of scenario's tags.

add_tag(tag)

Add a tag to this scenario.

If the scenario's cycle already have another scenario tagged with tag the other scenario will be untagged.

Parameters:

Name Type Description Default
tag str

The tag to add to this scenario.

required

has_tag(tag)

Indicate if the scenario has a given tag.

Parameters:

Name Type Description Default
tag str

The tag to search among the set of scenario's tags.

required

Returns:

Name Type Description
bool bool

True if the scenario has the tag given as parameter. False otherwise.

remove_tag(tag)

Remove a tag from this scenario.

Parameters:

Name Type Description Default
tag str

The tag to remove from the set of the scenario's tags.

required

set_primary()

Promote the scenario as the primary scenario of its cycle.

If the cycle already has a primary scenario, it will be demoted, and it will no longer be primary for the cycle.

submit(force=False, wait=False, timeout=None)

Submit this scenario for execution.

All the Tasks of the scenario will be submitted for execution.

Parameters:

Name Type Description Default
force bool

Force execution even if the data nodes are in cache.

False
wait bool

Wait for the scheduled jobs created from the scenario submission to be finished in asynchronous mode.

False
timeout Union[float, int]

The optional maximum number of seconds to wait for the jobs to be finished before returning.

None

subscribe(callback, params=None)

Subscribe a function to be called on Job status change.

The subscription is applied to all jobs created from the scenario's execution.

Parameters:

Name Type Description Default
callback Callable[[Scenario, Job], None]

The callable function to be called on status change.

required
params Optional[List[Any]]

The parameters to be passed to the callback.

None
Note

Notification will be available only for jobs created after this subscription.

unsubscribe(callback, params=None)

Unsubscribe a function that is called when the status of a Job changes.

Parameters:

Name Type Description Default
callback Callable[[Scenario, Job], None]

The callable function to unsubscribe.

required
Note

The function will continue to be called for ongoing jobs.