https://dagster.io/ logo
#ask-ai
Title
# ask-ai
d

Deividas Jodogalvis

02/06/2024, 1:21 PM
How to re-execute any DagsterRun
s

Scout

02/06/2024, 1:21 PM
To re-execute a Dagster run, you can use the Python APIs provided by Dagster. Here's a step-by-step guide based on the documentation: 1. Initial Execution: First, you need to execute your job. If the job does not succeed, you may want to re-execute it.
Copy code
python     from dagster import DagsterInstance, execute_job, reconstructable     from your_project.your_module import your_job      instance = DagsterInstance.ephemeral()      # Initial execution     initial_result = execute_job(reconstructable(your_job), instance=instance)
2. Re-execution: If the initial run fails and you want to re-trigger the run from the point of failure, you can use the
ReexecutionOptions
class to specify the run you want to re-execute and how you want to re-execute it.
Copy code
python     from dagster import ReexecutionOptions      if not initial_result.success:         options = ReexecutionOptions.from_failure(initial_result.run_id, instance)         # Re-execute the entire job from the point of failure         from_failure_result = execute_job(             reconstructable(your_job),             instance=instance,             reexecution_options=options         )
3. Selective Re-execution: If you want to re-execute only certain parts of the job, you can specify the steps you want to re-execute using the
step_selection
parameter of
ReexecutionOptions
.
Copy code
python     # Re-execute the job, but only the "unreliable" op and all its descendants     options = ReexecutionOptions(         parent_run_id=initial_result.run_id,         step_selection=["unreliable*"]     )     result = execute_job(         reconstructable(your_job),         instance=instance,         reexecution_options=options,     )
The
step_selection
input is configurable, and you can use patterns to select specific steps or ops. The syntax for
step_selection
is further documented in the API docs for
ReexecutionOptions
. Please note that the code examples provided here are based on the documentation and should be adapted to fit the specifics of your job and ops. If you encounter any issues or have further questions about re-executing runs, feel free to ask for additional help or clarification.
3 Views