geolib.models.base_model

This module contains the primary objects that power GEOLib.

Functions

output_filename_from_input(model[, extension])

Classes

BaseModel(**data)

class geolib.models.base_model.BaseModel(**data)
Parameters:

data (Any)

property console_flags: List[str]
property console_flags_post: List[str]
property custom_console_path: Path | None
datastructure: Optional[Annotated[BaseModelStructure]]

This is the base class for all models in GEOLib.

Note that datastructure is a SerializeAsAny type, which means that the inheriting class is serialized according to its own definition (duck-typing). This is needed since Pydantic v2 as the default behavior has changed: https://docs.pydantic.dev/latest/concepts/serialization/#subclass-instances-for-fields-of-basemodel-dataclasses-typeddict

property default_console_path: Path
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:

BaseModel

execute_remote(endpoint)

Execute a Model on a remote endpoint.

A new model instance is returned.

Parameters:

endpoint (HttpUrl)

Return type:

BaseModel

filename: Optional[Path]
get_error_context()
Return type:

str

get_meta_property(key)

Get a metadata property from the input file.

Parameters:

key (str)

Return type:

Optional[str]

property input

Access internal dict-like datastructure of the input.

property is_valid: bool

Checks validity and integrity of structure.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'validate_assignment': True, 'validate_default': True}

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

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 (Path)

Return type:

BaseModelStructure

abstract property parser_provider_type: Type[BaseParserProvider]

Returns the parser provider type of the current concrete class.

Raises:

NotImplementedError – If not implemented in the concrete class.

Returns:

Type[BaseParserProvider] – Concrete parser provider.

abstract serialize(filename)

Serialize model to input file.

Parameters:

filename (Optional[Path])

Return type:

Optional[Path]

set_meta_property(key, value)

Set a metadata property from the input file.

Parameters:
  • key (str)

  • value (str)

Return type:

None

geolib.models.base_model.output_filename_from_input(model, extension=None)
Parameters:
Return type:

Path