Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holden/track model runs using a file #14

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ersilia.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ersilia/20231021170711
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Session started for model: eos4rta
7 changes: 7 additions & 0 deletions ersilia/cli/commands/close.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime
import os
from . import ersilia_cli
from .. import echo
from ... import ErsiliaModel
Expand All @@ -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)
9 changes: 8 additions & 1 deletion ersilia/cli/commands/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))
10 changes: 10 additions & 0 deletions ersilia/core/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Loading