From 6838a1c0c13c58453b0718653341a7ca7e1b19ec Mon Sep 17 00:00:00 2001 From: Romanas Sonkinas Date: Wed, 1 Nov 2023 10:48:40 +0000 Subject: [PATCH] A couple of small bugfixes --- CHANGES.rst | 4 ++++ croud/clusters/commands.py | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 10c339fb..c16d44ed 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,10 @@ Unreleased - Moved import and export jobs into their own section in croud docs. +- Fixed a bug preventing s3 imports from working (due to the endpoint). + +- Correctly showing percent for import jobs, and not showing for export jobs. + 1.7.0 - 2023/09/11 ================== diff --git a/croud/clusters/commands.py b/croud/clusters/commands.py index 364827ed..c2936e47 100644 --- a/croud/clusters/commands.py +++ b/croud/clusters/commands.py @@ -191,10 +191,11 @@ def import_jobs_create_from_s3(args: Namespace) -> None: "s3": { "bucket": args.bucket, "file_path": args.file_path, - "endpoint": args.endpoint or "", "secret_id": args.secret_id, } } + if args.endpoint: + extra_body["s3"]["endpoint"] = args.endpoint args.type = "s3" import_jobs_create(args, extra_payload=extra_body) @@ -854,22 +855,25 @@ def _get_formatted_records_normalized(feedback: dict) -> str: records_normalized = num_records if num_records > 1_000_000: - records_normalized = f"{records_normalized / 1_000_000:.2f} M" + records_normalized = f"{records_normalized / 1_000_000:.2f}M" elif num_records > 1_000: - records_normalized = f"{records_normalized / 1_000:.2f} K" + records_normalized = f"{records_normalized / 1_000:.2f}K" return records_normalized def _data_job_feedback_func(status: str, feedback: dict, job_type: str): records_normalized = _get_formatted_records_normalized(feedback) - percent = "{:.2f}".format(feedback.get("progress", {}).get("percent", 0)) + percent = feedback.get("progress", {}).get("percent", 0) + percent_str = "" + if percent > 0: + percent_str = "({:.2f}%) ".format(percent) if status == "SUCCEEDED": print_info(f"Done {job_type}ing {records_normalized} records") else: print_info( - f"{job_type}ing... {records_normalized} ({percent}%) records {job_type}ed " + f"{job_type}ing... {records_normalized} records {percent_str}{job_type}ed " "so far." )