From 0e1aa36dd1dbd397019e13d3977171ec11bdd289 Mon Sep 17 00:00:00 2001 From: "pascal.tremblin" Date: Sun, 29 Nov 2026 12:13:13 +0100 Subject: [PATCH] studio: full run ids for analyse(), version lines in English, current keys in examples - The Analysis tab passes analyse() the full id of each run (the signac job id, whose directory is workspace//) instead of its first 8 characters, which did not name any directory. summary() gives it as job_id next to the short id (MCP tools unchanged). The template of analysis.py shows the first 8 characters, as the table. - The "# [canoP studio]" version lines at the top of the input file of a run are in English whatever the language of the studio (file contents do not depend on it); the origin of the version of canoP stays in French in the job documents and is written in English in the lines. - New campaign and the create_campaign MCP tool: examples with simulation.cfl and amr.max_refine instead of the old hydro.cfl and amr.level_max. - Tutorial: analyse() receives the id of the run; its analysis.py still accepts the start of it. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 +++++ docs/tutorial/campaign.md | 14 +++++----- docs/tutorial/files/analysis.py | 2 +- tools/trame/campaign_template/analysis.py | 6 +++-- tools/trame/canop_analysis.py | 4 +-- tools/trame/canop_assistant.py | 2 +- tools/trame/canop_campaign.py | 32 +++++++++++++++-------- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8acd0ad..ba56f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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//`), 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 diff --git a/docs/tutorial/campaign.md b/docs/tutorial/campaign.md index 96c4dae..18b7f07 100644 --- a/docs/tutorial/campaign.md +++ b/docs/tutorial/campaign.md @@ -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//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(ecoarse / efine) / log(nfine / - ncoarse). + runs, where `run` is the id of the run (its directory is `workspace//`; 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//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(ecoarse + / efine) / log(nfine / ncoarse). - `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 diff --git a/docs/tutorial/files/analysis.py b/docs/tutorial/files/analysis.py index 7892cea..0485526 100644 --- a/docs/tutorial/files/analysis.py +++ b/docs/tutorial/files/analysis.py @@ -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 diff --git a/tools/trame/campaign_template/analysis.py b/tools/trame/campaign_template/analysis.py index d46f41d..c0b2792 100644 --- a/tools/trame/campaign_template/analysis.py +++ b/tools/trame/campaign_template/analysis.py @@ -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// (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 @@ -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): diff --git a/tools/trame/canop_analysis.py b/tools/trame/canop_analysis.py index 37ca224..befad37 100644 --- a/tools/trame/canop_analysis.py +++ b/tools/trame/canop_analysis.py @@ -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 @@ -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//).""" state = app.state pts = [] for r in rows: diff --git a/tools/trame/canop_assistant.py b/tools/trame/canop_assistant.py index f2bb90a..a604835 100644 --- a/tools/trame/canop_assistant.py +++ b/tools/trame/canop_assistant.py @@ -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.", diff --git a/tools/trame/canop_campaign.py b/tools/trame/canop_campaign.py index 16ace87..10f6ff9 100644 --- a/tools/trame/canop_campaign.py +++ b/tools/trame/canop_campaign.py @@ -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", ""), @@ -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] @@ -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)