Async Execution & Cloud Orchestration
FlowyML supports asynchronous execution for cloud orchestrators, allowing you to submit jobs to remote infrastructure without blocking your local process.
Overview
When using a RemoteOrchestrator (like AWS Batch, SageMaker, Vertex AI, or Azure ML), the run_pipeline method returns a SubmissionResult object immediately after the job is successfully submitted.
from flowyml.stacks.aws import AWSBatchOrchestrator
# Initialize remote orchestrator
orchestrator = AWSBatchOrchestrator(
job_queue="my-queue",
job_definition="my-job-def"
)
# Submit pipeline (non-blocking)
result = orchestrator.run_pipeline(pipeline, run_id="run-123")
print(f"π Job submitted! ID: {result.job_id}")
SubmissionResult
A submission has a provider job ID (job_id), platform-specific metadata, and a wait() method. Pass a timeout in seconds when another part of your application needs control back by a deadline.
try:
result.wait(timeout=30)
except TimeoutError:
print(f"Stopped waiting locally for {result.job_id}")
A successful wait returns None. A failed, stopped, or cancelled job raises RuntimeError. After a timeout, you can wait on the same handle again. While detached, FlowyML starts no further status reads. A transport call or custom blocking wait already in progress may finish in the background. wait(timeout=0) checks the result already observed by this handle. wait() with no timeout uses the orchestrator's native wait when available.
Job Control & Monitoring
You can monitor and control jobs using the orchestrator instance:
Check Status
status = orchestrator.get_run_status(result.job_id)
print(f"Current Status: {status}") # e.g., ExecutionStatus.RUNNING
Cancel Job
Follow a run locally
Use flowyml run train --stack azure-training --follow to submit a remote run, follow its logs, and sync its outputs in one command. To reconnect to an existing run, use the FlowyML run ID printed at submission. Open the Logs tab for a step in the dashboard or follow its output in a terminal.
flowyml logs RUN_ID --follow
flowyml logs RUN_ID --step train --tail 30 --follow
flowyml sync RUN_ID --wait --timeout 120
Add --timeout SECONDS to run --follow, logs --follow, or sync --wait to limit local polling. For a submission, one deadline covers both log streaming and output sync. The CLI checks the deadline between provider calls and exits with code 124 when it expires. The remote job continues, and you can reconnect by its printed FlowyML run ID.
Python applications can reconnect after a restart with the FlowyML run ID returned by pipeline.run(). Call sync_run(run_id) for one refresh, or wait through final step reconciliation and output indexing.
from flowyml import RunSyncError, sync_run
try:
record = sync_run(run_id, wait=True, timeout=120)
print(record["status"], record.get("metrics", {}))
except RunSyncError as error:
print(error)
if error.run:
print(error.run.get("steps", {}))
raise
sync_run locates the owning project or configured SQL database and writes discovered artifacts there. An explicit store= selects the database when projects reuse a run ID. refresh=True rechecks a completed job. As with the CLI, the sync deadline is checked between provider calls. If it expires, the caller receives TimeoutError.
When following a run, the CLI retries temporary network failures and provider throttling up to four consecutive attempts per read. An access error or exhausted retries produces a nonzero exit code, even when cached output is available. If another execution takes over the same FlowyML run ID, the CLI reports the change.
When two projects reuse a FlowyML run ID, the dashboard offers a project chooser. Links opened from a project keep its name through logs, downloads, and stop requests. The CLI and Python SDK also accept a project name. Use an empty string to select an unassigned run.
flowyml logs nightly --project research --follow
flowyml sync nightly --project research --wait
flowyml runs inspect nightly --project research
flowyml runs stop nightly --project research
When you reassign an active run in the dashboard, current workers keep publishing to that attempt. Open the run in its new project to follow it.
Each metadata database uses the run ID as a primary key. Dedicated project databases can hold independent runs with the same ID. If the selected store already holds that ID for another project, choose a new ID. SDK submissions check ownership before dispatch, and metadata writes recheck it before updating the row. Historical logs in an unlabelled shared directory can be attributed only when their owning execution can be identified.
The dashboard fetches a log backlog in pages and resumes from the last displayed output when a connection drops or the stream goes quiet. For a live remote run, FlowyML keeps checking logs for 20 seconds after observing completion and performs a final read. This captures delayed lines even when their worker timestamps precede the last displayed event. An older completed run opens immediately using its recorded end time. Use flowyml runs list to find its ID or flowyml sync RUN_ID --refresh to recheck for late child jobs.
Local workers retain stdout and stderr even when the dashboard is closed. Remote runs use the workspace, project, or region associated with the submission. Vertex AI uses Cloud Logging, SageMaker and AWS Batch use CloudWatch Logs, and Azure ML uses worker and controller logs. Steps that share a job share its worker log. The enterprise Databricks adapter follows the task output published by the Jobs API, which provides the most recent 5 MB. Databricks Jobs API
Use the dashboard's Stop Run button or flowyml runs stop RUN_ID to request cancellation. An active local Python step can take until its next heartbeat to stop. A blocking call in native code can delay interruption until control returns to Python. Completed steps keep their outputs, and the dashboard distinguishes the stopped step from work that was skipped.
The dashboard stores each worker's latest heartbeat and resource sample with its run attempt. After a server restart, the run detail can identify a running local step that missed three heartbeat intervals. A new heartbeat restores the running indication.
Supported Platforms
| Platform | Orchestrator Class | Status Tracking | Cancellation |
|---|---|---|---|
| AWS | AWSBatchOrchestrator |
β | β |
| AWS | SageMakerOrchestrator |
β | β |
| GCP | VertexAIOrchestrator |
β | β |
| Azure | AzureMLOrchestrator |
β | β |