Skip to content
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ different OpenModelica versions, according to the conditions of the
`(dr)` next to `(sim)`, with a *Reconciliation result* column in the library
page. The simulation columns of the reports are titled *Reconciliation
computation* for such a library.
A *Reconciliation extraction* column before it says whether omc extracted
the model to reconcile, which it does in its back end: the model counts as
extracted when omc wrote `<model>_Reconciled_tmp.mo`, the file the cell
links. The result database keeps that as `drextracted`, for the overview.
[configs/dataReconciliation-newBackend.json](./configs/dataReconciliation-newBackend.json)
is the same configuration with `--newBackend`; it fills the branch
`dataReconciliation-newBackend`, and `overview-dataReconciliation.html` has
Expand Down
6 changes: 3 additions & 3 deletions library.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<th>SimCode</th>
<th>Templates</th>
<th>Compilation</th>
<th>#simulationLabel#</th>
#drExtractionHeader#<th>#simulationLabel#</th>
#drSummaryHeader#<th>Verification</th>
</tr>
<tr>
Expand All @@ -30,7 +30,7 @@
<td bgcolor="#SimCodeColor#">#SimCode#</td>
<td bgcolor="#TemplatesColor#">#Templates#</td>
<td bgcolor="#CompilationColor#">#Compilation#</td>
<td bgcolor="#SimulationColor#">#Simulation#</td>
#drExtractionSummary#<td bgcolor="#SimulationColor#">#Simulation#</td>
#drSummary#<td bgcolor="#VerificationColor#">#Verification#</td>
</tr>
</table>
Expand Down Expand Up @@ -59,7 +59,7 @@ Config: <pre>#config#</pre>
<p>Links are provided if getErrorString() or the simulation generates output. The links are coded with <font style="#FF0000">red</font> if there were errors, <font style="#FFCC66">yellow</font> if there were warnings, and normal links if there are only notifications.</p>
#invalidNote#
<table>
<tr><th>Model</th><th>Verified</th><th>#simulateLabel#</th>#drHeader#<th>Total buildModel</th><th>Parsing</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compile</th><th>Total Execution</th></tr>
<tr><th>Model</th><th>Verified</th>#drExtractionHeader#<th>#simulateLabel#</th>#drHeader#<th>Total buildModel</th><th>Parsing</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compile</th><th>Total Execution</th></tr>
#testsHTML#
</table>
<script>
Expand Down
41 changes: 30 additions & 11 deletions report.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
libnames = set(shared.libname(library,conf) for (library,conf) in configs)
# What a data reconciliation run simulates is the model the reconciliation
# extracted, not the library's model.
simulationLabel = shared.DR_SIMULATION_LABEL if configs and all(conf.get("dataReconciliation") for (library,conf) in configs) else "Simulation"
entryhead = "<tr><th>Branch</th><th>Total</th><th>Parsing</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compilation</th><th>%s</th><th>Verification</th></tr>\n" % simulationLabel
dataReconciliation = bool(configs) and all(conf.get("dataReconciliation") for (library,conf) in configs)
simulationLabel = shared.DR_SIMULATION_LABEL if dataReconciliation else "Simulation"
entryhead = "<tr><th>Branch</th><th>Total</th><th>Parsing</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compilation</th>%%s<th>%s</th><th>Verification</th></tr>\n" % simulationLabel
# The extraction is counted next to the computation it is done for. It has no
# time of its own: it is part of the back end.
phasesHead = entryhead % ("<th>%s</th>" % shared.DR_EXTRACTION_LABEL if dataReconciliation else "")
timesHead = entryhead % ""

db = resultsdb.connect(args.db)
cursor = db.cursor()
Expand Down Expand Up @@ -85,8 +90,11 @@ def inView(view, model, invalid):
dates[branch][libname] = 0
continue
dates[branch][libname] = v[0]
rows[branch][libname] = cursor.execute("SELECT model,finalphase,%s FROM %s WHERE libname=? AND date=? AND finalphase>=0"
% (",".join(fields), db.quote(branch)), (libname,v[0])).fetchall()
# A table from before the column has no drextracted, and one of the shared
# database has NULL in its older rows.
drextracted = "drextracted" if "drextracted" in db.columns(branch) else "NULL"
rows[branch][libname] = cursor.execute("SELECT model,finalphase,%s,%s FROM %s WHERE libname=? AND date=? AND finalphase>=0"
% (",".join(fields), drextracted, db.quote(branch)), (libname,v[0])).fetchall()
for r in rows[branch][libname]:
libs.setdefault(libname, set()).add(r[0])

