Project
- class glotaran.project.project.Project(file: Path, folder: Path | None = None)[source]
Bases:
object
A project represents a projectfolder on disk which contains a project file.
A project file is a file in yml format with name project.gta
Attributes Summary
Get all project datasets.
Check if the project has datasets.
Check if the project has models.
Check if the project has parameters.
Check if the project has results.
Get all project models.
Get all project parameters.
Get all project results.
Methods Summary
Create a new project folder and file.
Create a scheme for optimization.
Generate a model.
Generate parameters for a model.
Get the path to a result with name
name
.Get the path to the model directory of the project.
Get the path to the parameter directory of the project.
Get the path to a result with name
name
.Import a dataset.
Load a dataset.
Load a result.
Load a model.
Load parameters.
Load a result.
Format the project as a markdown text.
Open a new project.
Optimize a model.
Methods Documentation
- static create(folder: str | Path, allow_overwrite: bool = False) Project [source]
Create a new project folder and file.
- Parameters
- Returns
The created project.
- Return type
- Raises
FileExistsError – Raised if the project file already exists and allow_overwrite=False.
- create_scheme(model_name: str, parameters_name: str, maximum_number_function_evaluations: int | None = None, clp_link_tolerance: float = 0.0) Scheme [source]
Create a scheme for optimization.
- file: Path
- generate_model(model_name: str, generator_name: str, generator_arguments: dict[str, Any], *, allow_overwrite: bool = False, ignore_existing: bool = False)[source]
Generate a model.
- Parameters
model_name (str) – The name of the model.
generator_name (str) – The generator for the model.
generator_arguments (dict[str, Any]) – Arguments for the generator.
allow_overwrite (bool) – Whether to overwrite an existing model.
ignore_existing (bool) – Whether to ignore generation of a model file if it already exists.
- generate_parameters(model_name: str, parameters_name: str | None = None, *, format_name: Literal['yml', 'yaml', 'csv'] = 'csv', allow_overwrite: bool = False, ignore_existing: bool = False)[source]
Generate parameters for a model.
- Parameters
model_name (str) – The model.
parameters_name (str | None) – The name of the parameters. If
None
it will be <model_name>_parameters.format_name (Literal["yml", "yaml", "csv"]) – The parameter format.
allow_overwrite (bool) – Whether to overwrite existing parameters.
ignore_existing (bool) – Whether to ignore generation of a parameter file if it already exists.
- get_latest_result_path(result_name: str) pathlib.Path [source]
Get the path to a result with name
name
.- Parameters
result_name (str) – The name of the result.
- Returns
The path to the result.
- Return type
Path
- Raises
ValueError – Raised if result does not exist.
- get_models_directory() pathlib.Path [source]
Get the path to the model directory of the project.
- Returns
The path to the project’s model directory.
- Return type
Path
- get_parameters_directory() pathlib.Path [source]
Get the path to the parameter directory of the project.
- Returns
The path to the project’s parameter directory.
- Return type
Path
- get_result_path(result_name: str, *, latest: bool = False) pathlib.Path [source]
Get the path to a result with name
name
.- Parameters
- Returns
The path to the result.
- Return type
Path
- Raises
ValueError – Raised if result does not exist.
- property has_data: bool
Check if the project has datasets.
- Returns
Whether the project has datasets.
- Return type
- property has_models: bool
Check if the project has models.
- Returns
Whether the project has models.
- Return type
- property has_parameters: bool
Check if the project has parameters.
- Returns
Whether the project has parameters.
- Return type
- property has_results: bool
Check if the project has results.
- Returns
Whether the project has results.
- Return type
- import_data(path: str | Path, name: str | None = None, allow_overwrite: bool = False, ignore_existing: bool = False)[source]
Import a dataset.
- load_data(dataset_name: str) xr.Dataset | xr.DataArray [source]
Load a dataset.
- Parameters
dataset_name (str) – The name of the dataset.
- Returns
The loaded dataset.
- Return type
- Raises
ValueError – Raised if the dataset does not exist.
- load_latest_result(result_name: str) glotaran.project.result.Result [source]
Load a result.
- Parameters
result_name (str) – The name of the result.
- Returns
The loaded result.
- Return type
- Raises
ValueError – Raised if result does not exist.
- load_model(name: str) glotaran.model.model.Model [source]
Load a model.
- Parameters
name (str) – The name of the model.
- Returns
The loaded model.
- Return type
- Raises
ValueError – Raised if the model does not exist.
- load_parameters(parameters_name: str) glotaran.parameter.parameter_group.ParameterGroup [source]
Load parameters.
- Parameters
parameters_name (str) – The name of the parameters.
- Returns
The loaded parameters.
- Return type
- Raises
ValueError – Raised if parameters do not exist.
- load_result(result_name: str, *, latest: bool = False) glotaran.project.result.Result [source]
Load a result.
- Parameters
- Returns
The loaded result.
- Return type
- Raises
ValueError – Raised if result does not exist.
- markdown() glotaran.utils.ipython.MarkdownStr [source]
Format the project as a markdown text.
- Returns
MarkdownStr – The markdown string.
- Return type
- classmethod open(project_folder_or_file: str | Path, create_if_not_exist: bool = True) Project [source]
Open a new project.
- Parameters
- Returns
The project instance.
- Return type
- Raises
FileNotFoundError – Raised when the project file does not not exist and create_if_not_exist is False.
- optimize(model_name: str, parameters_name: str, result_name: str | None = None, maximum_number_function_evaluations: int | None = None, clp_link_tolerance: float = 0.0)[source]
Optimize a model.