Models#

Pydantic models for API request and response validation.

Pydantic models for the Ionworks API client.

These models use extra=”allow” to accept any fields from the API response, letting the API handle validation. Required fields are kept minimal.

class ionworks.models.CellSpecification(*, id, name, **extra_data)[source]#

Bases: BaseModel

Cell specification model - accepts any fields from the API.

The API returns nested component/material data and ratings objects. This model is permissive to allow the API to define the schema.

Parameters:
model_config = {'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: str#
name: str#
class ionworks.models.CellInstance(*, id, name, cell_specification_id, **extra_data)[source]#

Bases: BaseModel

Cell instance model - accepts any fields from the API.

Parameters:
  • id (str)

  • name (str)

  • cell_specification_id (str)

  • extra_data (Any)

model_config = {'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: str#
name: str#
cell_specification_id: str#
class ionworks.models.CellMeasurement(*, id, name, cell_instance_id, **extra_data)[source]#

Bases: BaseModel

Cell measurement model - accepts any fields from the API.

Parameters:
  • id (str)

  • name (str)

  • cell_instance_id (str)

  • extra_data (Any)

model_config = {'extra': 'allow'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: str#
name: str#
cell_instance_id: str#
class ionworks.models.CellMeasurementBundleResponse(*, measurement, steps_created, file_path)[source]#

Bases: BaseModel

Response from creating a measurement bundle.

Parameters:
measurement: CellMeasurement#
steps_created: int#
file_path: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.models.InitiateUploadResponse(*, measurement_id, signed_url, token, path)[source]#

Bases: BaseModel

Response from the initiate-upload endpoint for signed URL uploads.

Parameters:
  • measurement_id (str)

  • signed_url (str)

  • token (str)

  • path (str)

measurement_id: str#
signed_url: str#
token: str#
path: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.models.ConfirmUploadResponse(*, instance, measurement, steps_created, file_path)[source]#

Bases: BaseModel

Response from the confirm-upload endpoint after successful upload.

Parameters:
instance: CellInstance#
measurement: CellMeasurement#
steps_created: int#
file_path: str#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.models.CellMeasurementDetail(*, measurement, specification_id=None, instance_id=None, steps=None, time_series=None, cycles=None)[source]#

Bases: BaseModel

Detail model for a measurement with steps and time series.

Returns minimal data by default: foreign keys for parent objects rather than nested objects. Use the spec/instance clients to fetch parent objects if needed.

Parameters:
  • measurement (CellMeasurement)

  • specification_id (str | None)

  • instance_id (str | None)

  • steps (DataFrame | DataFrame | None)

  • time_series (DataFrame | DataFrame | None)

  • cycles (DataFrame | DataFrame | None)

model_config = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

measurement: CellMeasurement#
specification_id: str | None#
instance_id: str | None#
steps: DataFrame | DataFrame | None#
time_series: DataFrame | DataFrame | None#
cycles: DataFrame | DataFrame | None#
classmethod convert_dict_to_df(v)[source]#

Convert dictionary to DataFrame (polars or pandas based on config).

Parameters:

v (Any)

Return type:

Any

class ionworks.models.CellInstanceDetail(*, instance, specification_id, measurements)[source]#

Bases: BaseModel

Detail model for a cell instance with all measurements.

Returns a foreign key for the parent specification rather than a nested object. Use client.cell_spec.get(detail .specification_id) to fetch the full specification.

Parameters:
instance: CellInstance#
specification_id: str#
measurements: list[CellMeasurementDetail]#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.models.StepsAndCycles(*, steps, cycles)[source]#

Bases: BaseModel

Steps and cycle metrics for a measurement.

Returned by the /steps_and_cycles endpoint which fetches both in one call (cycles are derived from steps).

Parameters:
  • steps (DataFrame | DataFrame)

  • cycles (DataFrame | DataFrame)

model_config = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

steps: DataFrame | DataFrame#
cycles: DataFrame | DataFrame#
classmethod convert_dict_to_df(v)[source]#

Convert dictionary to DataFrame.

Parameters:

v (Any)

Return type:

Any