geoh5py.ui_json

geoh5py.ui_json.constants

geoh5py.ui_json.input_file

class geoh5py.ui_json.input_file.InputFile(data: dict[str, Any] = None, ui_json: dict[str, Any] = None, validations: dict = None, validation_options: dict = None)[source]

Bases: object

Handles loading ui.json input files.

Attributes
dataInput file content parsed to flat dictionary of key:value.
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
load(input_dict: dict[str, Any])[source]

Load data from dictionary and validate.

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, **kwargs)[source]

Read and create an InputFile from ui.json

property ui_json: dict | None

Dictionary representing the ui.json file with promoted values.

classmethod ui_validation(ui_json: dict[str, Any])[source]

Validation of the ui_json forms

update_ui_values(data: dict, none_map=None)[source]

Update the ui.json values and enabled status from input data.

Parameters
  • data – Key and value pairs expected by the ui_json.

  • none_map – Map parameter ‘None’ values to non-null numeric types. The parameters in the dictionary are mapped to optional and disabled.

Raises

UserWarning – If attempting to set None value to non-optional parameter.

property validation_options

Pass validation options to the validators.

property validations
property validators
property workspace
write_ui_json(name: str = None, none_map: dict[str, Any] = None, path: str = None)[source]

Writes a formatted ui.json file from InputFile data

Parameters
  • name – Name of the file

  • none_map – Map parameter None values to non-null numeric types.

  • path – Directory to write the ui.json to.

geoh5py.ui_json.templates

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(main: bool = True, label: str = 'String data', choice_list: tuple = ('Option A', 'Option B'), value: str = 'Option A', optional: str | None = None) dict[source]

Dropdown menu of string choices.

Parameters
  • main – Show form in main.

  • label – Label identifier.

  • value – Input value.

  • choice_list – List of options.

  • 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, 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’.

  • 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.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 = 0.0, vmax: float = 100.0, 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.integer_parameter(main: bool = True, label: str = 'Integer data', value: int = 1, vmin: int = 0, vmax: int = 100, 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('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('b99bd6e5-4fe1-45a5-bd2f-75fc31f91b38'), 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('f26feba3-aded-494b-b9e9-b2bbcbe298e1'), UUID('f495cd13-f09b-4a97-9212-2ea392aeb375'), UUID('0b639533-f35b-44d8-92a8-f70ecff3fd26')), value: str = 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.

  • 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.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.utils

geoh5py.ui_json.utils.collect(ui_json: dict[str, dict], member: str, value: Any = None) dict[str, Any][source]

Collects ui parameters with common field and optional value.

geoh5py.ui_json.utils.container_group2name(value)[source]
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) 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.inf2str(value)[source]
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.list2str(value)[source]
geoh5py.ui_json.utils.monitored_directory_copy(directory: str, entity: ObjectBase, copy_children: bool = True)[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.none2str(value)[source]
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.path2workspace(value)[source]
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)[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.utils.str2inf(value)[source]
geoh5py.ui_json.utils.str2list(value)[source]
geoh5py.ui_json.utils.str2none(value)[source]
geoh5py.ui_json.utils.truth(ui_json: dict[str, dict], name: str, member: str) bool[source]

Return parameter’s ‘member’ value with default value for non-existent members.

geoh5py.ui_json.utils.workspace2path(value)[source]

geoh5py.ui_json.validation

class geoh5py.ui_json.validation.InputValidation(validators: dict[str, BaseValidator] = None, validations: dict[str, Any] | None = None, workspace: Workspace = 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.
workspace (optional)Workspace instance needed to validate uuid types.
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)[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 individual key/value pairs in input.

Parameters

data – Input data with known validations.

property validations
property validators
property workspace