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

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_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

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

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

model_fields: ClassVar[dict[str, FieldInfo]] = {'datastructure': FieldInfo(annotation=Union[Annotated[BaseModelStructure, SerializeAsAny], NoneType], required=False, default=None), 'filename': FieldInfo(annotation=Union[Path, NoneType], required=False, default=None)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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