make_update_model

specatalog.helpers.helper_functions.make_update_model(model, creation_model)[source]

Create dynamically a pydantic-class for updating based on an SQLAlchemy model.

Parameters:
  • model (TimeStampedModel) – An SQLAlchemy model of the type TimeStampedModel. Has to be of the class Molecule or Measurement (or a subclass).

  • creation_model (BaseModel) – The creation_model from models.creation_pydantic_measurements/molecules that corresponds to the class of model. E.g. model = ms.TREPR -> creation_model = cpm.TREPRModel.

Raises:

ValueError – If the model is not of the class Molecule or Measurement an error is raised.

Returns:

UpdateModel – The update-model contains all column names as optional fields with the default-value None. The value of the field can be set to any value but must be the same type as the original column type. Fields that must not be updated are excluded from the UpdateModel. No additional fields can be created when using the model.

Return type:

BaseModel