Skip to content

Commit 3878c20

Browse files
authored
Merge pull request #18 from neuronsimulator/olupton/tasty-fudge
model-specific output fudging + generic patterns.
2 parents df08368 + a5abf34 commit 3878c20

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

modeldb/modeldb-run.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
- run()
6363
- verify_graph_()
6464
3434:
65+
curate_patterns:
66+
- pattern: 'realtime = [0-9]+\.[0-9]+ s'
67+
repl: 'realtime = %wallclock_time%'
6568
run:
6669
- init()
6770
- gr.showAllTimeGraphs=1
@@ -1011,6 +1014,16 @@
10111014
run:
10121015
- ParmFitnessGui[0].run()
10131016
- verify_graph_()
1017+
146030:
1018+
curate_patterns:
1019+
- pattern: 'Setup time for simulation: [0-9]+\.[0-9]+ seconds'
1020+
repl: 'Setup time for simulation: %setup_time% seconds'
1021+
- pattern: 'Starting simulation of duration 300\.0 ms, dt: 0\.025, reference: Sim_8c at time: \d+/\d+/\d+,\d+:\d+:\d+ [AP]{1}M:\d+'
1022+
repl: 'Starting simulation of duration 300\.0 ms, dt: 0\.025, reference: Sim_8c at time: %current_date%'
1023+
- pattern: 'Finished simulation in [0-9]+\.[0-9]+ seconds'
1024+
repl: 'Finished simulation in %simulation_time% seconds'
1025+
- pattern: 'Current time: \d+/\d+/\d+,\d+:\d+:\d+ [AP]{1}M:\d+'
1026+
repl: 'Current time: %current_time%'
10141027
147461:
10151028
comment: //do not run Minimum time would be 1/2 hr default time is about 8.3 hours
10161029
run: null
@@ -1019,6 +1032,9 @@
10191032
- demo_run()
10201033
- verify_graph_()
10211034
150245:
1035+
curate_patterns:
1036+
- pattern: 't=100\.00;122\([0-9]+\.[0-9]+\)'
1037+
repl: 't=100.00;122(%some_kind_of_clock%)'
10221038
run:
10231039
- tstop=100
10241040
- init()
@@ -1031,6 +1047,12 @@
10311047
comment: //do not run Tried "initDialog.unmap(1)" - didnt work. Need to change
10321048
archive
10331049
run: null
1050+
187604:
1051+
curate_patterns:
1052+
- pattern: 'TIME HOST 0: [0-9\.]+ seconds \(set up\)'
1053+
repl: 'TIME HOST 0: %elapsed_time% seconds (set up)'
1054+
- pattern: 'TIME HOST 0: [0-9\.]+ seconds \(created cells\)'
1055+
repl: 'TIME HOST 0: %elapsed_time% seconds (created cells)'
10341056
206244:
10351057
run:
10361058
- chdir("mechanism")

modeldb/report.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
import json
33
import re
44
import difflib
5+
import logging
56
import os
67
import subprocess
8+
from .modeldb import ModelDB
79
from pygments import highlight
810
from pygments.lexers import DiffLexer
911
from pygments.formatters import HtmlFormatter
1012

13+
mdb = ModelDB()
1114

12-
def curate_run_data(run_data):
15+
def curate_run_data(run_data, model=None):
1316
curated_data = run_data
1417

1518
regex_dict = {
@@ -19,10 +22,22 @@ def curate_run_data(run_data):
1922
# nrniv: unable to open font "*helvetica-medium-r-normal*--14*", using "fixed" <-> special: unableto open font "*helvetica-medium-r-normal*--14*", using "fixed"
2023
"^nrniv:": "%neuron-executable%:",
2124
"^special:": "%neuron-executable%:",
25+
"(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d+ \d+:\d+:\d+ [A-Z]+ \d+": "%date_command%",
26+
"total run time [0-9\.]+": "total run time %run_time%",
2227
}
2328

29+
for model_specific_substitution in mdb.run_instr.get(model, {}).get("curate_patterns", []):
30+
regex_dict[model_specific_substitution["pattern"]] = model_specific_substitution["repl"]
31+
2432
for regex_key, regex_value in regex_dict.items():
25-
curated_data = [re.sub(regex_key, regex_value, line) for line in curated_data]
33+
updated_data = []
34+
for line in curated_data:
35+
new_line, number_of_subs = re.subn(regex_key, regex_value, line)
36+
if number_of_subs:
37+
logging.debug("{} matched {} time(s)".format(regex_key, number_of_subs))
38+
logging.debug("{} -> {}".format(line, new_line))
39+
updated_data.append(new_line)
40+
curated_data = updated_data
2641

2742
return curated_data
2843

@@ -41,8 +56,8 @@ def diff_reports(report1_json, report2_json):
4156
for k in data_a.keys():
4257
if int(k) == 0:
4358
continue # skip info key
44-
curated_a = curate_run_data(data_a[k]["nrn_run"])
45-
curated_b = curate_run_data(data_b[k]["nrn_run"])
59+
curated_a = curate_run_data(data_a[k]["nrn_run"], model=int(k))
60+
curated_b = curate_run_data(data_b[k]["nrn_run"], model=int(k))
4661
if curated_a != curated_b:
4762
diff_dict[k] = hd.make_table(curated_a, curated_b, context=True).replace("\n", " ")
4863
if "do_not_run" not in data_a[k]:

0 commit comments

Comments
 (0)