From 912692cb4741eb5eb7dbffb9070968c75e994daf Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Wed, 5 May 2021 18:57:31 -0700 Subject: [PATCH] Display %load command execution time as HH:MM:SS for large values (#121) * Display %load command execution time as HH:MM:SS for large values * Update changelog Co-authored-by: Michael Chin --- ChangeLog.md | 2 +- src/graph_notebook/magics/graph_magic.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f464664a..ae19f4dc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,7 +6,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd - Add support for notebook variables in Sparql/Gremlin magic queries ([Link to PR](https://github.com/aws/graph-notebook/pull/113)) - Add support for grouping by different properties per label in Gremlin ([Link to PR](https://github.com/aws/graph-notebook/pull/115)) - Fix missing Boto3 dependency in setup.py ([Link to PR](https://github.com/aws/graph-notebook/pull/118)) - +- Update %load execution time to HH:MM:SS format if over a minute ([Link to PR](https://github.com/aws/graph-notebook/pull/121)) ## Release 2.1.1 (April 22, 2021) diff --git a/src/graph_notebook/magics/graph_magic.py b/src/graph_notebook/magics/graph_magic.py index 77c0832f..70ec0f81 100644 --- a/src/graph_notebook/magics/graph_magic.py +++ b/src/graph_notebook/magics/graph_magic.py @@ -9,6 +9,7 @@ import logging import json import time +import datetime import os import uuid from enum import Enum @@ -823,7 +824,12 @@ def on_button_clicked(b): print(f'Overall Status: {interval_check_response["payload"]["overallStatus"]["status"]}') if interval_check_response["payload"]["overallStatus"]["status"] in FINAL_LOAD_STATUSES: execution_time = interval_check_response["payload"]["overallStatus"]["totalTimeSpent"] - execution_time_statement = '<1 second' if execution_time == 0 else f'{execution_time} seconds' + if execution_time == 0: + execution_time_statement = '<1 second' + elif execution_time > 59: + execution_time_statement = str(datetime.timedelta(seconds=execution_time)) + else: + execution_time_statement = f'{execution_time} seconds' print('Total execution time: ' + execution_time_statement) interval_output.close() print('Done.')