tlc.core.schema¶
Defines Schema, which is a class for describing atomic or (possibly nested) composite structures
Module Contents¶
Classes¶
Class |
Description |
|---|---|
Describes a scalar boolean value |
|
Describes a binary value utf-8 encoded as a string |
|
Describes a date-time string value |
|
Describes a value which consists of an anonymous, free-form dictionary |
|
Describes a scalar numeric value which is a dimension size within a property |
|
A numeric value with type ‘float32’ |
|
A numeric value with type ‘float64’ |
|
Describes a generic URL string value |
|
Describes a Image URL string value |
|
Describes a binary value encoded as a run-length encoding |
|
A numeric value with type ‘int16’ |
|
A numeric value with type ‘int32’ |
|
A numeric value with type ‘int64’ |
|
A numeric value with type ‘int8’ |
|
Defines a single item in a value map. |
|
A schema that encodes a None value |
|
Describes a scalar numeric value |
|
A string containing an object type |
|
Describes a scalar value in a schema |
|
A schema is a recursive structure which defines the layout of an object. It defines what elements the object consists of, which must be either |
|
Describes a Segmentation Mask URL string value |
|
Describes a Segmentation URL string value |
|
Describes a string value |
|
Describes a URL string value pointing to a tensor |
|
A timestamp value counting the number of ‘unit’s since epoch |
|
A numeric value with type ‘uint16’ |
|
A numeric value with type ‘uint32’ |
|
A numeric value with type ‘uint64’ |
|
A numeric value with type ‘uint8’ |
|
Describes a generic URL string value |
API¶
- class BoolValue( )¶
Bases:
tlc.core.schema.ScalarValueDescribes a scalar boolean value
- class BytesStringValue( )¶
Bases:
tlc.core.schema.StringValueDescribes a binary value utf-8 encoded as a string
- class DatetimeStringValue( )¶
Bases:
tlc.core.schema.StringValueDescribes a date-time string value
- class DictValue( )¶
Bases:
tlc.core.schema.ScalarValueDescribes a value which consists of an anonymous, free-form dictionary
- class DimensionNumericValue(
- value_min: int = 0,
- value_max: int | None = None,
- enforce_min: bool = True,
- enforce_max: bool = False,
- display_name: str = '',
- description: str = '',
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- sample_type: str = '',
- default_value: int | None = None,
Bases:
tlc.core.schema.Int32ValueDescribes a scalar numeric value which is a dimension size within a property
- static dimension_numeric_value_from_any(
- this_property: Any,
Creates a DimensionNumericValue object and populates it from an anonymous, possibly sparse object
- classmethod fixed_size(
- size: int,
Create a fixed size dimension value
- class Float32Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: float | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘float32’
- class Float64Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: float | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘float64’
- class FolderUrlStringValue( )¶
Bases:
tlc.core.schema.StringValueDescribes a generic URL string value
- class ImageUrlStringValue( )¶
Bases:
tlc.core.schema.UrlStringValueDescribes a Image URL string value
- class InstanceSegmentationRLEBytesStringValue( )¶
Bases:
tlc.core.schema.BytesStringValueDescribes a binary value encoded as a run-length encoding
- static from_any(
- any_value: Any,
- class Int16Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘int16’
- class Int32Value(
- value_min: int | None = None,
- value_max: int | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘int32’
- class Int64Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘int64’
- class Int8Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘int8’
- class MapElement(
- internal_name: str = '',
- display_name: str = '',
- description: str = '',
- display_color: str = '',
- url: str = '',
Bases:
dictDefines a single item in a value map.
Initialize self. See help(type(self)) for accurate signature.
- static from_any(
- any_map_element: Any,
Creates a MapElement object and populates it from an anonymous, possibly sparse object
- class NoneSchema¶
Bases:
tlc.core.schema.SchemaA schema that encodes a None value
It is not a valid Schema as it has neither value nor values. It is used to encode override schemas that remove sub schemas.
- Example:
override_schema = { "values": { "column_to_remove": None }} # or equivalently override_schema = { "values": { "column_to_remove": NoneSchema()}}
- class NumericValue(
- value_type: str = _DEFAULT_SCALAR_VALUE_TYPE,
- value_min: float | int | None = None,
- value_max: float | int | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | float | None = None,
Bases:
tlc.core.schema.ScalarValueDescribes a scalar numeric value
- static from_any(
- any_value: Any,
Create and populate a NumericValue object given an anonymous, potentially sparse object
- static from_value(
- value: Any,
Create a numeric value from a Python value.
- Parameters:
value – The value to create a NumericValue from
- Returns:
A NumericValue (or one it the derived classes) representing the value
- class ObjectTypeStringValue( )¶
Bases:
tlc.core.schema.StringValueA string containing an object type
- class ScalarValue( )¶
Describes a scalar value in a schema
- static from_any(
- any_value: Any,
Create and populate a ScalarValue (or one of the derived classes) given an anonymous, potentially sparse object
- static from_value(
- value: Any,
Create a scalar value from a Python value.
- Parameters:
value – The value to create a ScalarValue from
- Returns:
A ScalarValue (or one it the derived classes) representing the value
- class Schema(
- display_name: str = '',
- description: str = '',
- writable: bool = True,
- display_importance: float = 0,
- value: ScalarValue | None = None,
- values: dict[str, Schema] | None = None,
- composite_role: str = '',
- display_color: str = '',
- swap_group: str = '',
- computable: bool = True,
- sample_type: str | None = None,
- transient: bool = False,
- default_visible: bool = True,
- size0: DimensionNumericValue | None = None,
- size1: DimensionNumericValue | None = None,
- size2: DimensionNumericValue | None = None,
- size3: DimensionNumericValue | None = None,
- size4: DimensionNumericValue | None = None,
- size5: DimensionNumericValue | None = None,
- metadata: dict[str, Any] | None = None,
- default_value: Any | None = None,
- array_signature_group: str | None = None,
A schema is a recursive structure which defines the layout of an object. It defines what elements the object consists of, which must be either
Atomic type (with optional metadata, e.g. value range, unit, etc.) OR
Composite contents (a list of schemas describing the sub-object)
In addition, it defines HOW MANY of these scalar or composite elements exist, in the form of up to six-dimensions which can each be described separately and be of fixed or variable lengths. The default size of dimensions is 1, describing a scalar value.
Schemas are used for
Defining the layout of Objects (as reported by e.g. “MyObject.schema”)
In the case of Tables: defining the common layout of all table rows (as reported by e.g “MyTableObject.schema.values[“rows”])
In the case where a schema defines a “top-level” object, it will always have a ‘values’ attribute (since it is always a composite object, and does not comprise only a single atomic value).
- add_sample_weight( ) None¶
Adds a sample weight column to the schema.
- Parameters:
hidden – Whether the column should be hidden
- add_sub_schema( ) None¶
Adds a Schema as a sub-property within this Schema (i.e. into the ‘values’ collection)
- add_sub_value(
- name: str,
- value: ScalarValue,
- writable: bool = True,
- computable: bool = True,
Adds a scalar value as a sub-property within this Schema (i.e. into the ‘values’ collection)
- consider_override_from( ) Schema¶
Selectively overwrites columns within this Schema according to the columns defined in another Schema.
- does_object_match(
- _object: Any,
Checks whether a schema matches an example object.
This requires exact 1:1 mapping between attributes in the object and the schema (including recursively). This means no attributes can be missing, nor can there be any additional attributes only present in the object.
- static from_any(
- any_object: Any,
Returns a Schema object which has been populated from a serialized (possibly sparse) object
- static from_json(
- json_string: str,
Returns a Schema object which has been populated from a JSON string
- classmethod from_sample(
- sample: Any,
Creates a schema describing the provided sample.
- Parameters:
sample – The sample to create a schema from
- Returns:
The schema
- classmethod from_structure(
- structure: tlc.client.sample_type._SampleTypeStructure,
Creates a schema from a structure.
- Parameters:
structure – The structure to create a schema from
- Returns:
The schema
- is_atomic() bool¶
Return whether the schema is atomic, i.e. has a single value.
The opposite of
is_composite.- Returns:
Whether the schema is atomic
- is_composite() bool¶
Return whether the schema is composite, i.e. has multiple values.
The opposite of
is_atomic.- Returns:
Whether the schema is composite
- is_fixed_size() bool¶
Return whether the schema has fixed size.
This requires all dimensions to be fixed size.
- is_scalar() bool¶
Return whether the schema is a scalar value
Sizes are required to be set in increasing dimensions without gaps and no size is treated like a scalar.
- last_dimension() DimensionNumericValue | None¶
Return the last (outermost) dimension of the Schema
- pop_dim() DimensionNumericValue | None¶
Sets size5 to None and shifts all other dimensions left. (size5 becomes size4, size4 becomes size3, etc.).
- Returns:
The old size0
- push_dim(
- dim: DimensionNumericValue | None = None,
Inserts dim as size0 and shifts all other dimensions right. (size1 becomes size0, size2 becomes size1).
- Parameters:
dim – The dimension to insert as size0
- Returns:
The old size5
- property sample_type_object: SampleType¶
- set_writable_flag_recursively(
- writable: bool,
Sets the writable flag recursively.
- Parameters:
writable – Whether the schema is writable
- class SegmentationMaskUrlStringValue( )¶
Bases:
tlc.core.schema.SegmentationUrlStringValueDescribes a Segmentation Mask URL string value
- static from_any(
- any_value: Any,
Create and populate a SegmentationMaskUrlStringValue object given an anonymous, potentially sparse object
- class SegmentationUrlStringValue( )¶
Bases:
tlc.core.schema.UrlStringValueDescribes a Segmentation URL string value
- static from_any(
- any_value: Any,
Create and populate a SegmentationUrlStringValue object given an anonymous, potentially sparse object
- class StringValue( )¶
Bases:
tlc.core.schema.ScalarValueDescribes a string value
- static from_any(
- any_value: Any,
Create and populate a StringValue object given an anonymous, potentially sparse object
- class TensorUrlStringValue( )¶
Bases:
tlc.core.schema.UrlStringValueDescribes a URL string value pointing to a tensor
- class TimestampValue(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = NUMBER_ROLE_TIMESTAMP,
- unit: str = 'ms',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.Int64ValueA timestamp value counting the number of ‘unit’s since epoch
Stores the value as an ‘int64’
Defaults to milliseconds resolution
- class Uint16Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘uint16’
- class Uint32Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘uint32’
- class Uint64Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘uint64’
- class Uint8Value(
- value_min: float | None = None,
- value_max: float | None = None,
- enforce_min: bool = False,
- enforce_max: bool = False,
- value_step: float = 0,
- number_role: str = '',
- unit: str = '',
- value_map: dict[float, MapElement] | None = None,
- default_value: int | None = None,
Bases:
tlc.core.schema.NumericValueA numeric value with type ‘uint8’
- class UrlStringValue( )¶
Bases:
tlc.core.schema.StringValueDescribes a generic URL string value