Expand All @@ -100,40 +108,51 @@ def counts(branch, lib, view):
selected = [r for r in rows[branch].get(lib, []) if inView(view, r[0], invalid)]
vs = [sum(1 for r in selected if r[1] >= i) for i in range(0,8)]
sums = [sum(r[2+i] or 0 for r in selected) for i in range(0,len(fields))]
return (vs, sums)
return (vs, sums, sum(1 for r in selected if extracted(r)))

def extracted(row):
"""Whether the data reconciliation extracted its model from the model of this row.

A run from before that was recorded says so by getting through the back end,
which the extraction is part of.
"""
return row[1] >= 2 if row[-1] is None else row[-1] == 1

totals = {}
for (view, _) in VIEWS:
totals[view] = {}
for branch in branches:
t = {"simulate": 0, "verify": 0, "total": 0, "exectime": 0.0, "simtime": 0.0}
for lib in libs:
(vs, sums) = counts(branch, lib, view)
(vs, sums, _) = counts(branch, lib, view)
t["simulate"] += vs[6]
t["verify"] += vs[7]
t["total"] += vs[0]
t["exectime"] += sums[0]
t["simtime"] += sums[7]
totals[view][branch] = t

def countsTable(caption, rows):
return '<table class="counts"><caption>%s</caption>\n%s%s</table>\n' % (caption, entryhead, "".join(rows))
def countsTable(caption, head, rows):
return '<table class="counts"><caption>%s</caption>\n%s%s</table>\n' % (caption, head, "".join(rows))

def libraryTables(lib, view):
phases = []
times = []
old_vs = None
for branch in branches:
(vs, sums) = counts(branch, lib, view)
(vs, sums, numExtracted) = counts(branch, lib, view)
# In the order of the columns: the total, the phases and, before the
# simulation, the extraction of a data reconciliation library.
vs = [vs[0]] + vs[0:6] + ([numExtracted] if dataReconciliation else []) + vs[6:]
link = '<td><a href="%s/%s/%s.html">%s</a></td>' % (branch,lib,lib,branch)
phases.append("<tr>%s%s</tr>\n" % (link, "".join('<td%s>%s</td>' % (' class="warning"' if old_vs and old_vs[i]>vs[i] else (' class="better"' if old_vs and old_vs[i]<vs[i] else ""), vs[i])
for i in [0]+list(range(0,len(vs))))))
for i in range(0,len(vs)))))
times.append("<tr>%s%s</tr>\n" % (link, "".join("<td>%s</td>" % friendlyStr(s) for s in sums)))
if old_vs:
old_vs = [max(vs[i], old_vs[i]) for i in range(0, len(vs))]
else:
old_vs = vs
return countsTable("Models that completed each phase", phases) + countsTable("Time spent in each phase", times)
return countsTable("Models that completed each phase", phasesHead, phases) + countsTable("Time spent in each phase", timesHead, times)

def viewSwitch():
return '<div class="switch" role="group" aria-label="Invalid models">%s</div>' % "".join(
Expand Down
17 changes: 15 additions & 2 deletions resultsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
("maxrss", "bigint"),
# 1 for a model that omc only translates with --warnNonStandardModelica
("invalid", "int"),
# 1 for a model the data reconciliation extracted its model from
("drextracted", "int"),
]
SQLITE_TYPES = {"bigint": "integer", "int": "integer", "real": "real", "text": "text"}
POSTGRES_TYPES = {"bigint": "bigint", "int": "integer", "real": "double precision", "text": "text"}
Expand Down Expand Up @@ -313,20 +315,22 @@ def createTables(self, branch):
self.addLibversionHost(cursor)
elif user_version == 3:
self.addLibversionHost(cursor)
elif user_version not in (4, 5, 6):
elif user_version not in (4, 5, 6, 7):
raise SystemExit("Unknown schema user_version=%d" % user_version)
if 0 < user_version < 5:
self.addMaxrss(cursor)
if 0 < user_version < 6:
self.addInvalid(cursor)
if 0 < user_version < 7:
self.addDrExtracted(cursor)

