Skip to main content

Programmatically define TetraScience Intermediate Data Schema (IDS).

Reason this release was yanked:

customers are encouraged to contact TetraScience to install the latest version from TS JFrog

Project description

Welcome to ts-ids-core's documentation!

ts-ids-core provides a programmatic way of defining TetraScience Intermediate Data Schema (IDS). An IDS defined using the ts-ids-core framework can be exported to IDS JSON (jsonschema v7) and is thus compatible with the Tetra Data Platform (TDP).

Install

pip install ts-ids-core

Quickstart

To define your own Programmatic IDS (PIDS), inherit from classes in ts_ids_core.schema; ts_ids_core.schema.IdsSchema contains the IDS metadata fields, e.g. IDS version, and should be the parent class to your top-level IDS class.

In addition to defining IDS metadata fields, in the example below we add a field named "samples" that conforms to the predefined component, Schema.

from typing import List

from ts_ids_core.schema import IdsSchema, Sample
from ts_ids_core.base.ids_field import IdsField
from ts_ids_core.base.ids_element import SchemaExtraMetadataType


class DemoIdsSchema(IdsSchema):
    #: The type hint `SchemaExtraMetadataType` is required.
    schema_extra_metadata: SchemaExtraMetadataType = {
        "$id": "https://ids.tetrascience.com/my_namespace/demo_ids/v1.0.0/schema.json",
        "$schema": "http://json-schema.org/draft-07/schema#",
    }

    ids_namespace: str = IdsField('my_namespace', const=True)
    ids_type: str = IdsField('my_unique_ids_name', const=True)
    ids_version: str = IdsField('v1.0.0', const=True)

    samples: List[Sample] = IdsField()

That's it! You just defined an IDS class. To export the IDS to JSON Schema used by the TDP, run the following code:

ids_json_schema = DemoIdsSchema.schema_json(indent=2)

When printed, output will look like this:

Expand to show output
{
  "$id": "https://ids.tetrascience.com/my_namespace/my_unique_ids_name/v1.0.0/schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Top-level schema.",
  "type": "object",
  "properties": {
    "ids_type": {
      "const": "my_unique_ids_name",
      "type": "string"
    },
    "ids_version": {
      "const": "v1.0.0",
      "type": "string"
    },
    "@idsConventionVersion": {
      "const": "v1.0.0",
      "type": "string"
    },
    "ids_namespace": {
      "const": "my_namespace",
      "type": "string"
    },
    "samples": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/Sample"
      }
    }
  },
  "additionalProperties": false,
  "definitions": {
    "Batch": {
      "type": "object",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "barcode": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "Set": {
      "type": "object",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "Lot": {
      "type": "object",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "Holder": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": [
            "string",
            "null"
          ]
        },
        "barcode": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "Location": {
      "type": "object",
      "properties": {
        "position": {
          "type": [
            "string",
            "null"
          ]
        },
        "row": {
          "type": [
            "number",
            "null"
          ]
        },
        "column": {
          "type": [
            "number",
            "null"
          ]
        },
        "index": {
          "type": [
            "number",
            "null"
          ]
        },
        "holder": {
          "$ref": "#/definitions/Holder"
        }
      },
      "additionalProperties": false
    },
    "Source": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "type"
      ],
      "additionalProperties": false
    },
    "ValueDataType": {
      "title": "ValueDataType",
      "description": "An enumeration.",
      "enum": [
        "string",
        "number",
        "boolean"
      ],
      "type": "string"
    },
    "RawSampleTime": {
      "type": "object",
      "properties": {
        "start": {
          "type": [
            "string",
            "null"
          ]
        },
        "created": {
          "type": [
            "string",
            "null"
          ]
        },
        "stop": {
          "type": [
            "string",
            "null"
          ]
        },
        "duration": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_updated": {
          "type": [
            "string",
            "null"
          ]
        },
        "acquired": {
          "type": [
            "string",
            "null"
          ]
        },
        "modified": {
          "type": [
            "string",
            "null"
          ]
        },
        "lookup": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "lookup"
      ],
      "additionalProperties": false
    },
    "SampleTime": {
      "type": "object",
      "properties": {
        "start": {
          "type": [
            "string",
            "null"
          ]
        },
        "created": {
          "type": [
            "string",
            "null"
          ]
        },
        "stop": {
          "type": [
            "string",
            "null"
          ]
        },
        "duration": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_updated": {
          "type": [
            "string",
            "null"
          ]
        },
        "acquired": {
          "type": [
            "string",
            "null"
          ]
        },
        "modified": {
          "type": [
            "string",
            "null"
          ]
        },
        "lookup": {
          "type": [
            "string",
            "null"
          ]
        },
        "raw": {
          "$ref": "#/definitions/RawSampleTime"
        }
      },
      "required": [
        "lookup"
      ],
      "additionalProperties": false
    },
    "Property": {
      "type": "object",
      "properties": {
        "source": {
          "$ref": "#/definitions/Source"
        },
        "name": {
          "description": "This is the property name",
          "type": "string"
        },
        "value": {
          "description": "The original string value of the parameter",
          "type": "string"
        },
        "value_data_type": {
          "description": "This is the type of the original value",
          "$ref": "#/definitions/ValueDataType"
        },
        "string_value": {
          "description": "If string_value has a value, then numerical_value,\nnumerical_value_unit, and boolean_value all have to be null",
          "type": [
            "string",
            "null"
          ]
        },
        "numerical_value": {
          "description": "If numerical_value has a value, then string_value and\nboolean_value both have to be null",
          "type": [
            "number",
            "null"
          ]
        },
        "numerical_value_unit": {
          "type": [
            "string",
            "null"
          ]
        },
        "boolean_value": {
          "description": "If boolean_value has a value, then numerical_value, numerical_value_unit,\nand string_value all have to be null",
          "type": [
            "boolean",
            "null"
          ]
        },
        "time": {
          "$ref": "#/definitions/SampleTime"
        }
      },
      "required": [
        "source",
        "name",
        "value",
        "value_data_type",
        "string_value",
        "numerical_value",
        "numerical_value_unit",
        "boolean_value",
        "time"
      ],
      "additionalProperties": false
    },
    "Label": {
      "type": "object",
      "properties": {
        "source": {
          "$ref": "#/definitions/Source"
        },
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        },
        "time": {
          "$ref": "#/definitions/SampleTime"
        }
      },
      "required": [
        "source",
        "name",
        "value",
        "time"
      ],
      "additionalProperties": false
    },
    "Sample": {
      "description": "See [here](https://developers.tetrascience.com/docs/ids-design-conventions-schema-templates#samples)\nfor specification of \"samples\". An instance of this class is one item in the\n`samples` array.",
      "type": "object",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "barcode": {
          "type": [
            "string",
            "null"
          ]
        },
        "batch": {
          "$ref": "#/definitions/Batch"
        },
        "set": {
          "$ref": "#/definitions/Set"
        },
        "lot": {
          "$ref": "#/definitions/Lot"
        },
        "location": {
          "$ref": "#/definitions/Location"
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Property"
          }
        },
        "labels": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Label"
          }
        }
      },
      "additionalProperties": false
    }
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ts-ids-core-0.1.0a4.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

ts_ids_core-0.1.0a4-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file ts-ids-core-0.1.0a4.tar.gz.

File metadata

  • Download URL: ts-ids-core-0.1.0a4.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.11 Darwin/20.6.0

File hashes

Hashes for ts-ids-core-0.1.0a4.tar.gz
Algorithm Hash digest
SHA256 c15e92e7c6963d71ddfdc37781e2765d9eddc6b986cabf7c6e8b36ffe2b93a62
MD5 c122f6bd2e465ebe0a3966fcd69f1e79
BLAKE2b-256 037bd10c308ee3a4c4494800791b0216bc44785f2c7959e34bac65de0459629b

See more details on using hashes here.

File details

Details for the file ts_ids_core-0.1.0a4-py3-none-any.whl.

File metadata

  • Download URL: ts_ids_core-0.1.0a4-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.11 Darwin/20.6.0

File hashes

Hashes for ts_ids_core-0.1.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 64ae5c06701bef4baa20dcfc179e1d5c490740a7a19b180004b2977b12f6706f
MD5 50351b664f6d21add52394393aa7ee89
BLAKE2b-256 d58425fdb20640a7aa2ad4fa47e848d1e4f44c1ab8632ab03cb759525e2445cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page