Skip to content

Commit

Permalink
Merge branch 'master' into holden/metadata-to-id
Browse files Browse the repository at this point in the history
  • Loading branch information
AC-Dap authored Oct 12, 2023
2 parents 6d54b5a + 2994463 commit eb24151
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ersilia/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ def get_apis(self):
def run(
self, input=None, output=None, batch_size=DEFAULT_BATCH_SIZE, track_run=False
):
# Init some tracking before the run starts
if self._run_tracker is not None and track_run:
self._run_tracker.start_tracking()

api_name = self.get_apis()[0]
result = self.api(
api_name=api_name, input=input, output=output, batch_size=batch_size
Expand Down
15 changes: 13 additions & 2 deletions ersilia/core/tracking.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import json
import pandas as pd

Expand All @@ -10,6 +11,13 @@ class RunTracker:
NOTE: Currently, the Splunk connection is not set up. For now, we will print tracking results to the console.
"""

def __init__(self):
self.time_start = None

# function to be called before model is run
def start_tracking(self):
self.time_start = datetime.now()

def read_csv(self, file):
# reads csv file and returns Pandas dataframe
return pd.read_csv(file)
Expand All @@ -27,9 +35,12 @@ def track(self, input, result, meta):

print("Model metadata:", meta)

model_id = meta['metadata'].get ('Identifier', 'Unknown')
model_id = meta['metadata'].get('Identifier', 'Unknown')
print ("Model ID:", model_id)


time = datetime.now() - self.time_start
print("Time taken:", time)

def log_to_console(self, data):
print(f"\n{json.dumps(data)}\n")

Expand Down

0 comments on commit eb24151

Please sign in to comment.