Repository: Avaiga/taipy
File: taipy/core/scenario/scenario.py (Python)

Code before:
    InvalidSequence,
    NonExistingDataNode,
    NonExistingSequence,
    NonExistingTask,
    SequenceAlreadyExists,
    SequenceTaskDoesNotExistInScenario,
)
from ..job.job import Job
from ..notification import Event, EventEntityType, EventOperation, Notifier, _make_event
from ..sequence.sequence import Sequence
from ..submission.submission import Submission
from ..task.task import Task
from ..task.task_id import TaskId
from .scenario_id import ScenarioId


class Scenario(_Entity, Submittable, _Labeled):
    """Instance of a Business case to solve.

    A scenario holds a set of tasks (instances of `Task^` class) to submit for execution in order to
    solve the Business case. It also holds a set of additional data nodes (instances of `DataNode` class)
    for extra data related to the scenario.

    !!! note
    It is not recommended to instantiate a `Scenario` directly. Instead, it should be
    created with the `create_scenario()^` function.

    !!! Example

        ```python
        import taipy as tp
        from taipy import Config

        def by_two(x: int):
            return x * 2

        # Configure scenarios
        input_cfg = Config.configure_data_node("my_input")
        result_cfg = Config.configure_data_node("my_result")
        task_cfg = Config.configure_task("my_double", function=by_two, input=input_cfg, output=result_cfg)
        scenario_cfg = Config.configure_scenario("my_scenario", task_configs=[task_cfg])

        # Create a new scenario from the configuration
        scenario = tp.create_scenario(scenario_cfg)

        # Write the input data and submit the scenario
        scenario.my_input.write(3)
        scenario.submit()

        # Read the result
        print(scenario.my_result.read())  # Output: 6

Review comment (suggestion):
Add identation

```suggestion

        It is not recommended to instantiate a `Scenario` directly. Instead, it should be
        created with the `create_scenario()^` function.
```

Code after:
    InvalidSequence,
    NonExistingDataNode,
    NonExistingSequence,
    NonExistingTask,
    SequenceAlreadyExists,
    SequenceTaskDoesNotExistInScenario,
)
from ..job.job import Job
from ..notification import Event, EventEntityType, EventOperation, Notifier, _make_event
from ..sequence.sequence import Sequence
from ..submission.submission import Submission
from ..task.task import Task
from ..task.task_id import TaskId
from .scenario_id import ScenarioId


class Scenario(_Entity, Submittable, _Labeled):
    """Instance of a Business case to solve.

    A scenario holds a set of tasks (instances of `Task^` class) to submit for execution in order to
    solve the Business case. It also holds a set of additional data nodes (instances of `DataNode` class)
    for extra data related to the scenario.

    !!! note

        It is not recommended to instantiate a `Scenario` directly. Instead, it should be
        created with the `create_scenario()^` function.

    !!! Example

        ```python
        import taipy as tp
        from taipy import Config

        def by_two(x: int):
            return x * 2

        # Configure scenarios
        input_cfg = Config.configure_data_node("my_input")
        result_cfg = Config.configure_data_node("my_result")
        task_cfg = Config.configure_task("my_double", function=by_two, input=input_cfg, output=result_cfg)
        scenario_cfg = Config.configure_scenario("my_scenario", task_configs=[task_cfg])

        # Create a new scenario from the configuration
        scenario = tp.create_scenario(scenario_cfg)

        # Write the input data and submit the scenario
        scenario.my_input.write(3)
        scenario.submit()

        # Read the result