cols = ", ".join("%s %s NOT NULL" % (c, SQLITE_TYPES[t]) for c, t in BRANCH_COLUMNS)
cursor.execute("CREATE TABLE if not exists %s (%s)" % (self.quote(branch), cols))
# The indexes only slow the run's inserts down; the report scripts add them back.
cursor.execute("DROP INDEX IF EXISTS [idx_%s_date]" % branch)
cursor.execute("DROP INDEX IF EXISTS idx_omcversion_date")
cursor.execute("DROP INDEX IF EXISTS idx_libversion_date")
self.setUserVersion(6)
self.setUserVersion(7)

def addMaxrss(self, cursor):
"""Add maxrss to every result table that predates it; older rows read 0."""
Expand All @@ -342,6 +346,13 @@ def addInvalid(self, cursor):
if "finalphase" in have and "invalid" not in have:
cursor.execute("ALTER TABLE %s ADD COLUMN invalid integer NOT NULL DEFAULT(0)" % self.quote(tbl))

def addDrExtracted(self, cursor):
"""Add drextracted to every result table that predates it; older rows read 0."""
for tbl in self.tables():
have = self.columns(tbl)
if "finalphase" in have and "drextracted" not in have:
cursor.execute("ALTER TABLE %s ADD COLUMN drextracted integer NOT NULL DEFAULT(0)" % self.quote(tbl))

def addLibversionHost(self, cursor):
"""Add the host columns to an existing [libversion].

Expand Down Expand Up @@ -540,6 +551,8 @@ def createTables(self, branch):
cursor.execute("ALTER TABLE %s ADD COLUMN IF NOT EXISTS maxrss bigint" % self.quote(branch))
if "invalid" not in branchColumns:
cursor.execute("ALTER TABLE %s ADD COLUMN IF NOT EXISTS invalid integer" % self.quote(branch))
if "drextracted" not in branchColumns:
cursor.execute("ALTER TABLE %s ADD COLUMN IF NOT EXISTS drextracted integer" % self.quote(branch))
indexes = [("UNIQUE INDEX", "uq_%s_%s" % (tbl, "_".join(KEYS.get(tbl, BRANCH_KEY))), tbl,
KEYS.get(tbl, BRANCH_KEY)) for tbl in ["omcversion", "libversion", branch]]
indexes.append(("INDEX", "idx_%s_libname_date" % branch, branch, ["libname", "date"]))
Expand Down
2 changes: 2 additions & 0 deletions shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def libname(library, conf):
# What the reports of a data reconciliation run call the simulation phase: the
# executable of such a run computes the reconciliation of the extracted model.
DR_SIMULATION_LABEL = "Reconciliation computation"
# The part omc does before it, in its back end: extracting the model to reconcile.
DR_EXTRACTION_LABEL = "Reconciliation extraction"

# A model the run no longer found in its library; the reports ask for >= 0.
DELETED_PHASE = -1
Expand Down
1 change: 1 addition & 0 deletions sqlite2postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
("parsing", "double precision"),
("maxrss", "bigint"),
("invalid", "integer"),
("drextracted", "integer"),
]

LOOKUP_COLUMNS = {
Expand Down
49 changes: 39 additions & 10 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,15 @@ def runnerExecTime(data, simulated):
shared_time = (data.get("exectime") or 0.0) - sum(simulatedTime(r) for r in runners)
return max(0.0, shared_time) + simulatedTime(simulated)

def drExtracted(data):
"""Whether the data reconciliation extracted its model from this one.

The results of a run that did not record it yet say so by getting through the
back end, which the extraction is part of.
"""
dr = data.get("dr") or {}
return dr["extracted"] if "extracted" in dr else bool(dr) and (data.get("phase") or 0) >= 2

def resultValues(model, libname, data, simulator=None):
"""One row of a branch table.

