From 69c5395cb5f0579b0912ea790edc768418240f02 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:03:52 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roboflow/deployment.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/roboflow/deployment.py b/roboflow/deployment.py index c09fef68..442b9b14 100644 --- a/roboflow/deployment.py +++ b/roboflow/deployment.py @@ -69,17 +69,17 @@ def add_deployment_parser(subparsers): deployment_delete_parser.set_defaults(func=delete_deployment) deployment_delete_parser.add_argument("-a", "--api_key", help="api key") deployment_delete_parser.add_argument("deployment_name", help="deployment name") - + deployment_log_parser.set_defaults(func=get_deployment_log) deployment_log_parser.add_argument("-a", "--api_key", help="api key") deployment_log_parser.add_argument("deployment_name", help="deployment name") deployment_log_parser.add_argument( - "-d", "--duration", help="duration of log (from now) in seconds", type=int, default=3600) - deployment_log_parser.add_argument( - "-n", "--tail", help="number of lines to show from the end of the logs (<= 50)", type=int, default=10) + "-d", "--duration", help="duration of log (from now) in seconds", type=int, default=3600 + ) deployment_log_parser.add_argument( - "-f", "--follow", help="follow log output", action="store_true" + "-n", "--tail", help="number of lines to show from the end of the logs (<= 50)", type=int, default=10 ) + deployment_log_parser.add_argument("-f", "--follow", help="follow log output", action="store_true") def list_machine_types(args): @@ -168,26 +168,27 @@ def get_deployment_log(args): if api_key is None: print("Please provide an api key") exit(1) - + to_timestamp = datetime.now() - from_timestamp = (to_timestamp - timedelta(seconds = args.duration)) - log_ids = set() # to avoid duplicate logs + from_timestamp = to_timestamp - timedelta(seconds=args.duration) + log_ids = set() # to avoid duplicate logs while True: - status_code, msg = deploymentapi.get_deployment_log(api_key, args.deployment_name, args.tail, from_timestamp, to_timestamp) + status_code, msg = deploymentapi.get_deployment_log( + api_key, args.deployment_name, args.tail, from_timestamp, to_timestamp + ) if status_code != 200: print(f"{status_code}: {msg}") exit(status_code) - for log in msg[::-1]: # logs are sorted by reversed timestamp - if log['insert_id'] in log_ids: + for log in msg[::-1]: # logs are sorted by reversed timestamp + if log["insert_id"] in log_ids: continue - log_ids.add(log['insert_id']) + log_ids.add(log["insert_id"]) print(f'[{datetime.fromisoformat(log["timestamp"]).strftime("%Y-%m-%d %H:%M:%S.%f")}] {log["payload"]}') if not args.follow: break - + time.sleep(10) from_timestamp = to_timestamp to_timestamp = datetime.now() -