Session#
| Member | Kind | What it is |
|---|---|---|
best | property | The run the best trial was promoted to, read from its directory. |
best_by_case | property | The run of the best trial in each case, None where it is missing. |
best_cost | property | The cost of the best trial, None without one. |
best_parameters | property | The one parameter set of the best trial, empty without one. |
cases | property | The ids of the calibrated cases. |
config | property | The frozen configuration the session ran, config.toml, as a mapping. |
descriptor | property | The descriptor, session.json, read once. |
dir | property | The session directory. |
name | property | Name of the session directory, <case>[_vN]. |
phases | property | The phases of a staged search, by rank; empty for a single search. |
sites | property | The sites of the calibrated cases. |
status | property | Where the search stands: running, completed, partial, aborted or failed. |
trials | property | Every trial of the session, one row per trial and case. |
windows | property | The periods of the search whose best the session holds, by name. |
figure | method | Draw the registered session figure *name* of this session. |
of_run | method | Return the session that promoted run, or None when no session did. |
profile | method | Where the time of the search went, by step and by reused (PROFILE_COLUMNS). |
show | method | Read one thing of this session: table, profile, figure or report. |
table | method | Return 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_configis refused. A session opened byhmp.openor by aProjectcarries it.render (Renderer | None) – The function that draws a figure or writes the report of the session. Without one,
figureis 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 thesessions/*/of its project, and a kept trial undersessions/<case>/trials/<n>is in its own session. A session figure asked for on a run draws this session. The session opened here keeps theread_configof the run, so its best run validates its configuration as the run does.
-
figure(
)[source]#name=None,*,request=None,draw=None,save=None,dpi=None,theme=None,engine=None,time=None,data=False,**options,
Draw the registered
sessionfigure 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.openor 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.
linescounts the lines added,duration_ssums their time andmax_rss_mbis the peak of their memory. A trial read from the cost cache or written by a pre-release has no profile and adds nothing.
- table(name)[source]#
Return the table name of this session:
trialsorprofile.trialsistrialsandprofileisprofile(). 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.Nonewhile 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,
Nonewhere it is missing.Empty while no trial is held as best.
- property best_parameters: dict[str, float][source]#
The one parameter set of the best trial, empty without one.
- property config: dict[str, Any][source]#
The frozen configuration the session ran,
config.toml, as a mapping.Empty when the session wrote none.
- property phases: list[PhaseDescriptor][source]#
The phases of a staged search, by rank; empty for a single search.
- 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 ofTRIAL_COLUMNSstays inparametersalone.