From 3cec770cf42d1ca7a850fcf4f59d39ac5f86b30f Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 7 Oct 2023 19:54:37 -0400 Subject: [PATCH 1/5] added tracking model run time --- ersilia/core/model.py | 1 + ersilia/core/tracking.py | 14 +++++++++++++- my_molecules.csv | 5 +++++ my_molecules_output.csv | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 my_molecules.csv create mode 100644 my_molecules_output.csv diff --git a/ersilia/core/model.py b/ersilia/core/model.py index 6ec580fec..c28301d0d 100644 --- a/ersilia/core/model.py +++ b/ersilia/core/model.py @@ -413,6 +413,7 @@ def get_apis(self): return self.autoservice.get_apis() def run(self, input=None, output=None, batch_size=DEFAULT_BATCH_SIZE, track_run=False): + 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 diff --git a/ersilia/core/tracking.py b/ersilia/core/tracking.py index 25da8f774..436b805fb 100644 --- a/ersilia/core/tracking.py +++ b/ersilia/core/tracking.py @@ -1,3 +1,5 @@ +from datetime import datetime + class RunTracker: """ This class will be responsible for tracking model runs. It calculates the desired metadata based on a model's @@ -5,6 +7,13 @@ class RunTracker: NOTE: Currently, the Splunk connection is not set up. For now, we will print tracking results to the console. """ + time_start = None + # 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 track(self, input, result, meta): """ @@ -14,4 +23,7 @@ def track(self, input, result, meta): print("Run input file:", input) print("Run output file:", result) - print("Model metadata:", meta) \ No newline at end of file + print("Model metadata:", meta) + + time = datetime.now() - self.time_start + print("Time taken:", time) \ No newline at end of file diff --git a/my_molecules.csv b/my_molecules.csv new file mode 100644 index 000000000..a8ed0cfbd --- /dev/null +++ b/my_molecules.csv @@ -0,0 +1,5 @@ +Nc1ccc(cc1)S(N)(=O)=O +C[C@H](CSC(C)=O)C(=O)N1CCC[C@H]1C(=O)N[C@@H](Cc1ccccc1)C(O)=O +COc1ccc(Cl)c(Nc2ncnc3cc(OCC4CCN(C)CC4)c(OC)cc23)c1 +C(N1CCCNCCNCCCNCC1)c1ccc(CN2CCCNCCNCCCNCC2)cc1 +CC(C)NC[C@H](O)COc1cccc2ccccc12 diff --git a/my_molecules_output.csv b/my_molecules_output.csv new file mode 100644 index 000000000..cfa8bf299 --- /dev/null +++ b/my_molecules_output.csv @@ -0,0 +1,6 @@ +key,input,mw +FDDDEECHVMSUSB-UHFFFAOYSA-N,Nc1ccc(cc1)S(N)(=O)=O,172.20899999999997 +FHHHOYXPRDYHEZ-COXVUDFISA-N,C[C@H](CSC(C)=O)C(=O)N1CCC[C@H]1C(=O)N[C@@H](Cc1ccccc1)C(O)=O,406.5040000000001 +WPOXAFXHRJYEIC-UHFFFAOYSA-N,COc1ccc(Cl)c(Nc2ncnc3cc(OCC4CCN(C)CC4)c(OC)cc23)c1,442.94700000000034 +YIQPUIGJQJDJOS-UHFFFAOYSA-N,C(N1CCCNCCNCCCNCC1)c1ccc(CN2CCCNCCNCCCNCC2)cc1,502.79600000000045 +AQHHHDLHHXJYJD-AWEZNQCLSA-N,CC(C)NC[C@H](O)COc1cccc2ccccc12,259.34900000000005 From 67124e623b0165efdfee3e19c9098ca60a193947 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Mon, 9 Oct 2023 10:59:42 -0400 Subject: [PATCH 2/5] Class variable to instance variable tracking.py Changed the class variable to an instance variable --- ersilia/core/tracking.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ersilia/core/tracking.py b/ersilia/core/tracking.py index ce8b70545..f7fa471d8 100644 --- a/ersilia/core/tracking.py +++ b/ersilia/core/tracking.py @@ -8,9 +8,8 @@ class RunTracker: NOTE: Currently, the Splunk connection is not set up. For now, we will print tracking results to the console. """ - time_start = None - # def __init__(self): - # self.time_start = None + def __init__(self): + self.time_start = None # function to be called before model is run def start_tracking(self): From 316234e73fe65131443df01a29f658354e682f17 Mon Sep 17 00:00:00 2001 From: Anthony Cui Date: Mon, 9 Oct 2023 22:27:22 -0400 Subject: [PATCH 3/5] Call tracker.start_tracking when model is run --- ersilia/core/model.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ersilia/core/model.py b/ersilia/core/model.py index 30500beef..2ef49f26f 100644 --- a/ersilia/core/model.py +++ b/ersilia/core/model.py @@ -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 From 2bc657793da58a6e1582364cfe0959ff54cee204 Mon Sep 17 00:00:00 2001 From: AC-Dap Date: Tue, 10 Oct 2023 02:36:36 +0000 Subject: [PATCH 4/5] Apply automatic changes --- ersilia/core/tracking.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ersilia/core/tracking.py b/ersilia/core/tracking.py index d139110ba..779d5e65e 100644 --- a/ersilia/core/tracking.py +++ b/ersilia/core/tracking.py @@ -10,6 +10,7 @@ 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 From ba98d5d1dfa16101c78c6103031eeefacc6a924b Mon Sep 17 00:00:00 2001 From: Anthony Cui Date: Mon, 9 Oct 2023 22:39:01 -0400 Subject: [PATCH 5/5] Don't track input and output csv files --- my_molecules.csv | 5 ----- my_molecules_output.csv | 6 ------ 2 files changed, 11 deletions(-) delete mode 100644 my_molecules.csv delete mode 100644 my_molecules_output.csv diff --git a/my_molecules.csv b/my_molecules.csv deleted file mode 100644 index a8ed0cfbd..000000000 --- a/my_molecules.csv +++ /dev/null @@ -1,5 +0,0 @@ -Nc1ccc(cc1)S(N)(=O)=O -C[C@H](CSC(C)=O)C(=O)N1CCC[C@H]1C(=O)N[C@@H](Cc1ccccc1)C(O)=O -COc1ccc(Cl)c(Nc2ncnc3cc(OCC4CCN(C)CC4)c(OC)cc23)c1 -C(N1CCCNCCNCCCNCC1)c1ccc(CN2CCCNCCNCCCNCC2)cc1 -CC(C)NC[C@H](O)COc1cccc2ccccc12 diff --git a/my_molecules_output.csv b/my_molecules_output.csv deleted file mode 100644 index cfa8bf299..000000000 --- a/my_molecules_output.csv +++ /dev/null @@ -1,6 +0,0 @@ -key,input,mw -FDDDEECHVMSUSB-UHFFFAOYSA-N,Nc1ccc(cc1)S(N)(=O)=O,172.20899999999997 -FHHHOYXPRDYHEZ-COXVUDFISA-N,C[C@H](CSC(C)=O)C(=O)N1CCC[C@H]1C(=O)N[C@@H](Cc1ccccc1)C(O)=O,406.5040000000001 -WPOXAFXHRJYEIC-UHFFFAOYSA-N,COc1ccc(Cl)c(Nc2ncnc3cc(OCC4CCN(C)CC4)c(OC)cc23)c1,442.94700000000034 -YIQPUIGJQJDJOS-UHFFFAOYSA-N,C(N1CCCNCCNCCCNCC1)c1ccc(CN2CCCNCCNCCCNCC2)cc1,502.79600000000045 -AQHHHDLHHXJYJD-AWEZNQCLSA-N,CC(C)NC[C@H](O)COc1cccc2ccccc12,259.34900000000005