Skip to content

hololinked.metadata.td.tm.ThingModel

Bases: WoTSchema, Metadata

Thing Model as per W3C WoT Thing Description v1.1.

Source code in repo/hololinked/hololinked/metadata/td/tm.py
class ThingModel(WoTSchema, Metadata):
    """
    Thing Model as per W3C WoT Thing Description v1.1.

    - [Specification](https://www.w3.org/TR/wot-thing-description11/)
    - [UML Diagram](https://docs.hololinked.dev/UML/PDF/ThingModel.pdf)
    """

    context: list[str | dict[str, str]] = Field(["https://www.w3.org/2022/wot/td/v1.1"], alias="@context")
    type: str | list[str] | None = None
    id: str | None = None
    title: str | None = None
    description: str | None = None
    version: VersionInfo | None = None
    created: str | None = None
    modified: str | None = None
    support: str | None = None
    base: str | None = None
    properties: dict[str, PropertyAffordance] = Field(default_factory=dict)
    actions: dict[str, ActionAffordance] = Field(default_factory=dict)
    events: dict[str, EventAffordance] = Field(default_factory=dict)

    model_config = ConfigDict(extra="allow")

    def __init__(
        self,
        thing: Thing | None = None,
        allow_loose_schema: bool | None = False,
        ignore_errors: bool = False,
        skip_names: list[str] | None = [],
    ) -> None:
        WoTSchema.__init__(self)
        Metadata.__init__(
            self,
            thing=thing,
            ignore_errors=ignore_errors,
            skip_names=skip_names,
        )
        self.allow_loose_schema = allow_loose_schema

    def generate(self) -> ThingModel:
        """
        Populate the thing model.

        Returns
        -------
        ThingModel

        Raises
        ------
        ValueError
            If the thing instance is not attached to the thing model. Usually, when API first approach is used,
            the thing instance could not yet be instantiated. This method is not to be used at that time.
        """
        if self.thing is None:
            raise ValueError("Thing Model instance not attached to a Thing instance to generate metadata.")
        self.id = self.thing.id
        self.title = self.thing.__class__.__name__
        self.context = ["https://www.w3.org/2022/wot/td/v1.1"]
        # default value of context is not being picked up although we only use exclude_unset=True
        if self.thing.__doc__:
            self.description = WoTSchema.format_doc(self.thing.__doc__)
        source = getattr(type(self.thing), "_thing_model", None)  # the model a Thing produced from it implements
        if source is not None:
            self.title = source.title or self.title
            self.description = source.description
        self.properties = {}
        self.actions = {}
        self.events = {}
        self.add_interaction_affordances()
        return self

    def produce(self, impl: Any, id: str, validator: str = "pydantic", **kwargs: Any) -> Thing:
        """
        Create a `Thing` instance based on the Thing Model, possibly binding with an existing implementation object `impl`.

        Members of the `impl` must implement the interactions by name:
        - a method must implement an action
        - a `property` must be implemented as a plain attribute or a python `property` descriptor

        Events do not have a mapping and are created based on the Thing Model definition, accessible at runtime.

        If custom objects implement properties and actions, use the `property_impl` and `action_impl` keyword arguments
        to provide the corresponding implementation objects.

        Parameters
        ----------
        impl: Any
            the object implementing the Thing Model, can be `None`.
        id: str
            id of the `Thing`
        validator: str
            validator type for payloads, usually pydantic for pydantic models
        **kwargs: Any
            Additional keyword arguments:

            - `member_names_map` - an explicit mapping of interaction name to the member implementing it, only for names
            that differ (by default every interaction is implemented by the member of the same name)
            - `property_impl` - optional, if you have not implemented a getattr in your implementation class,
            you can provide an object that handles property access. default `@property` descriptors or custom
            descriptors do not require that you provide this. Names like `get()`, `set()`, and `delete()` are handled
            automatically. For other names, use `property_impl_fget`, `property_impl_fset`, and `property_impl_fdel`
            as needed.
            - `action_impl` - optional, if you have not implemented a standard method for an action in your
            implementation class, you can provide an object that handles action calls. default methods on the
            implementation object do not require that you provide this.
            - `property_impl_fget` - optional, if you have not implemented a getattr in your implementation class,
            you can provide an object that handles property access. default `@property` descriptors or custom
            descriptors with __get__ do not require that you provide this.
            -  `property_impl_fset` - optional, if you have not implemented a setattr in your implementation class,
            you can provide an object that handles property setting. default `@property` descriptors or custom
            descriptors with __set__ do not require that you provide this.
            - `property_impl_fdel` - optional, if you have not implemented a delattr in your implementation class,
            you can provide an object that handles property deletion. default `@property` descriptors or custom
            descriptors with __delete__ do not require that you provide this.
            - `action_impl_call` - optional, if you have not implemented a standard method for an action in your
            implementation class, you can provide an object that handles action calls. default methods on the
            implementation object do not require that you provide this.
            - `dynamic_attributes` - optional, False by default. A property whose member is not found statically is
            read and written on the implementation object at access time (through its `__getattr__` /
            `__setattr__`) instead of being stored on the `Thing`. Dotted member names like `a.b.c`, from the Thing
            Model or `member_names_map`, walk the attributes. Such members are checked on first use only.
            - `thing_kwargs` - any other argument of the `Thing` object

        Returns
        -------
        Thing
            the created `Thing`

        Raises
        ------
        ConformanceError
            listing every member that does not match the Thing Model
        """
        member_names_map = dict(kwargs.pop("member_names_map", None) or {})
        descriptors = Metadata.compile_descriptors_from(
            model=self,
            impl=impl,
            member_names_map=member_names_map,
            validator=validator,
            property_impl=kwargs.pop("property_impl", None),
            action_impl=kwargs.pop("action_impl", None),
            dynamic_attributes=kwargs.pop("dynamic_attributes", False),
        )
        namespace = {**descriptors, "_thing_model": self, "__doc__": self.description}
        # create the class with the namespace
        class_def = type(a_class_name_from_title_string(self.title), (Thing,), namespace)
        thing = class_def(id=id, **kwargs.pop("thing_kwargs", {}))
        # update the delegates if any
        for descriptor in descriptors.values():
            if descriptor.delegate is not None:
                descriptor.delegate.thing = thing

        return thing

    @classmethod
    def from_metadata(cls, metadata: dict[str, Any], strict: bool = True) -> ThingModel:
        """
        Convert a JSON specification of a Thing Description or a Thing Model into a ThingModel instance.

        Parameters
        ----------
        metadata: dict[str, Any]
            the Thing Description or Thing Model JSON
        strict: bool, optional
            Unknown keys will raise an error if True, default True

        Returns
        -------
        ThingModel
            the model with its properties, actions and events, not attached to a Thing instance

        Raises
        ------
        NotImplementedError
            if the Thing Model uses `tm:ref` or `{{placeholders}}`, which are not supported yet
        """
        if model_spec_has_extensions(metadata):
            raise NotImplementedError("Thing Models with tm:ref or {{placeholders}} are not supported yet")
        model = cls()
        for key in ("id", "title", "description", "created", "modified", "support", "base"):
            if key in metadata:
                setattr(model, key, metadata[key])
        if "@context" in metadata:
            context = metadata["@context"]
            model.context = context if isinstance(context, list) else [context]
        model.properties = {
            name: PropertyAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
            for name in metadata.get("properties", {})
        }
        model.actions = {
            name: ActionAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
            for name in metadata.get("actions", {})
        }
        model.events = {
            name: EventAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
            for name in metadata.get("events", {})
        }
        return model

    @classmethod
    def from_file(
        cls,
        path: str | os.PathLike,
        strict: bool = True,
        format: Literal["json", "yaml"] | None = None,
    ) -> ThingModel:
        """
        Load a Thing Description or a plain Thing Model from a JSON or a YAML file.

        A YAML file must hold only JSON types: unquoted dates stay strings, only `true` and `false` are booleans and
        numbers follow the JSON grammar. Loading YAML needs the `yaml` extra (`pip install hololinked[yaml]`).

        Parameters
        ----------
        path: str | os.PathLike
            path of the file
        strict: bool, optional
            Unknown keys will raise an error if strict is True.
        format: Literal["json", "yaml"] | None, optional
            format of the file, by default YAML if the file ends with `.yaml` or `.yml` and JSON otherwise

        Returns
        -------
        ThingModel
            the model with its properties, actions and events, not attached to a Thing instance
        """
        return cls.from_metadata(load_metadata_file(path, format), strict=strict)

    # not the best code and logic, but works for now
    skip_properties: ClassVar[list[str]] = ["expose", "thing_description", "GUI", "object_info"]
    """
    List of default property names to skip when generating the metadata. Different from `skip_names` as
    this list is supposed to be used as a builtin blacklist.
    """

    skip_actions: ClassVar[list[str]] = [
        Thing._add_property.name,
        Thing._get_properties.name,
        Thing._get_properties_in_db.name,
        Thing._set_properties.name,
    ]
    """
    List of default action names to skip when generating the metadata. Different from `skip_names` as
    this list is supposed to be used as a builtin blacklist.
    """

    skip_events: ClassVar[list[str]] = []
    """
    List of default event names to skip when generating the metadata. Different from `skip_names` as
    this list is supposed to be used as a builtin blacklist.
    """

    def add_interaction_affordances(self) -> None:
        """
        Add interaction affordances to the thing model.

        Raises
        ------
        ValueError
            If the thing instance is not attached to the thing model. Usually, when API first approach is used,
            the thing instance could not yet be instantiated. This method is not to be used at that time.
        """
        if self.thing is None:
            raise ValueError("Thing Model instance not attached to a Thing instance to generate metadata.")
        affordances: list[
            tuple[str, ItemsView[str, Any], type[PropertyAffordance | ActionAffordance | EventAffordance], list[str]]
        ] = [
            ("properties", self.thing.properties.remote_objects.items(), PropertyAffordance, self.skip_properties),
            ("actions", self.thing.actions.descriptors.items(), ActionAffordance, self.skip_actions),
            ("events", self.thing.events.plain.items(), EventAffordance, self.skip_events),
        ]
        for affordance, items, affordance_cls, skip_list in affordances:
            for name, obj in items:
                if name in skip_list or name in self.skip_names:
                    continue
                if name == "state" and affordance == "properties" and not hasattr(self.thing, "state_machine"):
                    continue
                try:
                    affordance_dict = getattr(self, affordance)
                    affordance_dict[name] = affordance_cls.from_descriptor(obj, self.thing)
                except Exception as ex:
                    if not self.ignore_errors:
                        raise ex from None
                    if hasattr(self.thing, "logger"):
                        self.thing.logger.error(f"Error while generating schema for {name} - {ex}")

    def model_dump(self, **kwargs) -> dict[str, Any]:
        """
        Return the JSON representation.

        Returns
        -------
        dict[str, Any]
            JSON representation
        """

        def dump_value(value):
            nonlocal kwargs
            if hasattr(value, "model_dump"):
                return value.model_dump(**kwargs)
            elif isinstance(value, dict):
                return {k: dump_value(v) for k, v in value.items()}
            elif isinstance(value, list):
                return [dump_value(v) for v in value]
            elif isinstance(value, tuple):
                return tuple(dump_value(v) for v in value)
            else:
                return value

        result = {}
        for field in self.__class__.model_fields:
            if field in self.skip_keys:
                continue
            if not hasattr(self, field) or getattr(self, field) is None:
                continue
            if field in [
                "instance",
                "skip_keys",
                "skip_properties",
                "skip_actions",
                "skip_events",
                "skip_names",
                "ignore_errors",
                "allow_loose_schema",
            ]:
                continue
            value = getattr(self, field)
            result[field] = dump_value(value)
        return result

