From da7b8519e2158ab0f3ee3afb1a95022336618197 Mon Sep 17 00:00:00 2001 From: Alex Sickler Date: Mon, 1 Apr 2024 14:24:21 -0400 Subject: [PATCH] :sparkles: add download job result subcommand --- d3b_dff_cli/modules/dewrangle/download_job.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 d3b_dff_cli/modules/dewrangle/download_job.py diff --git a/d3b_dff_cli/modules/dewrangle/download_job.py b/d3b_dff_cli/modules/dewrangle/download_job.py new file mode 100644 index 0000000..68ccf5c --- /dev/null +++ b/d3b_dff_cli/modules/dewrangle/download_job.py @@ -0,0 +1,24 @@ +"""Download job results from Dewrangle.""" + +from . import helper_functions as hf + +def download_job(jobid, token=None): + """ + Function to download results from Dewrangle + Input: Dewrangle job id + Output: object with job resuls + """ + + client = hf.create_gql_client(api_key=token) + + return hf.download_job_result(jobid, client=client, api_key=token) + + +def main(args): + """Main function.""" + + status, job_df = download_job(args.jobid) + if status == "Complete": + job_df.to_csv(args.outfile) + else: + print("Job incomplete, please check again later.")