pypi sbmlsim 0.64.0

one hour ago

Release notes for sbmlsim 0.64.0

sbmlsim

This is a breaking release. Live figures derive from equilibrated, time shifted and scanned experiments, so 47 of the 52 study figures of the HCTZ model of pkdb_models are live figures; at the defaults of its knobs a live figure is still the static figure bitwise, and the recipe of a bundle reproduces the service bitwise (#814). The contracts move to livefigure/2 and panelbundle/3, the panel annotation to the namespace https://sbmlsim.org/ns/panel/2, and the floor to sbmlsim-core 0.62.0. Panels take 16 knobs, a colour map of the renderer, a selection of a missing value and name declared units as declared (#813); a rule can be drawn over the data (Rule.above, #812); the migration of a fit record keeps the text of what it does not change (#811). The web app of a model vendors sbmlsim-web 0.11.0. See Migration for what a model package does.

Breaking

  • Requires sbmlsim-core>=0.62.0 (from 0.58.0). 0.59.0 is the panel endpoint of panelbundle/3 and livefigure/2, and fitproblem/1 without variable_step_size (sbmlsim-core#264). 0.60.0 draws the error bars of a curve below its markers (sbmlsim-core#268). 0.61.0 wraps titles and legends into their width (sbmlsim-core#272). 0.62.0 fixes the root finding which stalled a grid with a change, e.g. Q_pump=0 (sbmlsim-core#277: the secant step of the vendored SUNDIALS and guards with the flag -1001). The SVG and PNG of figures with error bars or long titles and legends therefore change: the outputs of the documentation were drawn again, and a model package which compares images (e.g. verify png) sees differences.
  • livefigure/2, livefigure/1 is refused. LiveBinding.simulation may be null; the new points are the keys of the simulations of a curve of one point each and at the time every point is read at, in the time of the model with the shift. The LiveElementPayload of an answer has simulation: null, points, and x values which may be null. Simulations carry steady_state and time_shift. A renderer needs sbmlsim-web 0.11.0 or newer.
  • panelbundle/3, which an endpoint of panelbundle/2 refuses:
    • Every run carries steady_state (null or {absolute_tolerance, relative_tolerance, max_time}) and x_shift, and the x of an exact output includes the shift.
    • The bindings of points.
    • One SBML and one compiled model per variant (models/<variant>/model.xml, which every model key of the variant names as sbml and compiled, shared by variants of one SBML). Derived targets are selected by the parameter panel_derived in the preinit of a run.
    • Exported bundles (--export) and the web apps of model packages (<name>_app.html, written by the factory) must be written again.
  • The panel annotation is the namespace https://sbmlsim.org/ns/panel/2 (with <steadyState>, timeShift and missing="true"). An annotation of panel/1 is refused with a problem which says to run the factory of the model again, and the factory replaces it. The reader is strict: an unknown element or attribute of the namespace is a problem of its panel. An sbmlsim 0.63 or earlier finds no panels in a panel/2 annotation, instead of drawing curves without the steady state or the shift.
  • fitproblem/1 without variable_step_size. document_settings no longer writes it, and sbmlsim-core 0.59 and newer refuse it. This only affects a document built by hand; stored fit records were migrated in 0.63 already.
  • Spec hashes change. Every spec_hash of a simulation, map and live figure answer includes the versions of sbmlsim and sbmlsim-core (VERSIONS of sbmlsim.serve.app), since GET /api/sim/{hash} is served as immutable, so the hashes change with every release of either. An old GET /api/sim/{hash} link answers 404. The spec_hash of the run layer is unchanged.
  • Payloads change within the kept versions:
    • panel/1 and mappanel/1: simulation always carries steady_state (null) and time_shift (0.0), and limits.end is 1000000.0, limits.knobs 16.
    • app/1: information_figure (a path in the declaration, a data:image/svg+xml;base64, URL or null in the answer of /app); the head of a live figure carries columns, its plot columns, and the head of a panel and a map columns: null.
    • The strict readers of sbmlsim 0.63 refuse these payloads.
  • Project.app, panels, variant_panels, maps and live_figures may be references "module:attribute". Code which reads these fields directly gets the reference string; use load_app(), load_panels(), load_variant_panels(), load_maps() and load_live_figures().
  • The variant of a live figure: a variant named by SimulationExperiment.variant_of must be the file of the model of the task, else a ContractError; it used to bind silently. The BloodPressure figures of HCTZ are refused until pkdb_models declares the fluid variant.

Migration

  • Run the factory of every model package again, so its SBML carries the annotation panel/2 and its web app panelbundle/3 and sbmlsim-web 0.11.0. The committed SBML of pkdb_models (apixaban, glimepiride and hctz, e.g. apixaban_body_flat.xml, apixaban_body_female_flat.xml, glimepiride_body_flat.xml, hctz_body_flat.xml) carries panel/1 and has no panels until its factory runs again.
  • Write the browser exports again (python -m sbmlsim.serve --export, the committed exports of pkpdsim and pkdb_models): they are panelbundle/2 and stale. Panels which declare a reordered unit or a unit id of the model also name their units differently now (see below).
  • Read the declarations of a project with Project.load_* (load_app(), load_panels(), load_variant_panels(), load_maps(), load_live_figures()) instead of project.app, project.panels, ... wherever they may hold references or callables (e.g. tests/models/test_panels.py of pkdb_models, which reads project.app and keeps working only while the project holds an object).
  • Compare images again after the floor: figures with error bars or long titles and legends are drawn differently.

Live figures of equilibrated, shifted and scanned experiments

  • Steady state (PanelSteadyState, PanelSimulation.steady_state, the <steadyState> child of <simulation>): every point of a panel or a live figure starts from the steady state of its condition, so a knob of the condition equilibrates again by construction (one request per point, no state kept between requests). A condition without a steady state is a failed point. The derivation maps the steady state of a plan to it; a steady state with a pre-initialization of its own, or one after the end, is refused.
  • Time shift (PanelSimulation.time_shift, timeShift): added to the time of the result in the time unit of the model, before the conversion into x_unit.
  • Curves of one point per simulation (LiveBinding.points, LiveBinding.at): a line over one dimension of values of a scan (x a coordinate D.target or a formula) whose y is a selection or a Formula whose reductions are all at(e, t) at a row. A point reads the last row whose time equals at, and a failed point is null. An at between rows, max/min/mean, PK parameters and curves at two times are refused.
  • A knob of a temperature in °C on a live figure converts as its target holds it (knob_conversion, its offset).
  • MAX_END rises from 10000 to 1e6, also the bound of -start.
  • Measured on HCTZ: a knob move is 12 to 155 ms in the browser and 0.06 to 0.13 s in the service, each simulation equilibrating again, so no steady state is cached.
  • Demo: examples/panels/equilibrium.py, a panel and four live figures. scripts/panel_fixture.py writes the fixtures of the panel endpoint of sbmlsim-core (tests/data/panel_fixtures/, docs/development.md).

Panels, apps and the service

  • 16 knobs (#813): MAX_KNOBS is 16 (was 8), for a declaration (panel, map, live figure, the scans of a page) and a request alike; MAX_GRID (64) still bounds the work.
  • A colour map the renderer draws: ColorScaleSpec.name is checked against COLOR_SCALES of sbmlsim-core when the scale is declared; the error names every valid name and suggests the lower-case one (Blues to blues). Before, a wrong name was written into the SBML and the bundle and the page could not draw the map.
  • A selection of a missing value: a None in PanelData.sel (JSON null, <select column="..." missing="true"/> in the annotation) selects the rows whose column is missing (NaN, None, pandas.NA, in a column of any dtype), and the text "nan" matches nothing. sbmlsim.data.matching_rows does it, which Data.get_data(sel=) uses as well, which matched None in a string column only.
  • Declared units are named as declared: a unit which a curve, a map readout, an x_unit or a series declares is named by its declaration in the short form of pint and the order of the declaration, e.g. mM stays mM (was mmol/l when mM is also a unit id of the model), μmol/min/g stays μmol/min/g, uM becomes μM. Within one panel and one map every unit equal to a declared one takes the text of the first declaration (declared_unit, panel_curve_units of serve/runner.py).
  • App.information_figure: an SVG below the root of the project, at most 1 MiB (MAX_INFORMATION_FIGURE_BYTES), read and checked when the service starts and served as an image data URL. LiveFigure.columns and PanelSummary.columns size a card before its figure is drawn.
  • References to callables: a reference of app, panels, variant_panels, maps or live_figures may name a callable which takes the Project it is loaded for. In a rebuild (create_models(out)) that is the project of the rebuild root, so a declaration built from a factory output reads the files the factory just wrote. A callable which raises is a ValueError naming the field and the reference, which check_model and the service report.
  • python -m sbmlsim.serve --timeout SECONDS: the wall clock deadline of every simulation of the service, 30 s by default (the deadline of the pool of a page), 0 for none; without the option a SBMLSIM_CORE_TIMEOUT_MS of the environment is kept. The deadline belongs to the runtime of the engine, one per process, so it also bounds the derivation of the live figures and the jobs. A point past the deadline is a failed point (null, listed in failed, still a 200) whose message names the deadline, and its thread is freed. An answer with a point the deadline may have failed is kept in no cache of the service, while a failure of the model stays cached. --export sets no deadline, and the library and the run layer keep none.
  • The web app of a model vendors sbmlsim-web 0.11.0: livefigure/2, the dashboard of a page and the information figure.

The figure model

  • A rule over the data (#812): Rule(above=True), Plot.rule(..., above=True) and Figure.rule(..., above=True) draw the rule at RULE_ABOVE_Z (1.0) over every line, marker and band median of its plot, e.g. the medium change of the machine perfusion figures of pkdb_models. The default keeps RULE_Z (-0.25), so existing figures are unchanged.

Bug fixes

  • The migration of a fit record keeps the text of what it does not change (#811). python -m sbmlsim.run migrate of 0.63.0 wrote a changed record out again with json.dumps(indent=...) and expanded the arrays a record held compactly (a record of pkdb_models grew from 636 to 184526 lines). It now writes again only what it changes: an object member by member, an array of the same length element by element, a value on one line stays on one line, the keys keep their order with the added ones after them. A rewritten text which does not read back as the migrated record is refused with a MigrationError before anything is written; a second migration changes nothing, byte for byte.
  • The domains of a model are no uncertainties of a fit: the distrib uncertainties named domain (sbmlsim.domains) no longer count as uncertainties of a fit (model_distributions), so the band of a model with domains names its fit again (the bundle carried uncertainty.fit == "").
  • A grid over a knob whose id equals the id of its target no longer fails; the dimension of a grid is panel-grid.
  • The web app of a rebuild (create_models(out)) carries the map panels and the live figures, and reads the information figure from the rebuild when the factory writes it.
  • The web app embeds the answers of the default variant once (31 % smaller for a model with derived targets in several variants).
  • The message of a point which a wall clock deadline interrupted names the deadline.
  • A bound of a live figure (e.g. MAX_LIVE_SIMULATIONS) is a ContractError naming the figure, the experiment and the model; a model file which is no variant gets a message which says to declare it as one.
  • check_model reads the information figure.

Documentation

  • docs/serve.md: the steady state, the time shift, curves of points, livefigure/2, panelbundle/3, the annotation panel/2, --timeout and the caches; docs/project.md: references and callables of the declarations and load_*; docs/plotting.md: Rule.above; docs/fitting.md: the layout a migrated record keeps; docs/development.md: the fixtures of the panel endpoint.

Don't miss a new sbmlsim release

NewReleases is sending notifications on new releases.