Attributes

skip_actions class-attribute

skip_actions: list[str] = [name, name, name, name]

List of default action names to skip when generating the metadata. Different from skip_names as this list is supposed to be used as a builtin blacklist.

skip_events class-attribute

skip_events: list[str] = []

List of default event names to skip when generating the metadata. Different from skip_names as this list is supposed to be used as a builtin blacklist.

skip_properties class-attribute

skip_properties: list[str] = ['expose', 'thing_description', 'GUI', 'object_info']

List of default property names to skip when generating the metadata. Different from skip_names as this list is supposed to be used as a builtin blacklist.

Functions

add_interaction_affordances

add_interaction_affordances() -> None

Add interaction affordances to the thing model.

Raises:

Type Description
ValueError

If the thing instance is not attached to the thing model. Usually, when API first approach is used, the thing instance could not yet be instantiated. This method is not to be used at that time.

Source code in repo/hololinked/hololinked/metadata/td/tm.py
def add_interaction_affordances(self) -> None:
    """
    Add interaction affordances to the thing model.

    Raises
    ------
    ValueError
        If the thing instance is not attached to the thing model. Usually, when API first approach is used,
        the thing instance could not yet be instantiated. This method is not to be used at that time.
    """
    if self.thing is None:
        raise ValueError("Thing Model instance not attached to a Thing instance to generate metadata.")
    affordances: list[
        tuple[str, ItemsView[str, Any], type[PropertyAffordance | ActionAffordance | EventAffordance], list[str]]
    ] = [
        ("properties", self.thing.properties.remote_objects.items(), PropertyAffordance, self.skip_properties),
        ("actions", self.thing.actions.descriptors.items(), ActionAffordance, self.skip_actions),
        ("events", self.thing.events.plain.items(), EventAffordance, self.skip_events),
    ]
    for affordance, items, affordance_cls, skip_list in affordances:
        for name, obj in items:
            if name in skip_list or name in self.skip_names:
                continue
            if name == "state" and affordance == "properties" and not hasattr(self.thing, "state_machine"):
                continue
            try:
                affordance_dict = getattr(self, affordance)
                affordance_dict[name] = affordance_cls.from_descriptor(obj, self.thing)
            except Exception as ex:
                if not self.ignore_errors:
                    raise ex from None
                if hasattr(self.thing, "logger"):
                    self.thing.logger.error(f"Error while generating schema for {name} - {ex}")

