Bits & Flames Fyron bitsandflames/fyron

API Design

Fyron APIs are designed for clinical research workflows where another person should be able to inspect the inputs, assumptions, outputs, and artifacts without reading a hidden framework.

This page documents the public design conventions that new modules and functions should follow.

Core Principles

PrincipleMeaning
Explicit assumptionsClinical and statistical assumptions belong in parameter names, docstrings, tables, or manifests.
DataFrame-firstCohorts, feature tables, metrics, and summaries should usually be pandas.DataFrame objects.
Ordinary Python inputsPrefer DataFrames, arrays, dictionaries, paths, and fitted sklearn/lifelines-style objects.
Inspectable outputsReturn DataFrames, dictionaries, dataclasses, Matplotlib handles, file paths, or fitted estimators.
Optional extrasHeavy dependencies stay optional and raise clear install messages.
No hidden uploadFunctions should not contact external systems unless the user explicitly configures a client or command.

Naming Conventions

Use parameter names that describe the clinical role:

PatternUse
id_colpatient, study, series, lesion, or row identifier column
duration_col, event_colsurvival endpoints
group_col, huestratification for tables and plots
feature_cols, label_col, outcome_colML or statistics inputs
save_path, output_pathexplicit artifact destinations
random_statereproducible stochastic behavior

Avoid short generic names when a clinical name is clearer. A call with duration_col="time" and event_col="death" is easier to review than one that relies on hidden defaults.

Return Shapes

Function familyPreferred return
table builders and QC helperspandas.DataFrame
model fitting helpersdict/dataclass with fitted object, metrics, and tables
plotting helpers(fig, ax), (fig, axes), or (fig, axes, table)
file writersresolved Path or manifest table
FHIR buildersplain JSON-serializable dictionaries
audit helpersJSON-serializable dictionaries

When a computed table is useful for reviewers, return it instead of hiding it inside a figure object.

Optional Dependencies

Optional modules must fail clearly. Use messages like:

text
Install with: uv add "fyron[visualization]"

Do not import optional packages at top level unless the module is itself optional and already raises a clear install message.

Stable And Experimental APIs

Most public names that do not start with _ are treated as stable once documented on module pages or in the generated reference.

Experimental APIs must say so in their docstring and docs page. They should explain what needs validation before study use, for example segmentation label assumptions, FHIR profile assumptions, or model-comparison limitations.

During public beta releases, new workflows can be marked beta when their behavior is useful but still expected to evolve. The beta label should appear in the docs page, CLI help or README section, and release notes. Curate is treated this way because it combines a Python package entrypoint with a local Docker Compose application.

Deprecation Policy

Avoid breaking notebooks. When an API must change:

  1. Add the replacement first.
  2. Keep the old name as an alias when feasible.
  3. Document the migration path.
  4. Warn before removal.
  5. Mention the change in the changelog.

Design Checklist

Before adding a public function, confirm:

  • the module is the right home,
  • required columns or shapes are validated early,
  • output shape is documented,
  • clinical assumptions are explicit,
  • optional dependencies are guarded,
  • the example uses synthetic or de-identified data,
  • tests cover both expected use and common failure modes.