Expand Down Expand Up @@ -1245,7 +1254,8 @@ def resultValues(model, libname, data, simulator=None):
simulated.get("phase") or 0,
data.get("parsing") or 0.0,
data.get("maxrss") or 0,
1 if data.get("nonstandard") else 0
1 if data.get("nonstandard") else 0,
1 if drExtracted(data) else 0
)

def removedModels(resultBranch, libname, tested):
Expand All @@ -1263,7 +1273,7 @@ def removedModels(resultBranch, libname, tested):
def removedValues(model, libname):
"""One row of a branch table saying the library no longer has that model."""
return (testRunStartTimeAsEpoch, libname, model,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, shared.DELETED_PHASE, 0.0, 0, 0)
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, shared.DELETED_PHASE, 0.0, 0, 0, 0)

resultPlaceholders = ",".join("?" * len(resultsdb.BRANCH_COLUMNS))

Expand Down Expand Up @@ -1346,6 +1356,20 @@ def drLink(filename_prefix, data):
return ""
return ' (<a href="%s.dr/%s.html">dr</a>)' % (filename_prefix, os.path.basename(filename_prefix))

def drExtractionCell(conf, filename_prefix, data):
"""The Reconciliation extraction cell of a model, linking the extracted model."""
if not conf.get("dataReconciliation"):
return ""
if drExtracted(data):
extractedModel = os.path.basename(filename_prefix) + "_Reconciled_tmp.mo"
if extractedModel in ((data.get("dr") or {}).get("files") or []):
return '<td bgcolor="#00FF00"><a href="%s.dr/%s">extracted</a></td>' % (filename_prefix, extractedModel)
return '<td bgcolor="#00FF00">extracted</td>'
# The extraction runs in the back end, which a model reaches with its front end.
if (data.get("phase") or 0) >= 1:
return '<td bgcolor="#FFCC66">failed</td>'
return '<td bgcolor="#FFCC66">&nbsp;</td>'

def drCell(conf, data):
"""The Reconciliation result cell of a model, for the libraries tested with it."""
if not conf.get("dataReconciliation"):
Expand All @@ -1358,11 +1382,13 @@ def drCell(conf, data):
return '<td bgcolor="#FFCC66">&nbsp;</td>'

