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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The user-visible changes of canoP, by version (see `CONTRIBUTING.md` for the ver
installations start in English; studios set up before keep French.
- Tutorial of canoP studio in the documentation: the build, a run of the blast example, and a
convergence campaign with a new initial condition in Python and its analysis.
- canoP studio: `analyse()` of the `analysis.py` of a campaign receives the full id of each run (its
directory is `workspace/<id>/`), no longer its first 8 characters.
- canoP studio: the `# [canoP studio]` version lines at the top of the input file of a run are in
English, whatever the language of the studio.
- canoP studio: the example of the parameters to vary in New campaign uses the current keys
(`simulation.cfl`, `amr.max_refine`).

## 0.1.0 - 2026-11-27

Expand Down
14 changes: 7 additions & 7 deletions docs/tutorial/campaign.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ template when the campaign is created. Replace that file with the analysis of th
The studio calls three functions of this file, and loads it again as soon as it is saved:

- `analyse(points, x, y)` receives the points of the graph, `[(x, y, run), ...]` for the finished
runs, where `run` is the start of the id of the run (8 characters, as in the table), and returns a
result made of numbers, strings, lists and dictionaries, which the page keeps as `an_result`. Here
it does not use x and y: for each run it finds its directory (`_run_dir`), reads its last output
(`workspace/<id>/sine_iter*.xmf`, with the XDMF reader of VTK), compares the density with the exact
solution, the initial wave moved by (vx, vy) t, and computes the L1 error and the observed order
between two successive levels, log(e<sub>coarse</sub> / e<sub>fine</sub>) / log(n<sub>fine</sub> /
n<sub>coarse</sub>).
runs, where `run` is the id of the run (its directory is `workspace/<run>/`; the table shows its
first 8 characters), and returns a result made of numbers, strings, lists and dictionaries, which
the page keeps as `an_result`. Here it does not use x and y: for each run it finds its directory
(`_run_dir`), reads its last output (`workspace/<id>/sine_iter*.xmf`, with the XDMF reader of
VTK), compares the density with the exact solution, the initial wave moved by (vx, vy) t, and
computes the L1 error and the observed order between two successive levels, log(e<sub>coarse</sub>
/ e<sub>fine</sub>) / log(n<sub>fine</sub> / n<sub>coarse</sub>).
- `draw(ax, points, result, x, y)` may add to the matplotlib graph of the tab (nothing here).
- `panel(app)` builds the panel with the widgets of trame and Vuetify (`app.v3`, `app.html`), bound
to `an_result`: the log-log plot of the error, drawn as an image by `analyse`, and the table of the
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/files/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def value(name, default):


def _run_dir(run):
"""Directory of a run, from the start of its id (the studio gives its first 8 characters)."""
"""Directory of a run, from its id or the start of it (canoP studio 0.1.0 gives its first 8 characters)."""
found = glob.glob(os.path.join(HERE, "workspace", glob.escape(run) + "*"))
return found[0] if len(found) == 1 else None

Expand Down
6 changes: 4 additions & 2 deletions tools/trame/campaign_template/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

The studio passes the points of the graph: the chosen metric (y, from the
signac documents job.doc["metrics"]) against the chosen parameter (x), one
point per run with metrics, sorted by x: [(x, y, run id), ...].
point per run with metrics, sorted by x: [(x, y, run id), ...]. The run id is the
id of the signac job: the run is in workspace/<run id>/ (the table shows its
first 8 characters).

analyse(points, x, y) -> result (any JSON data), kept in state.an_result
draw(ax, points, result, x, y) -> extra drawing on the matplotlib axes of the graph
Expand All @@ -27,7 +29,7 @@

def analyse(points, x, y):
"""Return the values shown in the panel; add here what this campaign needs (convergence, fits...)."""
return {"lines": [{"x": "%g" % px, "y": "%.6g" % py, "run": rid} for px, py, rid in points]}
return {"lines": [{"x": "%g" % px, "y": "%.6g" % py, "run": rid[:8]} for px, py, rid in points]}


def draw(ax, points, result, x, y):
Expand Down
4 changes: 2 additions & 2 deletions tools/trame/canop_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def collect(name):
for r in info["runs"]:
values = dict(r["metrics"] or {})
values["elapsed_s"] = r.get("elapsed_s")
rows.append({"id": r["id"], "state": r["state"], "params": r["params"],
rows.append({"id": r.get("job_id") or r["id"], "state": r["state"], "params": r["params"],
"metrics": {k: _number(values.get(k)) for k in metrics}})
return params, metrics, rows

Expand Down Expand Up @@ -200,7 +200,7 @@ def _on_tab(main_tab, **_):


def _points(rows):
"""Points (x, y, run id) of the graph, sorted by x."""
"""Points (x, y, run id) of the graph, sorted by x: the full id of the signac job (workspace/<id>/)."""
state = app.state
pts = []
for r in rows:
Expand Down
2 changes: 1 addition & 1 deletion tools/trame/canop_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def _obj(props=None, required=None):
"échoué), outputs, Slurm job, metrics of the finished runs (final time, Mcell-updates/s, *.npy diagnostics).",
_obj({"name": {"type": "string"}}, ["name"]), t_campaign_status),
("create_campaign", "Make a campaign: a base ini ('editor', an example path from list_examples, or an "
"absolute path) and a sweep, cartesian product of the values, e.g. {'amr.level_max': [4, 5, 6]}. "
"absolute path) and a sweep, cartesian product of the values, e.g. {'amr.max_refine': [5, 6, 7]}. "
"Execution settings may vary too, keys launch.nprocs, launch.omp_threads, launch.nodes, launch.time "
"(Slurm time), launch.partition (not written in the ini). The runs are prepared, not submitted. More runs "
"than the limit of the Execution panel needs confirmed_by_user=true.",
Expand Down
32 changes: 21 additions & 11 deletions tools/trame/canop_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ def summary(name, with_runs=True):
"sweep": {".".join(n): list(v) for n, v in _plain(proj.doc.get("sweep", []))}, "n_runs": len(rows),
"states": counts, "repository": repo_info(proj.path)}
if with_runs:
out["runs"] = [{"id": r["short"], "params": dict(zip(columns, r["values"])), "state": r["state"],
out["runs"] = [{"id": r["short"], "job_id": r["id"], "params": dict(zip(columns, r["values"])),
"state": r["state"],
"n_outputs": r["n_outputs"], "t_last": r["t"], "slurm_job": r["slurm_id"],
"elapsed_s": r["elapsed_s"],
"physics_commit": (_plain(proj.open_job(id=r["id"]).doc.get("physics")) or {}).get("short", ""),
Expand Down Expand Up @@ -1268,22 +1269,31 @@ def exe_reads_physics_dir(exe):
return False


# origin of the version of canoP (canop_version) in the version lines, which are always in English
_SOURCE_EN = {"compilation du studio": "build of the studio",
"sources au lancement (compilation hors du studio)": "sources at launch (built outside the studio)"}


def version_lines(campaign, canop, physics):
"""Comment lines at the top of the ini of a run: the versions of its launch, to reproduce it."""
"""Comment lines at the top of the ini of a run: the versions of its launch, to reproduce it.

They are in English whatever the language of the studio: the content of the files does not depend on it.
"""
canop = canop or {}
subs = ", ".join("%s %s" % (os.path.basename(s["path"]), s.get("commit", "")) for s in canop.get("submodules", []))
# changes to the physics of the canoP sources do not concern the run
mods = [f for f in canop.get("modified", []) if not f.startswith(PHYSICS + "/")]
lines = ["lancé le %s (lignes réécrites à chaque lancement)" % time.strftime("%Y-%m-%d %H:%M:%S"),
"canoP %s (%s, %s)" % (canop.get("commit") or "inconnu", canop.get("branch") or "?",
canop.get("source") or "")]
source = canop.get("source") or ""
lines = ["launched on %s (lines rewritten at each launch)" % time.strftime("%Y-%m-%d %H:%M:%S"),
"canoP %s (%s, %s)" % (canop.get("commit") or "unknown", canop.get("branch") or "?",
_SOURCE_EN.get(source, source))]
if subs:
lines.append(" sous-modules : %s" % subs)
lines.append(" submodules: %s" % subs)
if mods:
lines.append(" + %d fichier(s) modifié(s) non commité(s) : %s" % (len(mods), _files_text(mods)))
lines += ["physique %s du dépôt git de la campagne %s" % (physics, campaign),
"reproduire : canoP compilé à ce commit, la campagne à ce commit de la physique (README.md "
"de la campagne)"]
lines.append(" + %d modified file(s) not committed: %s" % (len(mods), _files_text(mods)))
lines += ["physics %s of the git repository of the campaign %s" % (physics, campaign),
"reproduce: canoP built at this commit, the campaign at this commit of the physics (README.md "
"of the campaign)"]
return ["%s %s" % (VERSION_MARK, line) for line in lines]


Expand Down Expand Up @@ -2320,7 +2330,7 @@ def campaign_tab():
v3.VTextField(v_model=("camp_new_name",), label=tr("Nom (lettres, chiffres, - et _)"),
density="compact", classes="mb-3")
v3.VTextarea(v_model=("camp_new_sweep",), label=tr("Paramètres à faire varier"), rows=5,
classes="mono", placeholder="hydro.cfl = 0.4, 0.6, 0.8\namr.level_max = 4, 5",
classes="mono", placeholder="simulation.cfl = 0.4, 0.6, 0.8\namr.max_refine = 5, 6",
persistent_placeholder=True,
hint=tr("une ligne par paramètre : section.clé = v1, v2, … (produit cartésien)"),
persistent_hint=True)
Expand Down
Loading