from_file classmethod

from_file(path: str | PathLike, strict: bool = True, format: Literal['json', 'yaml'] | None = None) -> ThingModel

Load a Thing Description or a plain Thing Model from a JSON or a YAML file.

A YAML file must hold only JSON types: unquoted dates stay strings, only true and false are booleans and numbers follow the JSON grammar. Loading YAML needs the yaml extra (pip install hololinked[yaml]).

Parameters:

Name Type Description Default

path

str | PathLike

path of the file

required

strict

bool

Unknown keys will raise an error if strict is True.

True

format

Literal['json', 'yaml'] | None

format of the file, by default YAML if the file ends with .yaml or .yml and JSON otherwise

None

Returns:

Type Description
ThingModel

the model with its properties, actions and events, not attached to a Thing instance

Source code in repo/hololinked/hololinked/metadata/td/tm.py
@classmethod
def from_file(
    cls,
    path: str | os.PathLike,
    strict: bool = True,
    format: Literal["json", "yaml"] | None = None,
) -> ThingModel:
    """
    Load a Thing Description or a plain Thing Model from a JSON or a YAML file.

    A YAML file must hold only JSON types: unquoted dates stay strings, only `true` and `false` are booleans and
    numbers follow the JSON grammar. Loading YAML needs the `yaml` extra (`pip install hololinked[yaml]`).

    Parameters
    ----------
    path: str | os.PathLike
        path of the file
    strict: bool, optional
        Unknown keys will raise an error if strict is True.
    format: Literal["json", "yaml"] | None, optional
        format of the file, by default YAML if the file ends with `.yaml` or `.yml` and JSON otherwise

    Returns
    -------
    ThingModel
        the model with its properties, actions and events, not attached to a Thing instance
    """
    return cls.from_metadata(load_metadata_file(path, format), strict=strict)

