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/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 da4fac826..625d1fefa 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,8 @@ def close(): mdl = ErsiliaModel(model_id, service_class=service_class) mdl.close() echo(":no_entry: Model {0} closed".format(mdl.model_id), fg="green") + + #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 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)) 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")