Namespaces¶
Namespaces adapter
Wraps the nwb_schema_language.Namespaces and other objects with convenience methods
for extracting information and generating translated schema
- class NamespacesAdapter(*, namespaces: Namespaces, schemas: List[SchemaAdapter], imported: List[NamespacesAdapter] = None)¶
Translate a NWB Namespace to a LinkML Schema
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- namespaces: Namespaces¶
- schemas: List[SchemaAdapter]¶
- imported: List[NamespacesAdapter]¶
- classmethod from_yaml(path: Path) NamespacesAdapter¶
Create a NamespacesAdapter from a nwb schema language namespaces yaml file.
Also attempts to provide imported implicitly imported schema (using the namespace key, rather than source, eg. with hdmf-common)
- build(skip_imports: bool = False, progress: AdapterProgress | None = None) BuildResult¶
Build the NWB namespace to the LinkML Schema
- find_type_source(name: str) SchemaAdapter¶
Given some neurodata_type_inc, find the schema that it’s defined in.
Rather than returning as soon as a match is found, check all
- populate_imports() None¶
Populate the imports that are needed for each schema file
This function adds a string version of imported schema assuming the generated schema will live in the same directory. If the path to the imported schema needs to be adjusted, that should happen elsewhere (eg in
LinkMLProvider) because we shouldn’t know about directory structure or anything like that here.
- to_yaml(base_dir: Path) None¶
Build the schemas, saving them to
yamlfiles according to theirname- Parameters:
base_dir (
Path) – Directory to saveyamlfiles
- property needed_imports: Dict[str, List[str]]¶
List of other, external namespaces that we need to import. Usually provided as schema with a namespace but not a source
- Returns:
[‘needed_import_0’, …]}
- Return type:
{‘namespace_name’
- schema_namespace(name: str) str | None¶
Inverse of
namespace_schemas()- given a schema name, get the namespace it’s in
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'imported': FieldInfo(annotation=List[NamespacesAdapter], required=False, default_factory=list), 'namespaces': FieldInfo(annotation=Namespaces, required=True), 'schemas': FieldInfo(annotation=List[SchemaAdapter], required=True)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.