Thread
#prefect-community
    e

    Eric

    2 years ago
    Hi team, I have another question here. I have a flow with 3 tasks (A->B->C) and task B is to sleep 60 sec for example. When the flow-run is started to B, I set the flow-run state to PAUSE via (
    client.set_flow_run_state(flow_run_id="<flow_run_id>", state=PAUSE)
    ). The flow-run state on UI is set to PAUSE and the task B continues to execute until the end. But once the task B is finished, I use
    client.set_flow_run_state
    to set this flow-run back to running (or resume). Task C will get this error (I throw it to thread) and the whole flow-run is still running (Task C is pending), it seems like an abnormal state because this flow-run will keep running but do nothing. May I ask if this is normal? Thanks πŸ™‚
    Failed to set task state with error: ClientError([{'message': 'State update failed for task run ID 3a05c8b8-e5b7-4952-b0ee-d3122b8d009c: provided a running state but associated flow run 1cb102f5-d7eb-4282-a6b7-e25a7bd97ab6 is not in a running state.', 'locations': [{'line': 2, 'column': 5}], 'path': ['set_task_run_states'], 'extensions': {'code': 'INTERNAL_SERVER_ERROR', 'exception': {'message': 'State update failed for task run ID 3a05c8b8-e5b7-4952-b0ee-d3122b8d009c: provided a running state but associated flow run 1cb102f5-d7eb-4282-a6b7-e25a7bd97ab6 is not in a running state.'}}}])
    Traceback (most recent call last):
    File "/Users/xy.l./.local/share/virtualenvs/data_platform-a2_zvZ3_/lib/python3.7/site-packages/prefect/engine/cloud/task_runner.py", line 116, in call_runner_target_handlers
    cache_for=self.task.cache_for,
    File "/Users/xy.l./.local/share/virtualenvs/data_platform-a2_zvZ3_/lib/python3.7/site-packages/prefect/client/client.py", line 1303, in set_task_run_state
    version=version,
    File "/Users/xy.l./.local/share/virtualenvs/data_platform-a2_zvZ3_/lib/python3.7/site-packages/prefect/client/client.py", line 287, in graphql
    raise ClientError(result["errors"])
    prefect.utilities.exceptions.ClientError: [{'message': 'State update failed for task run ID 3a05c8b8-e5b7-4952-b0ee-d3122b8d009c: provided a running state but associated flow run 1cb102f5-d7eb-4282-a6b7-e25a7bd97ab6 is not in a running state.', 'locations': [{'line': 2, 'column': 5}], 'path': ['set_task_run_states'], 'extensions': {'code': 'INTERNAL_SERVER_ERROR', 'exception': {'message': 'State update failed for task run ID 3a05c8b8-e5b7-4952-b0ee-d3122b8d009c: provided a running state but associated flow run 1cb102f5-d7eb-4282-a6b7-e25a7bd97ab6 is not in a running state.'}}}]
    Chris White

    Chris White

    2 years ago
    Hi Eric - currently there is no way to Pause an actively running flow; the only states that have real meaning for a Flow Run are: Scheduled, Submitted, Running, Cancelling, Cancelled, Failed, and Success. If a flow run is not in a
    Running
    state, then task runs are not allowed to enter
    Running
    states themselves, as this is the only state that signifies to Prefect that work is allowed to continue
    e

    Eric

    2 years ago
    ok, I got it. Thanks for your reply ☺️