geoh5py.ui_json package¶
Submodules¶
geoh5py.ui_json.constants module¶
geoh5py.ui_json.enforcers module¶
- class geoh5py.ui_json.enforcers.Enforcer(validations: set)[source]¶
Bases:
ABC
Base class for rule enforcers.
- Parameters:
enforcer_type – Type of enforcer.
validations – Value(s) to validate parameter value against.
- enforcer_type: str = ''¶
- class geoh5py.ui_json.enforcers.EnforcerPool(name: str, enforcers: list[Enforcer])[source]¶
Bases:
object
Validate data on a collection of enforcers.
- Parameters:
name – Name of parameter.
enforcers – List (pool) of enforcers.
- enforcer_types = {'required': <class 'geoh5py.ui_json.enforcers.RequiredEnforcer'>, 'required_form_members': <class 'geoh5py.ui_json.enforcers.RequiredFormMemberEnforcer'>, 'required_object_data': <class 'geoh5py.ui_json.enforcers.RequiredObjectDataEnforcer'>, 'required_uijson_parameters': <class 'geoh5py.ui_json.enforcers.RequiredUIJsonParameterEnforcer'>, 'required_workspace_object': <class 'geoh5py.ui_json.enforcers.RequiredWorkspaceObjectEnforcer'>, 'type': <class 'geoh5py.ui_json.enforcers.TypeEnforcer'>, 'type_uid': <class 'geoh5py.ui_json.enforcers.TypeUIDEnforcer'>, 'uuid': <class 'geoh5py.ui_json.enforcers.UUIDEnforcer'>, 'value': <class 'geoh5py.ui_json.enforcers.ValueEnforcer'>}¶
- classmethod from_validations(name: str, validations: SetDict) EnforcerPool [source]¶
Create enforcers pool from validations.
- Parameters:
name – Name of parameter.
validations – Encodes validations as enforcer type and validation key value pairs.
restricted_validations –
- class geoh5py.ui_json.enforcers.RequiredEnforcer(validations: set[str | tuple[str, str]])[source]¶
Bases:
Enforcer
Enforces required items in a collection.
- Parameters:
validations – Items that are required in the collection.
- Raises:
InCollectionValidationError – If collection is missing one of the required parameters/members.
- enforcer_type: str = 'required'¶
- validation_error¶
alias of
InCollectionValidationError
- class geoh5py.ui_json.enforcers.RequiredFormMemberEnforcer(validations: set[str | tuple[str, str]])[source]¶
Bases:
RequiredEnforcer
- enforcer_type: str = 'required_form_members'¶
- validation_error¶
alias of
RequiredFormMemberValidationError
- class geoh5py.ui_json.enforcers.RequiredObjectDataEnforcer(validations: set)[source]¶
Bases:
Enforcer
- collection(value: dict[str, Any]) list[list[UUID]] [source]¶
Returns list of children for all parents in validations.
- enforcer_type: str = 'required_object_data'¶
- validation_error¶
alias of
RequiredObjectDataValidationError
- class geoh5py.ui_json.enforcers.RequiredUIJsonParameterEnforcer(validations: set[str | tuple[str, str]])[source]¶
Bases:
RequiredEnforcer
- enforcer_type: str = 'required_uijson_parameters'¶
- validation_error¶
- class geoh5py.ui_json.enforcers.RequiredWorkspaceObjectEnforcer(validations: set[str | tuple[str, str]])[source]¶
Bases:
RequiredEnforcer
- collection(value: dict[str, Any]) list[UUID] [source]¶
Returns the collection to check for required items.
- enforcer_type: str = 'required_workspace_object'¶
- validation_error¶
- class geoh5py.ui_json.enforcers.TypeEnforcer(validations: set[type])[source]¶
Bases:
Enforcer
Enforces valid type(s).
- Parameters:
validations – Valid type(s) for parameter value.
- Raises:
TypeValidationError – If value is not a valid type.
- enforcer_type: str = 'type'¶
- class geoh5py.ui_json.enforcers.TypeUIDEnforcer(validations: set[str])[source]¶
Bases:
Enforcer
Enforces restricted geoh5 entity_type uid(s).
- Parameters:
validations – Valid geoh5py object type uid(s).
- Raises:
TypeValidationError – If value is not a valid type uid.
- enforcer_type: str = 'type_uid'¶
- class geoh5py.ui_json.enforcers.UUIDEnforcer(validations=None)[source]¶
Bases:
Enforcer
Enforces valid uuid string.
- Parameters:
validations – No validations needed, can be empty set.
- Raises:
UUIDValidationError – If value is not a valid uuid string.
- enforcer_type: str = 'uuid'¶
- class geoh5py.ui_json.enforcers.ValueEnforcer(validations: set[Any])[source]¶
Bases:
Enforcer
Enforces restricted value choices.
- Parameters:
validations – Valid parameter value(s).
- Raises:
ValueValidationError – If value is not a valid value choice.
- enforcer_type: str = 'value'¶
geoh5py.ui_json.forms module¶
- class geoh5py.ui_json.forms.Association(value)[source]¶
Bases:
str
,Enum
Geoh5py object association types.
- CELL = 'Cell'¶
- FACE = 'Face'¶
- VERTEX = 'Vertex'¶
- class geoh5py.ui_json.forms.BaseForm(*, label: str, value: Any, optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, **extra_data: Any)[source]¶
Bases:
BaseModel
Base class for uijson forms
- Parameters:
label – Label for ui element.
value – The parameter’s value.
optional – If True, ui element is rendered with a checkbox to control the enabled state.
enabled – If False, ui element is rendered grey and value will be written to file as None.
main – Controls whether ui element will render in the general parameters tab (True) or optional parameters (False).
tooltip – String rendered on hover over ui element.
group – Grouped ui elements will be rendered within a box labelled with the group name.
group_optional – If True, ui group is rendered with a checkbox that controls the enabled state of all of the groups members
dependency – Name of parameter that controls the enabled or visible state of the ui element.
dependency_type – Controls whether the ui element is enabled or visible when the dependency is enabled if optional or True if a bool type.
group_dependency – Name of parameter that controls the enabled or visible state of the ui group.
group_dependency_type – Controls whether the ui group is enabled or visible when the group dependency is enabled if optional or True if a bool type.
- dependency: str¶
- dependency_type: DependencyType¶
- enabled: bool¶
- group: str¶
- group_dependency: str¶
- group_dependency_type: DependencyType¶
- group_optional: bool¶
- property json_string¶
- label: str¶
- main: bool¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- optional: bool¶
- tooltip: str¶
- value: Any¶
- class geoh5py.ui_json.forms.BoolForm(*, label: str, value: bool = True, optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, **extra_data: Any)[source]¶
Bases:
BaseForm
Boolean valued uijson form.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: bool¶
- class geoh5py.ui_json.forms.ChoiceForm(*, label: str, value: list[str], optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, choiceList: list[str], multiSelect: bool = False, **extra_data: Any)[source]¶
Bases:
BaseForm
Choice list uijson form.
- choice_list: list[str]¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- multi_select: bool¶
- value: list[str]¶
- class geoh5py.ui_json.forms.DataForm(*, label: str, value: UUID | float | int, optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, parent: str, association: Association | list[Association], dataType: DataType | list[DataType], isValue: bool = False, property: UUID = UUID('00000000-0000-0000-0000-000000000000'), min: float = -inf, max: float = inf, precision: int = 2, **extra_data: Any)[source]¶
Bases:
BaseForm
Geoh5py data uijson form.
- association: Association | list[Association]¶
- is_value: bool¶
- max: float¶
- min: float¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parent: str¶
- precision: int¶
- property: UUID¶
- value: UUID | float | int¶
- class geoh5py.ui_json.forms.DataType(value)[source]¶
Bases:
str
,Enum
Geoh5py data types.
- BOOLEAN = 'Boolean'¶
- DATETIME = 'DateTime'¶
- FLOAT = 'Float'¶
- GEOMETRIC = 'Geometric'¶
- INTEGER = 'Integer'¶
- REFERENCED = 'Referenced'¶
- TEXT = 'Text'¶
- VECTOR = 'Vector'¶
- class geoh5py.ui_json.forms.DependencyType(value)[source]¶
Bases:
str
,Enum
An enumeration.
- DISABLED = 'disabled'¶
- ENABLED = 'enabled'¶
- class geoh5py.ui_json.forms.FileForm(*, label: str, value: Annotated[list[Path], BeforeValidator(func=to_path, json_schema_input_type=PydanticUndefined), BeforeValidator(func=to_list, json_schema_input_type=PydanticUndefined)], optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, fileDescription: list[str], fileType: list[str], fileMulti: bool = False, **extra_data: Any)[source]¶
Bases:
BaseForm
File path uijson form
- file_description: list[str]¶
- file_multi: bool¶
- file_type: list[str]¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: PathList¶
- class geoh5py.ui_json.forms.FloatForm(*, label: str, value: float = 1.0, optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, min: float = -inf, max: float = inf, precision: int = 2, lineEdit: bool = True, **extra_data: Any)[source]¶
Bases:
BaseForm
Float valued uijson form.
- line_edit: bool¶
- max: float¶
- min: float¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- precision: int¶
- value: float¶
- class geoh5py.ui_json.forms.IntegerForm(*, label: str, value: int = 1, optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, min: float = -inf, max: float = inf, **extra_data: Any)[source]¶
Bases:
BaseForm
Integer valued uijson form.
- max: float¶
- min: float¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: int¶
- class geoh5py.ui_json.forms.ObjectForm(*, label: str, value: UUID = UUID('00000000-0000-0000-0000-000000000000'), optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, meshType: Annotated[list[type[ObjectBase] | type[Group]], BeforeValidator(func=to_class, json_schema_input_type=PydanticUndefined), BeforeValidator(func=to_uuid, json_schema_input_type=PydanticUndefined), BeforeValidator(func=to_list, json_schema_input_type=PydanticUndefined)], **extra_data: Any)[source]¶
Bases:
BaseForm
Geoh5py object uijson form.
- mesh_type: MeshTypes¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: UUID¶
- class geoh5py.ui_json.forms.StringForm(*, label: str, value: str = '', optional: bool = False, enabled: bool = True, main: bool = True, tooltip: str = '', group: str = '', groupOptional: bool = False, dependency: str = '', dependencyType: DependencyType = DependencyType.ENABLED, groupDependency: str = '', groupDependencyType: DependencyType = DependencyType.ENABLED, **extra_data: Any)[source]¶
Bases:
BaseForm
String valued uijson form.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: str¶
geoh5py.ui_json.input_file module¶
- class geoh5py.ui_json.input_file.InputFile(*, data: dict[str, Any] | None = None, ui_json: dict[str, Any] | None = None, validate: bool = True, validations: dict | None = None, validation_options: dict | None = None, promotion: bool = True)[source]¶
Bases:
object
Handles loading ui.json input files.
- Attributes:
data
Input file content parsed to flat dictionary of key:value.Dictionary representing the input data for the ui.json file.
- ui_json: User interface serializable as ui.json format
- workspace: Target :obj:`geoh5py.workspace.Workspace`
- validations: Dictionary of validations for parameters in the input file
Methods
write_ui_json()
Writes a ui.json formatted file from ‘data’ attribute contents.
read_ui_json()
Reads a ui.json formatted file into ‘data’ attribute dictionary. Optionally filters ui.json fields other than ‘value’.
- association_validator = <geoh5py.shared.validators.AssociationValidator object>¶
- property data: dict[str, Any] | None¶
Dictionary representing the input data for the ui.json file.
- classmethod demote(var: dict[str, Any]) dict[str, Any] [source]¶
Converts promoted parameter values to their string representations.
Other parameters are left unchanged.
- property geoh5¶
Geoh5 workspace.
- property name: str | None¶
Name of ui.json file.
- classmethod numify(ui_json: dict[str, Any]) dict[str, Any] [source]¶
Convert inf, none and list strings to numerical types within a dictionary
- Parameters:
- ui_json
dictionary containing ui.json keys, values, fields
- Returns:
- Dictionary with inf, none and list string representations converted numerical types.
- property path: str | None¶
Directory for the input/output ui.json file.
- property path_name: str | None¶
- static read_ui_json(json_file: str | Path, **kwargs)[source]¶
Read and create an InputFile from ui.json
- set_data_value(key: str, value)[source]¶
Set the data and json form values from a dictionary.
- Parameters:
key – Parameter name to update.
value – Value to update with.
- static stringify(var: dict[str, Any]) dict[str, Any] [source]¶
Convert inf, none, and list types to strings within a dictionary
- Parameters:
var – Dictionary containing ui.json keys, values, fields
- Returns:
Dictionary with inf and none types converted to string representations in json format.
- property ui_json: dict | None¶
Dictionary representing the ui.json file with promoted values.
- update_ui_values(data: dict)[source]¶
Update the ui.json values and enabled status from input data.
- Parameters:
data – Key and value pairs expected by the ui_json.
- Raises:
AttributeError – If attempting to set None value to non-optional parameter.
- property validate¶
Option to run validations.
- property validation_options¶
Pass validation options to the validators.
The following options are supported:
- update_enabled: bool
If True, the enabled status of the ui_json will be updated based on the value provided. Default is True.
- ignore_list: tuple
List of keys to ignore when validating the ui_json. Default is empty tuple.
- property validations: dict | None¶
Dictionary of validations for the ui_json.
- property validators¶
geoh5py.ui_json.parameters module¶
- class geoh5py.ui_json.parameters.BoolParameter(name: str, value: bool = False)[source]¶
Bases:
Parameter
Parameter for boolean values.
- static_validations: dict[str, Any] = {'type': <class 'bool'>}¶
- class geoh5py.ui_json.parameters.DynamicallyRestrictedParameter(name: str, restrictions: Any, enforcer_type='type', value: Any | None = None)[source]¶
Bases:
Parameter
Parameter whose validations are set at runtime.
- property restrictions¶
- property validations¶
Returns a dictionary of static validations.
- class geoh5py.ui_json.parameters.FloatParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for float values.
- static_validations: dict[str, Any] = {'type': <class 'float'>}¶
- class geoh5py.ui_json.parameters.IntegerParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for integer values.
- static_validations: dict[str, Any] = {'type': <class 'int'>}¶
- class geoh5py.ui_json.parameters.NumericParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for generic numeric values.
- static_validations: dict[str, Any] = {'type': [<class 'int'>, <class 'float'>]}¶
- class geoh5py.ui_json.parameters.Parameter(name: str, value: Any | None = None)[source]¶
Bases:
object
Basic parameter to store key/value data with validation capabilities.
- Parameters:
name – Parameter name.
value – The parameters value.
enforcers – A collection of enforcers.
- static_validations: dict[str, Any] = {}¶
- property validations¶
Returns a dictionary of static validations.
- property value¶
- class geoh5py.ui_json.parameters.PropertyGroupParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for property group objects.
- static_validations: dict[str, Any] = {'type': <class 'geoh5py.groups.property_group.PropertyGroup'>}¶
- class geoh5py.ui_json.parameters.StringListParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for list of strings.
- static_validations: dict[str, Any] = {'type': [<class 'list'>, <class 'str'>]}¶
- class geoh5py.ui_json.parameters.StringParameter(name: str, value: Any | None = None)[source]¶
Bases:
Parameter
Parameter for string values.
- static_validations: dict[str, Any] = {'type': <class 'str'>}¶
- class geoh5py.ui_json.parameters.TypeRestrictedParameter(name: str, restrictions: list[Any], value: Any | None = None)[source]¶
Bases:
DynamicallyRestrictedParameter
Parameter with a restricted set of types known at runtime only.
- class geoh5py.ui_json.parameters.TypeUIDRestrictedParameter(name: str, restrictions: list[UUID], value: Any | None = None)[source]¶
Bases:
DynamicallyRestrictedParameter
Parameter with a restricted set of type uids known at runtime only.
- class geoh5py.ui_json.parameters.ValueRestrictedParameter(name: str, restrictions: Any, value: Any | None = None)[source]¶
Bases:
DynamicallyRestrictedParameter
Parameter with a restricted set of values.
geoh5py.ui_json.templates module¶
- geoh5py.ui_json.templates.bool_parameter(main: bool = True, label: str = 'Logical data', value: bool = False) dict [source]¶
Checkbox for true/false choice.
- Parameters:
main – Show ui in main.
label – Label identifier.
value – Input value.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.choice_string_parameter(*, choice_list: tuple = ('Option A', 'Option B'), label: str = 'String data', main: bool = True, multi_select: bool = False, optional: str | None = None, value: str = 'Option A') dict [source]¶
Dropdown menu of string choices.
- Parameters:
main – Show form in main.
choice_list – List of options.
label – Label identifier.
multi_select – Option to select multiple choices.
value – Input value.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.data_parameter(*, main: bool = True, label: str = 'Data channel', association: str = 'Vertex', data_type: str = 'Float', data_group_type: str | None = None, parent: str = '', value: str = '', optional: str | None = None) dict [source]¶
Dropdown menu of data from parental object.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
association – Data association type from ‘Vertex’ or ‘Cell’.
data_type – Type of data selectable from ‘Float’, ‘Integer’ or ‘Reference’.
data_group_type – [Optional] Select from property_groups of type. ‘3D vector’, ‘Dip direction & dip’, ‘Strike & dip’, or ‘Multi-element’.
multi_select – Option to select multiple choices.
parent – Parameter name corresponding to the parent object.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.data_value_parameter(*, main: bool = True, label: str = 'Data channel', association: str = 'Vertex', data_type: str = 'Float', parent: str = '', value: float = 0.0, is_value: bool = True, prop: UUID | Entity | None = None, optional: str | None = None) dict [source]¶
Dropdown of data or input box.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
association – Data association type from ‘Vertex’ or ‘Cell’.
data_type – Type of data selectable from ‘Float’, ‘Integer’ or ‘Reference’.
data_group_type – [Optional] Select from property_groups of type. ‘3D vector’, ‘Dip direction & dip’, ‘Strike & dip’, or ‘Multi-element’.
parent – Parameter name corresponding to the parent object.
is_value – Display the input box or dropdown menu.
prop – Data entity selected in the dropdown menu if ‘is_value=False’.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.drillhole_group_data(*, value: list[str] | None = None, main: bool = True, label: str = 'Data channel', group_type: UUID | None = UUID('825424fb-c2c6-4fea-9f2b-6cd00023d393'), group_value: UUID | None = None, multiselect: bool = True, optional: str | None = None, enabled: bool = True, tooltip: str = 'Select the data channel to use for the calculation.') dict [source]¶
Dropdown of data or input box.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
group_type – The group type to select, must be drillhole group.
group_value – The selected group UUID.
multiselect – Allow multiple data selection.
value – The name of the Data channel to extract.
optional – Make optional if not None. Initial state provided by not None
enabled – Enable or disable the form.
tooltip – The tooltip to display when hovering over the form.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.file_parameter(*, main: bool = True, label: str = 'File choices', file_description: tuple = (), file_type: tuple = (), value: str = '', optional: str | None = None) dict [source]¶
File loader for specific extensions.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
file_description – Title used to describe each type.
file_type – Extension of files to display.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.float_parameter(*, main: bool = True, label: str = 'Float data', value: float = 1.0, vmin: float | None = None, vmax: float | None = None, precision: int = 2, line_edit: bool = True, optional: str | None = None) dict [source]¶
Input box for float value.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
vmin – Minimum value allowed.
vmax – Maximum value allowed.
line_edit – Allow line edit or spin box
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.group_parameter(*, main: bool = True, label: str = 'Object', group_type: tuple = (UUID('812f3b2a-fdae-4752-8391-3b657953a983'), UUID('3d0e8578-7764-48cf-8db8-6c83d6411762'), UUID('f55d8ae4-3829-11e4-a70e-fcddabfddab1'), UUID('e2040afa-3829-11e4-a70e-fcddabfddab1'), UUID('61fbb4e8-a480-11e3-8d5a-2776bdf4f982'), UUID('bb60b1b9-4f3c-4cc7-b6fe-b417a0670e62'), UUID('825424fb-c2c6-4fea-9f2b-6cd00023d393'), UUID('adee3b2a-3829-11e4-a70e-fcddabfddab1'), UUID('72f29283-a4f6-4fc0-a1a8-1417ce5fcbec'), UUID('ed00094f-3da1-485f-8c4e-b52f6f171ea4'), UUID('151778d9-6cc0-4e72-ba08-2a80a4fb967f'), UUID('585b3218-c24b-41fe-ad1f-24d5e6e8348a'), UUID('47d6f059-b56a-46c7-8fc7-a0ded87360c3'), UUID('016dfd26-7d9b-49a6-97d8-cb31c37e404b'), UUID('136cb431-c7d2-4992-a5ab-46a6e16b6726'), UUID('952829b6-76a2-4d0b-b908-7f8d2482dc0d'), UUID('61449477-3833-11e4-a7fb-fcddabfddab1'), UUID('1f684938-2baf-4a01-ac71-e50c30cc0685'), UUID('4d65f8c3-a015-4c01-b411-412c0f4f0884'), UUID('2a5b7faa-41d1-4437-afac-934933eae6eb'), UUID('56f6f03e-3833-11e4-a7fb-fcddabfddab1'), UUID('27ee59e1-b1ce-41ec-8a86-8bd3d229e198'), UUID('7508bc11-3829-11e4-9cce-fcddabfddab1'), UUID('dd99b610-be92-48c0-873c-5b5946ea2840'), UUID('f65e521c-a763-427b-97bf-d0b4e5689e0d'), UUID('85756113-592a-4088-b374-f32c8fac37a2'), UUID('cbeb3920-a1a9-46f8-ab2b-7dfdf79c8a00'), UUID('dd99b610-be92-48c0-873c-5b5946ea2840'), UUID('1cde9996-cda7-40f0-8c20-faeb4e926748'), UUID('55ed3daf-c192-4d4b-a439-60fa987fe2b8'), UUID('bb50ac61-a657-4926-9c82-067658e246a0')), value: str | None = None, optional: str | None = None) dict [source]¶
Dropdown menu of groups of specific types.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
group_type – Type of selectable groups.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.integer_parameter(*, main: bool = True, label: str = 'Integer data', value: int = 1, vmin: int | None = None, vmax: int | None = None, optional: str | None = None) dict [source]¶
Input box for integer value.
- Parameters:
main – Show ui in main.
label – Label identifier.
value – Input value.
vmin – Minimum value allowed.
vmax – Maximum value allowed.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.object_parameter(*, main: bool = True, label: str = 'Object', mesh_type: tuple = (UUID('b3a47539-0301-4b27-922e-1dde9d882c60'), UUID('a006cf3e-e24a-4c02-b904-2e57b9b5916d'), UUID('4b99204c-d133-4579-a916-a9c8b98cfccb'), UUID('19730589-fd28-4649-9de0-ad47249d9aba'), UUID('58c4849f-41e2-4e09-b69b-01cf4286cded'), UUID('b020a277-90e2-4cd7-84d6-612ee3f25051'), UUID('9b08bb5a-300c-48fe-9007-d206f971ea92'), UUID('6a057fdc-b355-11e3-95be-fd84a7ffcb88'), UUID('c94968ea-cf7d-11eb-b8bc-0242ac130003'), UUID('7caebf0e-d16e-11e3-bc69-e4632694aa37'), UUID('77ac043c-fe8d-4d14-8167-75e300fb835a'), UUID('48f5054a-1c5c-4ca4-9048-80f36dc60a06'), UUID('6832acf3-78aa-44d3-8506-9574a3510c44'), UUID('e79f449d-74e3-4598-9c9c-351a28b8b69e'), UUID('30928322-cf2c-4230-b393-4dc629259b64'), UUID('fe1a240a-9189-49ff-aa7e-6067405b6e0a'), UUID('deebe11a-b57b-4a03-99d6-8f27b25eb2a8'), UUID('17dbbfbb-3ee4-461c-9f1d-1755144aac90'), UUID('b99bd6e5-4fe1-45a5-bd2f-75fc31f91b38'), UUID('a81c6b0a-f290-4bc8-b72d-60e59964bfe8'), UUID('f59d5a1c-5e63-4297-b5bc-43898cb4f5f8'), UUID('41018a45-01a0-4c61-a7cb-9f32d8159df4'), UUID('98a96d44-6144-4adb-afbe-0d5e757c9dfc'), UUID('88087fb8-76ae-445b-9cdf-68dbce530404'), UUID('849d2f3e-a46e-11e3-b401-2776bdf4f982'), UUID('4ea87376-3ece-438b-bf12-3479733ded46'), UUID('202c5db1-a56d-4004-9cad-baafd8899406'), UUID('275ecee9-9c24-4378-bf94-65f3c5fbe163'), UUID('238f961d-ae63-43de-ab64-e1a079271cf5'), UUID('f26feba3-aded-494b-b9e9-b2bbcbe298e1'), UUID('f495cd13-f09b-4a97-9212-2ea392aeb375'), UUID('0b639533-f35b-44d8-92a8-f70ecff3fd26')), multi_select: bool = False, value: str | None = None, optional: str | None = None) dict [source]¶
Dropdown menu of objects of specific types.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input value.
multi_select – Option to select multiple choices.
mesh_type – Type of selectable objects.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
- geoh5py.ui_json.templates.optional_parameter(state: str) dict[str, bool] [source]¶
Returns dictionary to make existing ui optional via .update() method.
- Parameters:
state – Initial state of optional parameter. Can be ‘enabled’ or ‘disabled’.
- geoh5py.ui_json.templates.range_label_template(*, main: bool = True, label: str = 'Range', allow_complement: bool = False, is_complement: bool = False, parent: str = '', property_: str | UUID = '', association: str = 'Vertex', data_type: list[str] | str = 'Float', value: list[float | int] | None = None, range_label: str = 'Values', enabled: bool = True, optional: str | None = None) dict [source]¶
Template for range label.
Or it is a multiselect data on a property group if referenced data. Or they are 2 values, an upper and lower bound as float values. In the second scenario, is_complement allows to invert the range.
- Parameters:
main – Show form in main.
label – The label identifier.
allow_complement – If users can invert the range.
is_complement – If the range is inverted.
parent – The parent object.
property – The property uid associated with the range.
association – The association type.
data_type – The data type of the range.
value – The value of the range.
range_label – The label of the range.
enabled – The state of the form.
optional – Make optional if not None. Initial state provided by not None.
- Returns:
The form dictionary.
- geoh5py.ui_json.templates.string_parameter(*, main: bool = True, label: str = 'String data', value: str = 'data', optional: str | None = None) dict [source]¶
Input box for string value.
- Parameters:
main – Show form in main.
label – Label identifier.
value – Input string value.
optional – Make optional if not None. Initial state provided by not None value. Can be either ‘enabled’ or ‘disabled’.
- Returns:
Ui_json compliant dictionary.
geoh5py.ui_json.ui_json module¶
- class geoh5py.ui_json.ui_json.BaseUIJson(*, title: str, geoh5: Path | None, run_command: str, monitoring_directory: Path, conda_environment: str, workspace_geoh5: Path)[source]¶
Bases:
BaseModel
Base class for storing ui.json data on disk.
- Params title:
Title of the application.
- Params geoh5:
Path to the geoh5 file.
- Params run_command:
Command to run the application.
- Params run_command_boolean:
Boolean to run the command.
- Params monitoring_directory:
Directory to monitor for changes.
- Params conda_environment:
Conda environment to run the application.
- Params conda_environment_boolean:
Boolean to run the conda environment.
- Params workspace_geoh5:
Path to the workspace geoh5 file.
- conda_environment: str¶
- geoh5: Path | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- monitoring_directory: Path¶
- run_command: str¶
- title: str¶
- to_params(workspace: Workspace | None = None) dict[str, Any] [source]¶
Promote, flatten and validate parameter/values dictionary.
- Parameters:
workspace – Workspace to fetch entities from. Used for passing active workspaces to avoid closing and flushing data.
- validate_data(params: dict[str, Any] | None = None, errors: dict[str, Any] | None = None)[source]¶
Validate the UIJson data.
- Parameters:
params – Promoted and flattened parameters/values dictionary. The params dictionary will be generated from the model values if not provided.
errors – Optionally pass existing errors. Primarily for the to_params method.
- Raises:
UIJsonError – If any validations fail.
- workspace_geoh5: Path¶
geoh5py.ui_json.utils module¶
- geoh5py.ui_json.utils.collect(ui_json: dict[str, dict], member: str, value: Any | None = None) dict[str, Any] [source]¶
Collects ui parameters with common field and optional value.
- geoh5py.ui_json.utils.dependency_requires_value(ui_json: dict[str, dict], parameter: str) bool [source]¶
Handles dependency and optional requirements.
If dependency doesn’t require a value then the function returns False. But if the dependency does require a value, the return value is either True, or will take on the enabled state if the dependent parameter is optional.
- Parameters:
ui_json – UI.json dictionary
parameter – Name of parameter to check type.
- geoh5py.ui_json.utils.find_all(ui_json: dict[str, dict], member: str, value: Any | None = None) list[str] [source]¶
Returns names of all collected parameters.
- geoh5py.ui_json.utils.flatten(ui_json: dict[str, dict]) dict[str, Any] [source]¶
Flattens ui.json format to simple key/value pair.
- geoh5py.ui_json.utils.group_enabled(group: dict[str, dict]) bool [source]¶
Return true if groupOptional and enabled are both true.
- Parameters:
group – UI.json dictionary
- geoh5py.ui_json.utils.group_optional(ui_json: dict[str, dict], group_name: str) bool [source]¶
Returns groupOptional bool for group name.
- geoh5py.ui_json.utils.group_requires_value(ui_json: dict[str, dict], parameter: str) bool [source]¶
True is groupOptional and group is enabled else False
- Parameters:
ui_json – UI.json dictionary
parameter – Name of parameter to check type.
- geoh5py.ui_json.utils.is_form(var) bool [source]¶
Return true if dictionary ‘var’ contains both ‘label’ and ‘value’ members.
- geoh5py.ui_json.utils.is_uijson(ui_json: dict[str, dict])[source]¶
Returns True if dictionary contains all the required parameters.
- geoh5py.ui_json.utils.monitored_directory_copy(directory: str, entity: ObjectBase | Group, copy_children: bool = True) str [source]¶
Create a temporary geoh5 file in the monitoring folder and export entity for update.
- Parameters:
directory – Monitoring directory
entity – Entity to be updated
copy_children – Option to copy children entities.
- geoh5py.ui_json.utils.optional_requires_value(ui_json: dict[str, dict], parameter: str) bool [source]¶
True if enabled else False.
- Parameters:
ui_json – UI.json dictionary
parameter – Name of parameter to check type.
- geoh5py.ui_json.utils.requires_value(ui_json: dict[str, dict], parameter: str) bool [source]¶
Check if a ui.json parameter requires a value (is not optional).
The required status of a parameter depends on a hierarchy of ui switches. At the top is the groupOptional switch, below that is the dependency switch, and on the bottom is the optional switch. When group optional is disabled all parameters in the group are not required, When the groupOptional is enabled the required status of a parameter depends first any dependencies and lastly on it’s optional status.
- Parameters:
ui_json – UI.json dictionary
parameter – Name of parameter to check type.
- geoh5py.ui_json.utils.set_enabled(ui_json: dict, parameter: str, value: bool, validate=True)[source]¶
Set enabled status for an optional or groupOptional parameter.
- Parameters:
ui_json – UI.json dictionary
parameter – Parameter name.
value – Boolean value set to parameter’s enabled member.
geoh5py.ui_json.validation module¶
- class geoh5py.ui_json.validation.InputValidation(validators: dict[str, BaseValidator] | None = None, validations: dict[str, Any] | None = None, ui_json: dict[str, Any] | None = None, validation_options: dict[str, Any] | None = None)[source]¶
Bases:
object
Validations on dictionary of parameters.
- Attributes:
- validationsValidations dictionary with matching set of input parameter keys.
- ignore_requirements (optional): Omit raising error on ‘required’ validator.
Methods
validate_data(data)
Validates data of params and contents/type/shape/keys/reqs of values.
- static infer_validations(ui_json: dict[str, Any] | None, validations: dict[str, dict] | None = None) dict [source]¶
Infer necessary validations from ui json structure.
- validate(name: str, value: Any, validations: dict[str, Any] | None = None)[source]¶
Run validations on a given key and value.
- Parameters:
name – Parameter identifier.
value – Input parameter value.
validations – [Optional] Validations provided on runtime
- validate_data(data: dict[str, Any]) None [source]¶
Calls validate method on ui.json data structure for cross-dependencies.
Individual key, value pairs are validated for expected type.
- Parameters:
data – Input data with known validations.
- property validations¶
- property validators¶