Model Interface¶
Base Model¶
This module contains the primary objects that power GEOLib.
- class geolib.models.base_model.BaseModel(**data)¶
- Parameters
data (
Any) –
- property console_flags: List[str]¶
- Return type
List[str]
- property console_path: pathlib.Path¶
- Return type
Path
- datastructure: Optional[geolib.models.base_model_structure.BaseModelStructure]¶
- execute(timeout_in_seconds=600)¶
Execute a Model and wait for timeout seconds.
The model is modified in place if the calculation and parsing is successful.
- Parameters
timeout_in_seconds (
int) –- Return type
- execute_remote(endpoint)¶
Execute a Model on a remote endpoint.
A new model instance is returned.
- Parameters
endpoint (
HttpUrl) –- Return type
- filename: Optional[pathlib.Path]¶
- get_error_context()¶
- Return type
str
- property input¶
Access internal dict-like datastructure of the input.
- property is_valid: bool¶
Checks validity and integrity of structure.
- Return type
bool
- property output¶
Access internal dict-like datastructure of the output.
Requires a successful execute.
- parse(filename)¶
Parse input or outputfile to Model, depending on extension.
- Parameters
filename (
FilePath) –- Return type
BaseModelStructure
- abstract property parser_provider_type: Type[geolib.models.parsers.BaseParserProvider]¶
Returns the parser provider type of the current concrete class.
- Raises
NotImplementedError – If not implemented in the concrete class.
- Return type
Type[BaseParserProvider]- Returns
Type[BaseParserProvider] – Concrete parser provider.
- abstract serialize(filename)¶
Serialize model to input file.
- Parameters
filename (
Union[FilePath,DirectoryPath,None]) –- Return type
Union[FilePath,DirectoryPath,None]
- class geolib.models.base_model.BaseModelList(**data)¶
Hold multiple models that can be executed in parallel.
Note that all models need to have a unique filename otherwise they will overwrite eachother. This also helps with identifying them later.
- Parameters
data (
Any) –
- errors: List[str]¶
- execute(calculation_folder, timeout_in_seconds=600, nprocesses=2)¶
Execute all models in this class in parallel.
We split the list to separate folders and call a batch processes on each folder. Note that the order of models will change.
- Parameters
calculation_folder (
DirectoryPath) –timeout_in_seconds (
int) –nprocesses (
Optional[int]) –
- Return type
- execute_remote(endpoint)¶
Execute all models in this class in parallel on a remote endpoint.
Note that the order of models will change.
- Parameters
endpoint (
HttpUrl) –- Return type
- models: List[geolib.models.base_model.BaseModel]¶
Metadata¶
All D-Serie models store some metadata in the input files. These include projectnames, dates and times, remarks etc. All of these options are available via the Metadata class.
The Metadata class can also hold other properties for your project such as an compute endpoint.
Todo
Make a mapping between the possible metadata options and names for each model.
- class geolib.models.meta.MetaData(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)¶
Holds all metadata found in the header of model files.
Could be specified by default or in advance to make model generation easier.
Also can read these settings automatically from a ‘geolib.env’ file in the working directory, or give as ‘_env_file’ parameter.
- Parameters
_env_file (
Union[str,PathLike,None]) –_env_file_encoding (
Optional[str]) –_env_nested_delimiter (
Optional[str]) –_secrets_dir (
Union[str,PathLike,None]) –values (
Any) –
- analyst: str¶
- calculation_folder: pathlib.Path¶
- company: str¶
- console_folder: pydantic.types.DirectoryPath¶
- endpoint: pydantic.networks.AnyHttpUrl¶
- gl_password: str¶
- gl_username: str¶
- nprocesses: int¶
- project: str¶
- remarks: str¶
- startdate: datetime.datetime¶
- timeout: int¶