broadinstitute/fiss

Request to Add Expand_Subworkfow Option to get_workflow_metadata

Closed this issue · 1 comments

Description:

I propose adding an expand_sub_workflows option to the get_workflow_metadata function to streamline the retrieval of associated workflow_ds.

Current Issue:

Users must manually call get_workflow_metadata multiple times to retrieve data for multi-level nested subworkflows, leading to:
Increased code complexity
Redundant API calls

Proposed Change:

Introduce a new boolean argument, expand_sub_workflows, to get_workflow_metadata:
When set to True, automatically retrieves metadata for all subworkflows, recursively encompassing nested structures.

Code Example:

def get_workflow_metadata(namespace, workspace, submission_id, workflow_id,
                          expand_sub_workflows=False):
    """Request the metadata for a workflow in a submission.

    Args:
        namespace (str): project to which workspace belongs
        workspace (str): Workspace name
        submission_id (str): Submission's unique identifier
        workflow_id (str): Workflow's unique identifier.
        expand_sub_workflows (bool): Whether to expand subworkflows

    Swagger:
        https://api.firecloud.org/#!/Submissions/workflowMetadata
    """
    uri = "workspaces/{0}/{1}/submissions/{2}/workflows/{3}".format(namespace,
                                            workspace, submission_id, workflow_id)
    if expand_sub_workflows:
        uri += "?expandSubWorkflows=true"
    return __get(uri)

Thanks for the report @bshifaw I'll work on getting an update out in the next few days. This is the patch I'm looking at doing:

def get_workflow_metadata(namespace, workspace, submission_id, workflow_id,
                          include_key=None, exclude_key=None,
                          expand_sub_workflows=False):
    """Request the metadata for a workflow in a submission.

    Args:
        namespace (str): project to which workspace belongs
        workspace (str): Workspace name
        submission_id (str): Submission's unique identifier
        workflow_id (str): Workflow's unique identifier.
        include_key (array[str]): When specified, return only these keys in the
            response. Matches any key in the response, including within nested
            blocks. May not be used with exclude_key.
        exclude_key (array[str]): When specified, omit these keys from the
            response. Matches any key in the response, including within nested
            blocks. May not be used with include_key.
        expand_sub_workflows (bool): When true, metadata for sub workflows will
            be fetched and inserted automatically in the metadata response.

    Swagger:
        https://api.firecloud.org/#!/Submissions/workflowMetadata
    """
    uri = "workspaces/{0}/{1}/submissions/{2}/workflows/{3}".format(namespace,
                                            workspace, submission_id, workflow_id)
    params = {}
    if include_key is not None:
        params["includeKey"] = include_key
    if exclude_key is not None:
        params["excludeKey"] = exclude_key
    if expand_sub_workflows:
        params["expandSubWorkflows"] = expand_sub_workflows
    return __get(uri, params=params)