from_metadata classmethod

from_metadata(metadata: dict[str, Any], strict: bool = True) -> ThingModel

Convert a JSON specification of a Thing Description or a Thing Model into a ThingModel instance.

Parameters:

Name Type Description Default

metadata

dict[str, Any]

the Thing Description or Thing Model JSON

required

strict

bool

Unknown keys will raise an error if True, default True

True

Returns:

Type Description
ThingModel

the model with its properties, actions and events, not attached to a Thing instance

Raises:

Type Description
NotImplementedError

if the Thing Model uses tm:ref or ``, which are not supported yet

Source code in repo/hololinked/hololinked/metadata/td/tm.py
@classmethod
def from_metadata(cls, metadata: dict[str, Any], strict: bool = True) -> ThingModel:
    """
    Convert a JSON specification of a Thing Description or a Thing Model into a ThingModel instance.

    Parameters
    ----------
    metadata: dict[str, Any]
        the Thing Description or Thing Model JSON
    strict: bool, optional
        Unknown keys will raise an error if True, default True

    Returns
    -------
    ThingModel
        the model with its properties, actions and events, not attached to a Thing instance

    Raises
    ------
    NotImplementedError
        if the Thing Model uses `tm:ref` or `{{placeholders}}`, which are not supported yet
    """
    if model_spec_has_extensions(metadata):
        raise NotImplementedError("Thing Models with tm:ref or {{placeholders}} are not supported yet")
    model = cls()
    for key in ("id", "title", "description", "created", "modified", "support", "base"):
        if key in metadata:
            setattr(model, key, metadata[key])
    if "@context" in metadata:
        context = metadata["@context"]
        model.context = context if isinstance(context, list) else [context]
    model.properties = {
        name: PropertyAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
        for name in metadata.get("properties", {})
    }
    model.actions = {
        name: ActionAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
        for name in metadata.get("actions", {})
    }
    model.events = {
        name: EventAffordance.from_metadata(name=name, metadata=metadata, strict=strict)
        for name in metadata.get("events", {})
    }
    return model