def drSummary(conf, stats):
"""The header cell and the count of reconciled models for the library summary."""
"""The header cells and the counts of extracted and of reconciled models for the library summary."""
if not conf.get("dataReconciliation"):
return ("", "", "")
n = sum(1 for s in stats if (s[3].get("dr") or {}).get("reconciled"))
return ("<th>Reconciliation result</th>", '<td bgcolor="%s">%d</td>' % ("#00FF00" if n == len(stats) else "#FFCC66", n),
return ("", "", "", "", "")
def count(n):
return '<td bgcolor="%s">%d</td>' % ("#00FF00" if n == len(stats) else "#FFCC66", n)
return ("<th>%s</th>" % shared.DR_EXTRACTION_LABEL, count(sum(1 for s in stats if drExtracted(s[3]))),
"<th>Reconciliation result</th>", count(sum(1 for s in stats if (s[3].get("dr") or {}).get("reconciled"))),
"<th>Reconciliation result</th>")

def invalidCross(data):
Expand Down Expand Up @@ -1584,14 +1610,14 @@ def publishLibrary(libname):
errPrefix = "files/%s_%s" % (s[2],s[1])
if is_non_zero_file(errPrefix+".err"):
filesList.write("/%s.err\n" % errPrefix)
if (s[3].get("dr") or {}).get("report"):
# The report of a data reconciliation run and the pages it links.
if (s[3].get("dr") or {}).get("files"):
# The report of a data reconciliation run, the pages it links and the extracted model.
filesList.write("/%s.dr/***\n" % filename_prefix)
if (s[3].get("diff") or {}).get("vars"):
filesList.write("/%s.diff.mat\n" % filename_prefix)
filesList.write("/%s.diff.ref.mat\n" % filename_prefix)
filesList.close()
testsHTML = "\n".join(['<tr%s><td>%s%s%s%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td>%s<td bgcolor="%s">%s</td><td>%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td>%s</td></tr>\n' %
testsHTML = "\n".join(['<tr%s><td>%s%s%s%s</td><td bgcolor="%s">%s</td>%s<td bgcolor="%s">%s</td>%s<td bgcolor="%s">%s</td><td>%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td bgcolor="%s">%s</td><td>%s</td></tr>\n' %
(lambda filename_prefix, errPrefix, diff:
(
' class="invalid"' if s[3].get("nonstandard") else "",
Expand All @@ -1604,6 +1630,7 @@ def publishLibrary(libname):
"&nbsp;" if diff is None else
(("%s (%d verified)" % (timeSeconds(diff.get("time")), diff.get("numCompared"))) if s[3]["phase"]>=7 else
('%s (<a href="%s.diff.mat" data-omplot="%s.diff">%d/%d failed</a>)' % (timeSeconds(diff.get("time")), filename_prefix, filename_prefix, len(diff.get("vars")), diff.get("numCompared")))),
drExtractionCell(conf, filename_prefix, s[3]),
checkPhase(s[3]["phase"], 6),
timeSeconds(s[3].get("sim") or 0),
drCell(conf, s[3]),
Expand All @@ -1628,8 +1655,10 @@ def publishLibrary(libname):

gitReferenceFilesVersion = referenceFilesVersion(conf.get("referenceFiles"))

(drSummaryHeader, drSummaryCell, drHeader) = drSummary(conf, stats)
(drExtractionHeader, drExtractionSummary, drSummaryHeader, drSummaryCell, drHeader) = drSummary(conf, stats)
replacements = (
(u"#drExtractionHeader#", drExtractionHeader),
(u"#drExtractionSummary#", drExtractionSummary),
(u"#drSummaryHeader#", drSummaryHeader),
(u"#drSummary#", drSummaryCell),
(u"#drHeader#", drHeader),
Expand Down
20 changes: 15 additions & 5 deletions testmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def noteChildrenRss():
# files its report links: the reconciled values and the extracted model.
dataReconciliationExtraFiles = ("_Outputs.csv", "_BoundaryConditions_Outputs.csv", "_Reconciled_Sx.csv",
"_NonReconcilcedVars.txt", "_BoundaryConditions.html")
# The model the extraction wrote for the executable to reconcile.
dataReconciliationExtractedModel = "_Reconciled_tmp.mo"
hrefRe = re.compile(r'<a\s+href\s*=\s*"?([^"\s>]+)"?', re.I)

def collectDataReconciliation():
Expand All @@ -176,15 +178,23 @@ def collectDataReconciliation():
the executable and linked relative to it, so they are copied together into a
directory of their own and keep working there. The links are read from the
report rather than listed here, so that whatever the runtime adds comes along.

The extraction is the part of the reconciliation that omc does: it succeeded
if it wrote the model it extracted, which is the last thing it does and what
the executable then reconciles. A model can have that file and no report,
when omc fails later in the back end.
"""
prefix = conf["fileName"]
report = "%s.html" % prefix
if not os.path.exists(report):
execstat["dr"] = {"report": False, "reconciled": False}
extractedModel = prefix + dataReconciliationExtractedModel
extracted = os.path.exists(extractedModel)
hasReport = os.path.exists(report)
if not (hasReport or extracted):
execstat["dr"] = {"report": False, "reconciled": False, "extracted": False}
return
files = {report, "Reconciled_%s.mo" % prefix.replace(".", "_")}
files = {report, extractedModel, "Reconciled_%s.mo" % prefix.replace(".", "_")}
files.update(prefix + suffix for suffix in dataReconciliationExtraFiles)
pending = [report]
pending = [report] if hasReport else []
while pending:
page = pending.pop()
with open(page, errors="replace") as fp:
Expand All @@ -208,7 +218,7 @@ def collectDataReconciliation():
if log in files and log not in copied and os.path.isfile(simFile):
shutil.copy(simFile, os.path.join(dest, log))
copied.append(log)
execstat["dr"] = {"report": True, "reconciled": os.path.exists(prefix + "_Outputs.csv"), "files": copied}
execstat["dr"] = {"report": hasReport, "reconciled": os.path.exists(prefix + "_Outputs.csv"), "extracted": extracted, "files": copied}

def writeResult():
noteChildrenRss()
Expand Down
Loading