# ask-the-community

Craig Amundsen

03/28/2023, 10:38 PM
Hello - I've been looking through the docs and searching here, and haven't figured out how, from flytekit, to query a flyte set up to get the execution status of a workflow that was started via FlyteRemote.emote.execute. Essentially, I want to be able to display in the system that kicked off the workflow if it's Pending, Running, Succeeded, etc. It seems like it should be possible. If someone could point me in the right direction, I'd be most appreciative.

Greg Gydush

03/28/2023, 10:45 PM
Copy code
execution = remote.sync_execution(execution, sync_nodes=True)
while not execution.is_done:
   # do something
^ does the above not work for your use case?
Copy code
def wait_for_workflow_execution_to_finish(
    execution: FlyteWorkflowExecution,
    log_interval: int | None = None,
) -> FlyteWorkflowExecution:
    """Wait for workflow to complete and return execution.

        execution: FlyteWorkflowExecution object
        log_interval: Interval for logging (in seconds). Defaults to 60.

        ValueError: If workflow execution failed

        Synced workflow execution
    log_interval = log_interval or 60
    remote = get_flyte_remote(,
    original_start_time = time.time()
    last_logged_time = time.time()
        "Syncing workflow execution. Total time elapsed: "
    while not execution.is_done:
        execution = remote.sync_execution(execution, sync_nodes=True)
        if (time.time() - last_logged_time) >= log_interval:
            last_logged_time = time.time()
            elapsed = datetime.timedelta(seconds=last_logged_time - original_start_time)
            <|>(f"Syncing execution. Total time elapsed: {elapsed}.")
    if execution.error:
        raise ValueError(execution.closure.error.message)
    <|>("Workflow execution finished.")
    return execution
^ I do something like this to get a synced execution (but you could also grab status trivially)

Craig Amundsen

03/28/2023, 11:00 PM
Thanks. I'll try that out.