generate

generate() -> ThingModel

Populate the thing model.

Returns:

Type Description
ThingModel

Raises:

Type Description
ValueError

If the thing instance is not attached to the thing model. Usually, when API first approach is used, the thing instance could not yet be instantiated. This method is not to be used at that time.

Source code in repo/hololinked/hololinked/metadata/td/tm.py
def generate(self) -> ThingModel:
    """
    Populate the thing model.

    Returns
    -------
    ThingModel

    Raises
    ------
    ValueError
        If the thing instance is not attached to the thing model. Usually, when API first approach is used,
        the thing instance could not yet be instantiated. This method is not to be used at that time.
    """
    if self.thing is None:
        raise ValueError("Thing Model instance not attached to a Thing instance to generate metadata.")
    self.id = self.thing.id
    self.title = self.thing.__class__.__name__
    self.context = ["https://www.w3.org/2022/wot/td/v1.1"]
    # default value of context is not being picked up although we only use exclude_unset=True
    if self.thing.__doc__:
        self.description = WoTSchema.format_doc(self.thing.__doc__)
    source = getattr(type(self.thing), "_thing_model", None)  # the model a Thing produced from it implements
    if source is not None:
        self.title = source.title or self.title
        self.description = source.description
    self.properties = {}
    self.actions = {}
    self.events = {}
    self.add_interaction_affordances()
    return self

