Session#

MemberKindWhat it is
bestpropertyThe run the best trial was promoted to, read from its directory.
best_by_casepropertyThe run of the best trial in each case, None where it is missing.
best_costpropertyThe cost of the best trial, None without one.
best_parameterspropertyThe one parameter set of the best trial, empty without one.
casespropertyThe ids of the calibrated cases.
configpropertyThe frozen configuration the session ran, config.toml, as a mapping.
descriptorpropertyThe descriptor, session.json, read once.
dirpropertyThe session directory.
namepropertyName of the session directory, <case>[_vN].
phasespropertyThe phases of a staged search, by rank; empty for a single search.
sitespropertyThe sites of the calibrated cases.
statuspropertyWhere the search stands: running, completed, partial, aborted or failed.
trialspropertyEvery trial of the session, one row per trial and case.
windowspropertyThe periods of the search whose best the session holds, by name.
figuremethodDraw the registered session figure *name* of this session.
of_runmethodReturn the session that promoted run, or None when no session did.
profilemethodWhere the time of the search went, by step and by reused (PROFILE_COLUMNS).
showmethodRead one thing of this session: table, profile, figure or report.
tablemethodReturn the table *name* of this session: trials or profile.
class Session(session_dir, *, read_config=None, render=None)[source]#

One calibration session, read from its directory.

Parameters:
  • session_dir (str | Path) – The session directory, sessions/<case>[_vN].

  • read_config (Callable[[Mapping[str, Any]], BaseModel] | None) – The function that validates a sealed configuration snapshot, passed to the runs the session opens. Without one, run.hydromodpy_config is refused. A session opened by hmp.open or by a Project carries it.

  • render (Renderer | None) – The function that draws a figure or writes the report of the session. Without one, figure is refused.

Raises:

FileNotFoundError – If the directory holds no session.json.

Examples

>>> import hydromodpy as hmp
>>> proj = hmp.open("~/ws/projects/bretagne")
>>> session = proj.sessions["J0014010-calage"]
>>> session.trials.sort_values("cost").head()
>>> session.best.label()
classmethod of_run(run)[source]#

Return the session that promoted run, or None when no session did.

The session is found from the lineage of the run (its session_id) among the sessions/*/ of its project, and a kept trial under sessions/<case>/trials/<n> is in its own session. A session figure asked for on a run draws this session. The session opened here keeps the read_config of the run, so its best run validates its configuration as the run does.

figure(
name=None,
*,
request=None,
draw=None,
save=None,
dpi=None,
theme=None,
engine=None,
time=None,
data=False,
**options,
)[source]#

Draw the registered session figure name of this session.

The arguments are those of hydromodpy.results.run.view.Run.figure(). A figure of another subject refuses the session.

Raises:

hydromodpy.core.exceptions.CommandUsageError – If the session was not opened by hydromodpy.open or a project.

profile()[source]#

Where the time of the search went, by step and by reused (PROFILE_COLUMNS).

It adds the profile lines of every trial the journal holds, read from the last line of each trial. lines counts the lines added, duration_s sums their time and max_rss_mb is the peak of their memory. A trial read from the cost cache or written by a pre-release has no profile and adds nothing.

show(what, **options)[source]#

Read one thing of this session: table, profile, figure or report.

table(name)[source]#

Return the table name of this session: trials or profile.

trials is trials and profile is profile(). Any other name is refused with those two.

property best: Run | None[source]#

The run the best trial was promoted to, read from its directory.

The descriptor names the run of the best trial; without that hint, the run paired with the session (runs/<session name>) is taken when it carries the same id. None while no run holds the best trial, or when the search keeps no single best.

Raises:

SeveralCasesError – If the session calibrates several cases: read best_by_case.

property best_by_case: dict[str, Run | None][source]#

The run of the best trial in each case, None where it is missing.

Empty while no trial is held as best.

property best_cost: float | None[source]#

The cost of the best trial, None without one.

property best_parameters: dict[str, float][source]#

The one parameter set of the best trial, empty without one.

property cases: tuple[str, ...][source]#

The ids of the calibrated cases.

property config: dict[str, Any][source]#

The frozen configuration the session ran, config.toml, as a mapping.

Empty when the session wrote none.

property descriptor: SessionDescriptor[source]#

The descriptor, session.json, read once.

property dir: Path[source]#

The session directory.

property name: str[source]#

Name of the session directory, <case>[_vN].

property phases: list[PhaseDescriptor][source]#

The phases of a staged search, by rank; empty for a single search.

property sites: tuple[str, ...][source]#

The sites of the calibrated cases.

property status: Vocabulary object at 0x7801209d4f10>][source]#

running, completed, partial, aborted or failed.

Type:

Where the search stands

property trials: DataFrame[source]#

Every trial of the session, one row per trial and case.

The columns are TRIAL_COLUMNS, then one column per searched parameter, named as in [calibration.parameters], with the value the trial tried, empty in a phase that did not search it. A parameter named like a column of TRIAL_COLUMNS stays in parameters alone.

property windows: dict[str, PeriodWindow][source]#

The periods of the search whose best the session holds, by name.