From 172ca2f6dcd367d6a7d921f23096494d54c75bb1 Mon Sep 17 00:00:00 2001 From: Holden Schermer Date: Sat, 21 Oct 2023 16:35:02 -0400 Subject: [PATCH 1/6] creates current_session.txt --- ersilia/cli/commands/close.py | 6 ++++++ ersilia/cli/commands/serve.py | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ersilia/cli/commands/close.py b/ersilia/cli/commands/close.py index da4fac826..442d5031f 100644 --- a/ersilia/cli/commands/close.py +++ b/ersilia/cli/commands/close.py @@ -1,3 +1,5 @@ +import datetime +import os from . import ersilia_cli from .. import echo from ... import ErsiliaModel @@ -17,3 +19,7 @@ def close(): mdl = ErsiliaModel(model_id, service_class=service_class) mdl.close() echo(":no_entry: Model {0} closed".format(mdl.model_id), fg="green") + + old_file_path = "/ersilia/core/current_session.txt" + new_file_path = os.path.join(os.path.dirname(old_file_path), datetime.datetime.now().strftime('%Y%m%d%H%M%S')) + os.rename(old_file_path, new_file_path) \ No newline at end of file diff --git a/ersilia/cli/commands/serve.py b/ersilia/cli/commands/serve.py index 3c05e366a..c8b4be6ce 100644 --- a/ersilia/cli/commands/serve.py +++ b/ersilia/cli/commands/serve.py @@ -20,7 +20,11 @@ def serve_cmd(): type=click.INT, help="Preferred port to use (integer)", ) - def serve(model, lake, docker, port): + # Add the new flag for tracking the serve session + @click.option( + "-t/", "--track_serve/--no_track_serve", "track_serve", required=False, default=True + ) + def serve(model, lake, docker, port, track_serve): if docker: service_class = "docker" else: @@ -54,3 +58,6 @@ def serve(model, lake, docker, port): echo("") echo(":person_tipping_hand: Information:", fg="blue") echo(" - info", fg="blue") + if track_serve: + with open("current_session.txt", "w") as f: + f.write("Session started for model: {0}".format(mdl.model_id)) From 2a2c7a44963518155073bcf7cf5a1d8c77f945d8 Mon Sep 17 00:00:00 2001 From: Chooi Je Qin <42904912+jeqinchooi@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:57:25 -0400 Subject: [PATCH 2/6] write debug info to current_session.txt --- .idea/.gitignore | 3 +++ .idea/ersilia.iml | 12 ++++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ ersilia/core/tracking.py | 10 ++++++++++ 7 files changed, 49 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/ersilia.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..26d33521a --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/ersilia.iml b/.idea/ersilia.iml new file mode 100644 index 000000000..039314de6 --- /dev/null +++ b/.idea/ersilia.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..2d239058f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..10b052848 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..94a25f7f4 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ersilia/core/tracking.py b/ersilia/core/tracking.py index 64f8c8063..781b098bb 100644 --- a/ersilia/core/tracking.py +++ b/ersilia/core/tracking.py @@ -87,6 +87,16 @@ def track(self, input, result, meta): self.get_file_sizes(input_dataframe, result_dataframe) + # log results to console + with open('../cli/commands/current_session.txt', 'a') as f: + # write the print statements to a file + f.write(f"\n{json.dumps(input_dataframe)}\n") + f.write(f"\n{json.dumps(result_dataframe)}\n") + f.write(f"\n{json.dumps(meta)}\n") + f.write(f"\nModel ID: {model_id}\n") + f.write(f"\nTime taken: {time}\n") + f.write(f"\nNAN Count:\n {nan_count}\n") + def log_to_console(self, data): print(f"\n{json.dumps(data)}\n") From c888e5ae1989a53d41af025126a6c3fcd7d03979 Mon Sep 17 00:00:00 2001 From: Holden Schermer Date: Sat, 21 Oct 2023 17:30:55 -0400 Subject: [PATCH 3/6] finished deliverable --- ersilia/20231021170711 | 1 + ersilia/cli/commands/close.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 ersilia/20231021170711 diff --git a/ersilia/20231021170711 b/ersilia/20231021170711 new file mode 100644 index 000000000..eb17ccd0f --- /dev/null +++ b/ersilia/20231021170711 @@ -0,0 +1 @@ +Session started for model: eos4rta \ No newline at end of file diff --git a/ersilia/cli/commands/close.py b/ersilia/cli/commands/close.py index 442d5031f..625d1fefa 100644 --- a/ersilia/cli/commands/close.py +++ b/ersilia/cli/commands/close.py @@ -20,6 +20,7 @@ def close(): mdl.close() echo(":no_entry: Model {0} closed".format(mdl.model_id), fg="green") - old_file_path = "/ersilia/core/current_session.txt" + #renames current_session to timestamp + old_file_path = "current_session.txt" new_file_path = os.path.join(os.path.dirname(old_file_path), datetime.datetime.now().strftime('%Y%m%d%H%M%S')) os.rename(old_file_path, new_file_path) \ No newline at end of file From 1ab2d7a8c61fdcc2532c3ddce342819e98e8a104 Mon Sep 17 00:00:00 2001 From: Holden Schermer Date: Sat, 21 Oct 2023 17:34:22 -0400 Subject: [PATCH 4/6] finished deliverable 2 --- ersilia/20231021170711 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 ersilia/20231021170711 diff --git a/ersilia/20231021170711 b/ersilia/20231021170711 deleted file mode 100644 index eb17ccd0f..000000000 --- a/ersilia/20231021170711 +++ /dev/null @@ -1 +0,0 @@ -Session started for model: eos4rta \ No newline at end of file From 47539258c264ef593da0a4ee3cd793ef6dd16402 Mon Sep 17 00:00:00 2001 From: Anthony Cui Date: Fri, 27 Oct 2023 19:52:04 -0400 Subject: [PATCH 5/6] Remove .idea from git --- .gitignore | 1 + .idea/.gitignore | 3 --- .idea/ersilia.iml | 12 ------------ .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/misc.xml | 4 ---- .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 7 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/ersilia.iml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 819ea58e4..4e463cefc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ secrets.json development.ipynb development.py tmp/ +.idea/ # Sphinx related /doctrees diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d33521a..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/ersilia.iml b/.idea/ersilia.iml deleted file mode 100644 index 039314de6..000000000 --- a/.idea/ersilia.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2..000000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 2d239058f..000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 10b052848..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 77a626d15c611b0c7a8e4ee6e16c1c4073f076a0 Mon Sep 17 00:00:00 2001 From: AC-Dap Date: Fri, 27 Oct 2023 23:59:57 +0000 Subject: [PATCH 6/6] Apply automatic changes --- ersilia/cli/commands/close.py | 9 ++++++--- ersilia/cli/commands/serve.py | 6 +++++- ersilia/core/tracking.py | 7 +++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ersilia/cli/commands/close.py b/ersilia/cli/commands/close.py index 625d1fefa..d053ceda4 100644 --- a/ersilia/cli/commands/close.py +++ b/ersilia/cli/commands/close.py @@ -20,7 +20,10 @@ def close(): mdl.close() echo(":no_entry: Model {0} closed".format(mdl.model_id), fg="green") - #renames current_session to timestamp + # renames current_session to timestamp old_file_path = "current_session.txt" - new_file_path = os.path.join(os.path.dirname(old_file_path), datetime.datetime.now().strftime('%Y%m%d%H%M%S')) - os.rename(old_file_path, new_file_path) \ No newline at end of file + new_file_path = os.path.join( + os.path.dirname(old_file_path), + datetime.datetime.now().strftime("%Y%m%d%H%M%S"), + ) + os.rename(old_file_path, new_file_path) diff --git a/ersilia/cli/commands/serve.py b/ersilia/cli/commands/serve.py index c8b4be6ce..d4018357a 100644 --- a/ersilia/cli/commands/serve.py +++ b/ersilia/cli/commands/serve.py @@ -22,7 +22,11 @@ def serve_cmd(): ) # Add the new flag for tracking the serve session @click.option( - "-t/", "--track_serve/--no_track_serve", "track_serve", required=False, default=True + "-t/", + "--track_serve/--no_track_serve", + "track_serve", + required=False, + default=True, ) def serve(model, lake, docker, port, track_serve): if docker: diff --git a/ersilia/core/tracking.py b/ersilia/core/tracking.py index ec7c0c9be..e759e5400 100644 --- a/ersilia/core/tracking.py +++ b/ersilia/core/tracking.py @@ -95,12 +95,12 @@ def track(self, input, result, meta): self.stats(result) self.get_file_sizes(input_dataframe, result_dataframe) - - json_object = json.dumps(json_dict, indent = 4) + + json_object = json.dumps(json_dict, indent=4) print("\nJSON Dictionary:\n", json_object) # log results to console - with open('../cli/commands/current_session.txt', 'a') as f: + with open("../cli/commands/current_session.txt", "a") as f: # write the print statements to a file f.write(f"\n{json.dumps(input_dataframe)}\n") f.write(f"\n{json.dumps(result_dataframe)}\n") @@ -109,7 +109,6 @@ def track(self, input, result, meta): f.write(f"\nTime taken: {time}\n") f.write(f"\nNAN Count:\n {nan_count}\n") - def log_to_console(self, data): print(f"\n{json.dumps(data)}\n")