Namespaces#

Namespaces adapter

Wraps the nwb_schema_language.Namespaces and other objects with convenience methods for extracting information and generating translated schema

pydantic model NamespacesAdapter#

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.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

Fields:
field imported: List[NamespacesAdapter] [Optional]#
field namespaces: Namespaces [Required]#
field schemas: List[SchemaAdapter] [Required]#
build(skip_imports: bool = False, progress: AdapterProgress | None = None) BuildResult#

Generate the corresponding linkML element for this adapter

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

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)

model_post_init(__context: Any) None#

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • __context – The context.

namespace_schemas(name: str) List[str]#

Get the schemas that are defined in a given namespace

populate_imports()#

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.

schema_namespace(name: str) str | None#

Inverse of namespace_schemas() - given a schema name, get the namespace it’s in

to_yaml(base_dir: Path)#
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’

property versions: Dict[str, str]#

versions for each namespace