Skip to content

Task_any / Task_all without trigger (or: How to livemonitor sub orchestration?) #385

@kevinm90

Description

@kevinm90

Hi everyone,

I am a bit confused with the task_any and task_all options.

Let me give you bit background:
I am building a durable function to trigger and monitor a list of ADO pipelines.

all_pipeline_tasks = []
    id_ = 0
    for single_pipeline in all_pipelines_json:
        child_id = f"{context.instance_id}:{id_}"
        single_pipeline_task = context.call_sub_orchestrator("SinglePipelineRunAndMonitorOrchestrator", single_pipeline, child_id)
        all_pipeline_tasks.append(single_pipeline_task)
        id_ += 1

This works and is easy, when I just want to wait for all tasks (= pipeline runs) to complete. I just do

# All tasks should be completed, just double-checking again here
    yield context.task_all(all_pipeline_tasks)
    all_results = [single_run.result for single_run in all_pipeline_tasks]
    return f"Mass Execution completed. {all_results}"

But how do I collect intermediate status of the tasks?
E.g. I want to output via the HTTP-API, that
Task A (=Pipeline A): Completed
Task B (=Pipeline B): Running
Task C (=PIpeline C): Triggering failed
...

I tried with a loop over all tasks / remaining tasks via

remaining_tasks = all_pipeline_tasks
    while len(remaining_tasks) > 0:
        print(remaining_tasks)
        all_open_tasks = context.open_tasks
        finishedTask = yield context.task_any(remaining_tasks)
        print (f"TODO: Collect human readable status and use _set_custom_status to populate to HTTP Endpoint. Finished task: {finishedTask}")
        remaining_tasks.remove(finishedTask)

... but that does not work, as every yield task_any call will trigger all tasks again (and therefore I am ending up in an endless loop).

So to sum it up, is there any function available, that would just give me the next finished task (of a given list), without triggering these tasks? If not, could you look into creating this? Maybe as additional option to task_any / task_all.
That would help a lot :-)

Thanks and regards
Kevin

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementFeature requests.ObservabilityTrouble seeing app health or how functions run.P2Priority 2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions