ProjectResultRegistry

class glotaran.project.project_result_registry.ProjectResultRegistry(directory: pathlib.Path)[source]

Bases: glotaran.project.project_registry.ProjectRegistry

A registry for results.

Initialize a result registry.

Parameters

directory (Path) – The registry directory.

Attributes Summary

directory

Get the registry directory.

empty

Whether the registry is empty.

items

Get the items of the registry.

result_pattern

Methods Summary

create_result_run_name

Create a result name for a model.

is_item

Check if the path contains an registry item.

load_item

Load an registry item by it's name.

markdown

Format the registry items as a markdown text.

previous_result_paths

List previous result paths with base_name.

save

Save a result.

Methods Documentation

create_result_run_name(base_name: str) str[source]

Create a result name for a model.

Parameters

base_name (str) – The base name for the result provided by user or derived from model name.

Returns

Folder name for the new result to be saved in.

Return type

str

property directory: pathlib.Path

Get the registry directory.

Returns

The registry directory.

Return type

Path

property empty: bool

Whether the registry is empty.

Returns

Whether the registry is empty.

Return type

bool

is_item(path: pathlib.Path) bool[source]

Check if the path contains an registry item.

Parameters

path (Path) – The path to check.

Returns

Whether the path contains an item.

Return type

bool

property items: dict[str, Path]

Get the items of the registry.

Returns

The items of the registry.

Return type

dict[str, Path]

load_item(name: str) Any

Load an registry item by it’s name.

Parameters

name (str) – The item name.

Returns

The loaded item.

Return type

Any

Raises

ValueError – Raise if the item does not exist.

markdown(join_indentation: int = 0) glotaran.utils.ipython.MarkdownStr

Format the registry items as a markdown text.

Parameters

join_indentation (int) – Number of whitespaces to indent when joining the parts. This is intended to be used with dedent when used in an indented f-string. Defaults to 0.

Returns

MarkdownStr – The markdown string.

Return type

str

previous_result_paths(base_name: str) list[Path][source]

List previous result paths with base_name.

Parameters

base_name (str) – The base name for the result provided by user or derived from model name.

Returns

Paths to previous results with name base_name.

Return type

list[Path]

result_pattern = re.compile('.+_run_\\d{4}$')
save(name: str, result: glotaran.project.result.Result)[source]

Save a result.

Parameters
  • name (str) – The name of the result.

  • result (Result) – The result to save.