Release notes¶
v2.1.0¶
Add
semanticmodule withconceptclass to represent a semantic entity (e.g. from a controlled vocabulary) with a unique identifier.
v2.0.0¶
Merge
lakehouse_schemaintoschemato consolidate the triallakehouse_schemamodels into the mainschemamodulets_ids_core.schema.run.InstrumentStatushas been renamed tots_ids_core.schema.run.RunStatus, and it is no longer part of thets_ids_core.schema.run.Rundefinition.ts_ids_core.schema.sample.Lotclass has been removed.
Documentation is no longer packaged with
ts-ids-core. Thets-ids docscommand now opens the public documentation site at ids.tetrascience.com.
v1.1.2¶
Nest
propertiesandlabelsas object arrays in thelakehouse_schema.Sampleschema class consistent toschema.Sample.
v1.1.1¶
Fix incorrect alias and add descriptions to
set,lot,locationandcompoundfields in theSampleschema class.Fix the
primary_keyreference inFirmwarelakehouse_schema class in order to point to a systems object.
v1.1.0¶
Add description text to all field definitions.
Add modified core schema components run, sample, system and user in
ts_ids_core.lakehouse_schemato support a normalized schema standard. At this release this should be considered a beta feature subject to change.
v1.0.2¶
Fix
is_tetra_data_schema: truebeing missing fromTetraDataSchema’s JSON Schema metadata when using Pydantic 2.10 or later, caused by a change in Pydantic’s JSON Schema generation. This metadata indicates that a schema is following certain conventions. AnyTetraDataSchemacreated usingts-ids-core>=0.7.0,<=1.0.1with Pydantic>=2.10(released Nov 20th 2024) may be missing this metadata, and can be fixed by updating to this patch.
v1.0.1¶
Many Tetra Data components represent the same concepts available in Tetra’s Recommended Labels and Key Context Terms available in the TetraConnect Hub. These descriptions were updated to match their corresponding context term or label:
Project,Experiment,Run,Batch,Sample,CompoundandAssay.Deprecated the use of
Lotwhich will be removed in a future version because it is not included in Key Context Terms or Recommended Labels.Improved descriptions of the differences between a system ID, serial number and name in the
Systemcomponent.Updated dependencies to exclude Pydantic versions v2.10.0 to 2.10.2 which contain a JSON Schema generation bug.
Modified JSON Schema generation logic to fix how Enums are serialized to JSON Schema from Pydantic v2.7 onward. When an
Enumcontains some elements including at least oneNoneelement, its JSON Schema should include both the non-null element type and the"null"type to create a valid IDS. For example, theModifiercomponent includes an enum of strings like">="as well asNone, so its JSON Schema type is"type": ["string", "null"], Pydantic 2.7 started omitting"type"from the schema in this case, sots-ids-corehas been updated to restore the expected JSON Schema type for Enums.
v1.0.0¶
Release v1.0.0, no changes from v0.7.0.
v0.7.0¶
Added descriptions for multiple components in runs, systems, samples, related files and quantities (
ValueUnit) with no functional change.Created
projectmodule with recommended component usageAdded
AssayAdded
ProjectAdded
ProjectAttributes
Moved
Experimentfrom thets_ids_core.schema.experimentmodule to theprojectmodule and deleted thets_ids_core.schema.experimentmoduleChanged CLI interface by grouping all commands under the
ts-idsgroup command, see the ts-ids group page for more.The previous
import-schemaandexport-schemacommands are deprecated. It’s recommended users now call these commands withts-idspreceding the command (e.g.ts-ids export-schema [options]).
Package documentation is now distributed with the package. Review the ts-ids docs command for more.
Removed
@idsConventionVersionfromTetraDataSchemain favor of designating a schema following TetraScience standards with the schema metadatais_tetra_data_schema: true. InheritingTetraDataSchemawill automatically addis_tetra_data_schema: trueas top-level schema metadata.
v0.6.1¶
First release to external Python package index. No changes.
v0.6.0¶
Fixed issue in Python 3.8 and 3.9 where the
Literaltype was not recognized ifLiteralwas imported fromtypingduring type validation. Nowtyping.Literalandtyping_extensions.Literalare treated equivalently.Fixed a case where
UUIDForeignKeyvalidation did not run if the foreign key was inside aRequiredIdsElementfield, for example ifFoocontained a foreign key field, andBarhad a fieldfoo: Required[Foo], then foreign key validation ofFoodid not run, and now it does.Removed implicit default values for required literal fields, e.g.
field: Required[Literal["foo"]]no longer has an implicit default of"foo", instead it needs to be explicitly defined asfield: Required[Literal["foo"]] = "foo"orfield: Required[Literal["foo"]] = IdsField(default="foo"). This allows type checkers to recognize the default, which isn’t possible with implicitly defined defaults. This also makes it possible to define a required constant which does not have a default value, which is closer to the default Pydantic functionality.Changed default value of
IdsElement.model_dump_json’sby_aliasargument toTrue, which is the intended way to usets-ids-core: fields which use an alias, such asids_type: Required[Literal["foo"]] = IdsElement(default="foo", alias="@idsType")will be converted to a JSON instance as{"@idsType": "foo"}(by_alias=True) by default now, instead of{"ids_type": "foo"}(by_alias=False). This gives it the same default it has for the other schema and instance serialization methods (model_dumpandmodel_json_schema).
Component updates¶
Updated the
Samplecomponent to add a non-required fieldcompound, which is an object containing anidandnamefields - see the linked documentation for full details.Updated the
Runcomponent to add anidfield - see the linked documentation for full details.Updated the
Experimentcomponent’sidfield by renaming the variable toid_and giving it an alias ofid. This avoids clashing with the Python builtinidin code, while still appearing as"id"in JSON Schema and JSON data.
v0.5.0¶
Breaking changes¶
Pydantic v2 introduces multiple breaking changes, but the following changes cover most of what is relevant for updating programmatic IDSs:
Defining constants
Previously, constants were defined on a field using
defaultandconstlike this:field: str = IdsField(default="my-value", const=True). Now they are defined using aLiteraltype annotation like this:field: Literal["my-value"]. See Pydantic docs for more.
Defining lists of fixed length
Lists of fixed length can be defined using
conlistwhose keyword arguments changed in Pydantic v2. Previously they were defined like this:field: conlist(str, min_items=3, max_items=3). In the Pydantic v2 syntax, this changes tofield: conlist(str, min_length=3, max_length=3). See Pydantic docs for more.The above is the simplest change, but there is also a new alternative syntax which provides better IDE type checking support, see Composing types via Annotated in the pydantic docs. This is equivalent to the field above:
field: Annotated[List[str]], annotated_types.Len(3, 3)]which type checkers recognize asList[str]. Note thatconlistimplied the field’s type is aListwhereas it is explicitly stated asList[str]within theAnnotatedtype. Please see the Improvements section for an improvement in the ease of defining a constrained annotated type with a fixed length.
JSON Schema keyword
"description"changesIn Pydantic v2, descriptions for objects are no longer inherited from parent classes. This means, for example, creating a custom system class like
class MySystem(System): ...will no longer inherit the docstring fromSystemas a ‘description’ when it is exported as a JSON schema. Docstrings need to be explicitly added to each class in which you want to define adescriptionwithin the JSON schema. When updating an existing programmatic IDS using a previousts-ids-coreversion, find which descriptions need updating by taking a diff of the exported schemas after updating tov0.5.0.
The
decimal.Decimaltype was previously defined as typenumberwithin the JSON schema and serialized as a float to JSON instances. In Pydantic v2, thedecimal.DecimalJSON schema type is now{'anyOf': [{'type': 'number'}, {'type': 'string'}]}and the decimal value is serialized as a string to JSON instances. SinceanyOftypes are not compatible with the TetraScience platform, we provided twoDecimaltypes to use in replacement ofdecimal.Decimal,DecimalNumberorDecimalString. The difference between these two types are their respective JSON schemas and serialization to JSON instances.DecimalNumberwill have the JSON schema typenumberand will be serialized as a float value to JSON instances, whereasDecimalStringwill have the JSON schema typestringand will be serialized as a string value to JSON instances. Both types will be a standarddecimal.Decimalinstance when initailized in anIdsElementsubclass.Dropped support for Python 3.7. The Python version requirement is now
>=3.8,<4.
Improvements¶
The update from Pydantic v1 to v2 brings benefits introduced by Pydantic v2 and allows ts-ids-core to keep updated with Pydantic’s latest features and bugfixes.
Parts of ts-ids-core were restructured internally to make use of new Pydantic v2 features, leading to the following improvements which don’t affect how to use ts-ids-core - no code changes needed for these:
Default initialization of required constants (i.e.
Required[Literal["foo"]])As mentioned under Breaking changes above, defining constants is now done with the
Literaltype. Since required constants will always be the same value and to avoid defining the constant within theLiteraltype and as a default usingIdsField(i.e.foo: Required[Literal["bar"]] = IdsField(default="bar")), required constants will be automatically set using theLiteralvalue just as a default value would be. So, one can define the constant asfoo: Required[Literal["bar"]]and the fieldfoowill be implicitly set with the value"bar"when instantiating anIdsElementsubclass without explicitly passing a value forfoo.
For convenience in defining a fixed length
Annotatedtype (e.g.Annotated[List[str], annotated_types.Len(3, 3)]), we provided anAnnotatedtype metadata functionfixed_lengthso one can define the type asAnnotated[List[str], fixed_length(3)]. Seefixed_lengthfor more.The
Requiredtype annotation now usesAnnotatedinstead of a custom class, which means IDE type checkers can ignore it and give type hints about the underlying type, for example IDEs now recognize thatRequired[str]should have the same hints and autocompletion asstrin code (with no change to howRequiredfields are validated or exported to JSON Schema).UUIDForeignKeyandUUIDPrimaryKeywere updated to use a new Pydantic v2Annotatedsyntax which also allows IDE type checkers to recognize that they arestrunderneath all the metadata.Fields like
ids_typeinIdsSchemaare “abstract” in the sense that you have to redefine them with a specific value in any subclasses ofIdsSchema. The way abstract fields are defined was updated internally to use a new annotation,Abstract, simplifying how these fields are defined and validated.Pydantic v2 deprecated the
BaseModelmethodschema_jsonwhich serialized the model to a JSON string representation. To preserve this behavior, we provided the same method withIdsElement, so one would not need to callmodel.model_json_schema()and then convert to a json string using another package likejson.import-schemahas been updated to generate models with a Pydantic v2 syntax, and a datamodel-code-generator template has been added to make the generated models require fewer manual steps to complete the conversion to programmatic IDS. Now, theRequiredannotation is added automatically, andOptionalis only added for types which can have a value ofNone, whereas before it was also added to non-required types. See Generate programmatic IDS from JSON schema for full details of how to use this tool.
v0.4.0¶
Modified the installation instructions for the
import-schemascript to convert rarely used dependencies into optional extra dependencies. Now, to useimport-schema, its extra dependencies need to be installed viapip install "ts-ids-core[import-schema]"or similar - see the documentation. Now any timets-ids-coreis installed without needingimport-schema, installation will be faster and come with fewer dependencies.Fixed a case where
UUIDForeignKeyfields were not being validated that they correspond to an existingUUIDPrimaryKeyif the foreign key was defined in a class containing abstract fields (any field with a default value ofNotImplemented). Now all foreign keys (inherited and newly defined) are validated when any class derived fromIdsSchemaorTetraDataSchemais defined and doesn’t contain any abstract fields.
v0.3.0¶
Added
UUIDStr, an annotation for UUIDs represented as strings, with validation that they follow the standard UUID string format. UpdatedUUIDPrimaryKeyandUUIDForeignKeyto use theUUIDStrtype, so that they are exported as strings, making their dictionary instances compatible withjsonschemavalidation in Python. See theUUIDStrdocs for details.Removed
DataCubeWithPointerand addedDataCubeMetadatato replace it. This component storesDataCubemetadata along with a file ID of a file in the Tetra Data Lake which stores the DataCube’s dimension and measure values. See the documentation for DataCubeMetadata
v0.2.0¶
Enabled intellisense for the
IdsElementconstructor. This enables additional code completion, tooltips and type checking in IDEs.SchemaExtraMetadataTypeis no longer aClassVar, so theIdsElement.schema_extra_metadatafield must now be explicitly given a type ofClassVar[SchemaExtraMetadataType]: to upgrade, replaceschema_extra_metadata: SchemaExtraMetadataTypewithschema_extra_metadata: ClassVar[SchemaExtraMetadataType]as needed. This way, intellisense does not interpretschema_extra_metadataas a constructor parameter.Updated documentation site and started publishing documentation to https://ids.tetrascience.com, including consolidating IDS components and conventions documentation from other sources into this documentation.
Added
RawValueUnitcomponent for storing a value and a unit along with a raw string value.Added
Experimentcomponent for referring to an experiment’s ID, name and description. Theexperimentfield which was previously inRunhas been removed, and itslogsandinstrument_statusfields were added to theRunobject. Now the meaning of “experiment” matches the definition of the “experiment” attribute used for instrument onboarding in TDP.Added
DataCubeWithParquetcomponent for storing datacube data with a pointer to a Parquet file in the data lake (note: this component was later removed in v0.3.0 and replaced withDataCubeMetadata).Added
UUIDPrimaryKeyandUUIDForeignKeyfor defining fields as primary or foreign keys, see their API docs for details.