model_dump

model_dump(**kwargs) -> dict[str, Any]

Return the JSON representation.

Returns:

Type Description
dict[str, Any]

JSON representation

Source code in repo/hololinked/hololinked/metadata/td/tm.py
def model_dump(self, **kwargs) -> dict[str, Any]:
    """
    Return the JSON representation.

    Returns
    -------
    dict[str, Any]
        JSON representation
    """

    def dump_value(value):
        nonlocal kwargs
        if hasattr(value, "model_dump"):
            return value.model_dump(**kwargs)
        elif isinstance(value, dict):
            return {k: dump_value(v) for k, v in value.items()}
        elif isinstance(value, list):
            return [dump_value(v) for v in value]
        elif isinstance(value, tuple):
            return tuple(dump_value(v) for v in value)
        else:
            return value

    result = {}
    for field in self.__class__.model_fields:
        if field in self.skip_keys:
            continue
        if not hasattr(self, field) or getattr(self, field) is None:
            continue
        if field in [
            "instance",
            "skip_keys",
            "skip_properties",
            "skip_actions",
            "skip_events",
            "skip_names",
            "ignore_errors",
            "allow_loose_schema",
        ]:
            continue
        value = getattr(self, field)
        result[field] = dump_value(value)
    return result

produce

produce(impl: Any, id: str, validator: str = 'pydantic', **kwargs: Any) -> Thing

Create a Thing instance based on the Thing Model, possibly binding with an existing implementation object impl.

Members of the impl must implement the interactions by name: - a method must implement an action - a property must be implemented as a plain attribute or a python property descriptor

Events do not have a mapping and are created based on the Thing Model definition, accessible at runtime.

If custom objects implement properties and actions, use the property_impl and action_impl keyword arguments to provide the corresponding implementation objects.

Parameters:

Name Type Description Default

impl

Any

the object implementing the Thing Model, can be None.

required

id

str

id of the Thing

required

validator

str

validator type for payloads, usually pydantic for pydantic models

'pydantic'

**kwargs

Any

Additional keyword arguments:

  • member_names_map - an explicit mapping of interaction name to the member implementing it, only for names that differ (by default every interaction is implemented by the member of the same name)
  • property_impl - optional, if you have not implemented a getattr in your implementation class, you can provide an object that handles property access. default @property descriptors or custom descriptors do not require that you provide this. Names like get(), set(), and delete() are handled automatically. For other names, use property_impl_fget, property_impl_fset, and property_impl_fdel as needed.
  • action_impl - optional, if you have not implemented a standard method for an action in your implementation class, you can provide an object that handles action calls. default methods on the implementation object do not require that you provide this.
  • property_impl_fget - optional, if you have not implemented a getattr in your implementation class, you can provide an object that handles property access. default @property descriptors or custom descriptors with get do not require that you provide this.
  • property_impl_fset - optional, if you have not implemented a setattr in your implementation class, you can provide an object that handles property setting. default @property descriptors or custom descriptors with set do not require that you provide this.
  • property_impl_fdel - optional, if you have not implemented a delattr in your implementation class, you can provide an object that handles property deletion. default @property descriptors or custom descriptors with delete do not require that you provide this.
  • action_impl_call - optional, if you have not implemented a standard method for an action in your implementation class, you can provide an object that handles action calls. default methods on the implementation object do not require that you provide this.
  • dynamic_attributes - optional, False by default. A property whose member is not found statically is read and written on the implementation object at access time (through its __getattr__ / __setattr__) instead of being stored on the Thing. Dotted member names like a.b.c, from the Thing Model or member_names_map, walk the attributes. Such members are checked on first use only.
  • thing_kwargs - any other argument of the Thing object
{}

Returns:

