brief-family-9488
12/02/2024, 8:03 PMjolly-florist-66728
12/02/2024, 8:03 PMFlyteRemote
, you can use the sync_execution
method. This method updates the state of the execution object with the latest status from the Flyte backend. Here's a basic example:
from flytekit.remote import FlyteRemote
# Initialize FlyteRemote
remote = FlyteRemote(config=Config.for_endpoint(endpoint="flyte.example.net"), default_project="flytesnacks", default_domain="development")
# Fetch the execution
execution = remote.fetch_execution(name="execution_id", project="flytesnacks", domain="development")
# Sync the execution to get the latest status
synced_execution = remote.sync_execution(execution, sync_nodes=True)
# Check if the execution is done
if synced_execution.is_done:
print("Execution is complete.")
else:
print("Execution is still in progress.")
Would you like more detail on this process?
Sources:
- Inspecting executions
- FlyteWorkflowExecution API π 0 button π 0 button π‘ Hint: Mention @runllm in the thread for followups.brief-family-9488
12/02/2024, 8:05 PMjolly-florist-66728
12/02/2024, 8:05 PMFlyteRemote
has failed or succeeded, you can check the closure.phase
attribute of the FlyteWorkflowExecution
object after syncing it. Here's how you can do it:
from flytekit.remote import FlyteRemote
from flytekit.models.core.execution import WorkflowExecutionPhase
# Initialize FlyteRemote
remote = FlyteRemote(config=Config.for_endpoint(endpoint="flyte.example.net"), default_project="flytesnacks", default_domain="development")
# Fetch the execution
execution = remote.fetch_execution(name="execution_id", project="flytesnacks", domain="development")
# Sync the execution to get the latest status
synced_execution = remote.sync_execution(execution, sync_nodes=True)
# Check the phase of the execution
phase = synced_execution.closure.phase
if phase == WorkflowExecutionPhase.SUCCEEDED:
print("Execution succeeded.")
elif phase == WorkflowExecutionPhase.FAILED:
print("Execution failed.")
else:
print(f"Execution is in {WorkflowExecutionPhase.enum_to_string(phase)} phase.")
Would you like more detail on this process?
Sources:
- FlyteRemote.sync_execution π 0 button π 0 button π‘ Hint: Mention @runllm in the thread for followups.freezing-airport-6809
exe = remote.execute()
then you can simply say
exe = exe.wait()
freezing-airport-6809
exe.sync()
brief-family-9488
12/03/2024, 1:27 AMfreezing-airport-6809
freezing-airport-6809
freezing-airport-6809