Skip to content

Submission

This page describes how to manage submissions in a Taipy application.

A Submission is created every time an entity (Scenario, a Sequence or a Task) is submitted for execution. It holds the list of jobs created during the submission process, and the submission's status.

Submission creation

The Submission is created using the submit() function, passing a submittable entity (i.e., a Task, a Scenario, or a Sequence) as an argument. The Submission entity is returned, holding the list of jobs created during the submission process.

Example

The code below demonstrates how to create a submission by submitting a scenario. When the scenario is submitted, a Submission is returned containing the list of jobs created. In our case, only one job is created.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import taipy as tp
from taipy import Config


def double(nb):
    return nb * 2

if __name__ == "__main__":
    # Create a scenario configuration made of one task configuration
    input_cfg = Config.configure_data_node("my_input", default_data=21)
    output_cfg = Config.configure_data_node("my_output")
    task_cfg = Config.configure_task("double_task", double, [input_cfg], [output_cfg])
    scenario_cfg = Config.configure_scenario("my_scenario", [task_cfg])

    # Run the Orchestrator service
    tp.Orchestrator().run()

    # Create a scenario and submit it
    scenario = tp.create_scenario(scenario_cfg)
    submission = tp.submit(scenario)

For more details and examples on how to submit scenarios, sequences or tasks, see the task orchestration page.

Submission attributes

Here is the list of Submission's main attributes:

  • entity_id: The identifier of the entity that was submitted.
  • id: The identifier of the Submission entity.
  • jobs: A list of jobs.
  • properties: A dictionary of additional properties.
  • creation_date: The date of this submission's creation.
  • submission_status: The current status of this submission.
  • version: The string indicates the application version of the submission to instantiate. If not provided, the latest version is used.

Submission Status

  • SUBMITTED: The submission has been submitted for execution but not processed yet by the orchestrator.
  • UNDEFINED: The submission's jobs have been submitted for execution but got some undefined status changes.
  • PENDING: The orchestrator has enqueued the submission. It is waiting for an available worker to start executing a first job.
  • BLOCKED: The submission is blocked by at least one blocked job waiting for its input data nodes to be ready.
  • RUNNING: The submission has its jobs currently being executed.
  • CANCELED: The submission has been submitted but its execution has been canceled.
  • FAILED: The submission has a job that failed during its execution.
  • COMPLETED: The submission has successfully been executed.

The timestamps of the status changes of a Submission are recorded. These timestamps can be accessed using the following properties:

  • submitted_at: The datetime when the entity of the submission was submitted.
  • run_at: The datetime when the first job of the submission started running.
  • finished_at: The datetime when the all jobs of the submission finished.
  • execution_duration: The duration of the submission execution in seconds, which is the difference between the finished_at and run_at. If the submisison is not finished, the duration is the difference between the current time and the run_at.

Get/Delete Submission

Three methods are available to get existing submissions:

A Submission can be deleted using the taipy.delete() function. Deleting a Submission can raise a SubmissionNotDeletedException if the Status of the Submission is not CANCELED, COMPLETED, FAILED or UNDEFINED.

Example

The code below demonstrates how to create a submission by submitting a scenario, and how to retrieve and delete it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import taipy as tp
from taipy import Config


def double(nb):
    return nb * 2

if __name__ == "__main__":
    # Create a scenario configuration made of one task configuration
    input_cfg = Config.configure_data_node("my_input", default_data=21)
    output_cfg = Config.configure_data_node("my_output")
    task_cfg = Config.configure_task("double_task", double, [input_cfg], [output_cfg])
    scenario_cfg = Config.configure_scenario("my_scenario", [task_cfg])

    # Run the Orchestrator service
    tp.Orchestrator().run()

    print(f'(1) Number of submission: {len(tp.get_submissions())}.')

    # Create a scenario and submit it
    scenario = tp.create_scenario(scenario_cfg)
    tp.submit(scenario)

    # Retrieve all submission.
    print(f'(2) Number of submissions: {len(tp.get_submissions())}.')

    # Get the latest submission of the scenario.
    submission = tp.get_latest_submission(scenario)

    # Then delete it.
    tp.delete(submission.id)
    print(f'(3) Number of submissions: {len(tp.get_submissions())}.')

This example produces the following output:

(1) Number of submissions: 0.
(2) Number of submissions: 1.
(3) Number of submissions: 0.