Type Description
Thing

the created Thing

Raises:

Type Description
ConformanceError

listing every member that does not match the Thing Model

Source code in repo/hololinked/hololinked/metadata/td/tm.py
def produce(self, impl: Any, id: str, validator: str = "pydantic", **kwargs: Any) -> Thing:
    """
    Create a `Thing` instance based on the Thing Model, possibly binding with an existing implementation object `impl`.

    Members of the `impl` must implement the interactions by name:
    - a method must implement an action
    - a `property` must be implemented as a plain attribute or a python `property` descriptor

    Events do not have a mapping and are created based on the Thing Model definition, accessible at runtime.

    If custom objects implement properties and actions, use the `property_impl` and `action_impl` keyword arguments
    to provide the corresponding implementation objects.

    Parameters
    ----------
    impl: Any
        the object implementing the Thing Model, can be `None`.
    id: str
        id of the `Thing`
    validator: str
        validator type for payloads, usually pydantic for pydantic models
    **kwargs: Any
        Additional keyword arguments:

        - `member_names_map` - an explicit mapping of interaction name to the member implementing it, only for names
        that differ (by default every interaction is implemented by the member of the same name)
        - `property_impl` - optional, if you have not implemented a getattr in your implementation class,
        you can provide an object that handles property access. default `@property` descriptors or custom
        descriptors do not require that you provide this. Names like `get()`, `set()`, and `delete()` are handled
        automatically. For other names, use `property_impl_fget`, `property_impl_fset`, and `property_impl_fdel`
        as needed.
        - `action_impl` - optional, if you have not implemented a standard method for an action in your
        implementation class, you can provide an object that handles action calls. default methods on the
        implementation object do not require that you provide this.
        - `property_impl_fget` - optional, if you have not implemented a getattr in your implementation class,
        you can provide an object that handles property access. default `@property` descriptors or custom
        descriptors with __get__ do not require that you provide this.
        -  `property_impl_fset` - optional, if you have not implemented a setattr in your implementation class,
        you can provide an object that handles property setting. default `@property` descriptors or custom
        descriptors with __set__ do not require that you provide this.
        - `property_impl_fdel` - optional, if you have not implemented a delattr in your implementation class,
        you can provide an object that handles property deletion. default `@property` descriptors or custom
        descriptors with __delete__ do not require that you provide this.
        - `action_impl_call` - optional, if you have not implemented a standard method for an action in your
        implementation class, you can provide an object that handles action calls. default methods on the
        implementation object do not require that you provide this.
        - `dynamic_attributes` - optional, False by default. A property whose member is not found statically is
        read and written on the implementation object at access time (through its `__getattr__` /
        `__setattr__`) instead of being stored on the `Thing`. Dotted member names like `a.b.c`, from the Thing
        Model or `member_names_map`, walk the attributes. Such members are checked on first use only.
        - `thing_kwargs` - any other argument of the `Thing` object

    Returns
    -------
    Thing
        the created `Thing`

    Raises
    ------
    ConformanceError
        listing every member that does not match the Thing Model
    """
    member_names_map = dict(kwargs.pop("member_names_map", None) or {})
    descriptors = Metadata.compile_descriptors_from(
        model=self,
        impl=impl,
        member_names_map=member_names_map,
        validator=validator,
        property_impl=kwargs.pop("property_impl", None),
        action_impl=kwargs.pop("action_impl", None),
        dynamic_attributes=kwargs.pop("dynamic_attributes", False),
    )
    namespace = {**descriptors, "_thing_model": self, "__doc__": self.description}
    # create the class with the namespace
    class_def = type(a_class_name_from_title_string(self.title), (Thing,), namespace)
    thing = class_def(id=id, **kwargs.pop("thing_kwargs", {}))
    # update the delegates if any
    for descriptor in descriptors.values():
        if descriptor.delegate is not None:
            descriptor.delegate.thing = thing

    return thing