datamodel Reference

Generate

Filetypes

Changelog

Git

Io

datamodel.io.loaders.dm(loader, node)[source]
datamodel.io.loaders.get_yaml_files(get: str = None) str | list[source]

Get a list of yaml files

Return a list of YAML files in the datamodel directory.

Parameters:

get (str, optional) – type of yaml file to get, can be “releases” or “products”, by default None

Returns:

Union[str, list] – The yaml file path or list of yaml file paths

datamodel.io.loaders.include(loader, node)[source]
datamodel.io.loaders.read_yaml(ymlfile: str | Path) dict[source]

Opens and reads a YAML file

Parameters:

ymlfile (Union[str, pathlib.Path]) – a file or pathlib.Path object

Returns:

dict – the YAML content

datamodel.io.move.construct_new_path(file: str | Path = None, old_path: str | Path = None, new_path: str | Path = None, release: str = None, kwargs: dict = None) Path[source]

Construct a new filepath

Constructs a new filepath, either from an abstract path location and a set of keyword arguments, or from an existing (old) filepath and abstract location.

Parameters:
  • file (Union[str, pathlib.Path], optional) – the existing full filepath, by default None

  • old_path (Union[str, pathlib.Path], optional) – the existing species abstract path, by default None

  • new_path (Union[str, pathlib.Path], optional) – the new species abstract path, by default None

  • release (str, optional) – the SDSS release, by default None

  • kwargs (dict, optional) – a set of path keyword arguments, by default None

Returns:

pathlib.Path – a full filepath

datamodel.io.move.dm_move(old: str, new: str, parent: bool = None, symlink: bool = True)[source]

_summary_

_extended_summary_

Parameters:
  • old (str) – _description_

  • new (str) – _description_

  • parent (bool, optional) – _description_, by default None

  • symlink (bool, optional) – _description_, by default True

datamodel.io.move.dm_move_species(abstract_path: str, new_path: str, release: str, parent: bool = None, symlink: bool = True, test: bool = None)[source]

Moves all files from a species to a new location

Moves all files from a given file species. Finds all real files that match an existing file species abstract path, and moves them to a new location. The location is determined by the original filename, a new abstract path location, and a given release.

Parameters:
  • abstract_path (str) – the existing species abstract path

  • new_path (str) – the new species abstract path

  • release (str) – the SDSS release

  • parent (bool, optional) – flag to move the entire parent directory, by default None

  • symlink (bool, optional) – flag to create a symlink from new location to old one, by default True

  • test (bool, optional) – flag to test the move, by default None

datamodel.io.move.find_files_from_species(path: str) Iterator[source]

Find all files species from an abstract path

Finds all files matching the species pattern in a given abstract path.

Parameters:

path (str) – an abstract file species path

Returns:

Iterator – Iterator over all matching files found

Models

class datamodel.models.base.BaseList[source]

Bases: BaseModel

Base pydantic class for lists of models

list_names()[source]

Create a simplified list of name attributes

sort(field: str, key: Callable = None, **kwargs) None[source]

Sort the list of models by a pydantic field name

Performs an in-place sort of the Pydantic Models using Python’s built-in sorted() method. Sets the newly sorted list to the root attribute, to preserve the original BaseList object instance. By default, the input sort key to the sorted function is the field attribute on the model.

Parameters:
  • field (str) – The Pydantic field name

  • key (Callable, optional) – a function to be passed into the sorted() function, by default None

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class datamodel.models.base.CoreModel[source]

Bases: BaseModel

Custom BaseModel

model_config: ClassVar[ConfigDict] = {'json_schema_extra': <function add_repr>}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

datamodel.models.base.add_repr(schema: Dict[str, Any], model: Type[BaseModel]) None[source]

Adds custom information into the schema

Products

Validate