Skip to content

Feature: wait for upload #80

@mwallschlaeger

Description

@mwallschlaeger

Feature Description

when uploading datasets, geonodectl currently not returning the json or at least the pk of the created dataset(s). This is because uploads are implemented asynchronously through executionrequests endpoints. iT would be nice to have a parameter to follow the upload and wait until upload is finished using a function like

Proposed Solution

Something like:

def __wait_and_get_upload_pks__(execid: str, gnConf: GeonodeApiConf) -> int:
    """
    Wait for the upload to finish and retrieve the primary key (pk) of the upload.

    Args:
        execid (str): The ID of the execution.

    Returns:
        int: The primary key (pk) of the upload.

    Raises:
        SystemExit: If the upload fails or the pk ID cannot be found.
    """
    gn_execreq = gnExecutionRequest(gnConf)
    r_exec = gn_execreq.get(exec_id=execid, page_size=100)
    t = 0
    while r_exec["status"] != "finished" and r_exec["status"] != "failed":
        time.sleep(5)
        logging.info(f"waiting for data upload to finished ({t} secs) ...")
        r_exec = gn_execreq.get(exec_id=execid, page_size=100)
        t += 5

    if r_exec["status"] == "failed":
        logging.error("upload failed ...")
        logging.error(r_exec)
        sys.exit(1)

    logging.info("upload finished ...")
    pks = []
    for resource in r_exec["output_params"]["resources"]:
        pks.append(resource["id"])
    return pks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions