geoh5py.ui_json package#
Subpackages#
Submodules#
geoh5py.ui_json.constants module#
geoh5py.ui_json.enforcers module#
- class geoh5py.ui_json.enforcers.Enforcer(validations: set)#
Bases:
ABCBase class for rule enforcers.
- Parameters:
enforcer_type – Type of enforcer.
validations – Value(s) to validate parameter value against.
- abstract enforce(name: str, value: Any)#
Enforces rule on ‘name’ parameter’s ‘value’.
- enforcer_type: str = ''#
- abstract rule(value: Any)#
True if ‘value’ adheres to enforcers rule.
- class geoh5py.ui_json.enforcers.EnforcerPool(name: str, enforcers: list[Enforcer])#
Bases:
objectValidate data on a collection of enforcers.
- Parameters:
name – Name of parameter.
enforcers – List (pool) of enforcers.
- enforce(value: Any)#
Enforce rules from all enforcers in the pool.
- 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#
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]])#
Bases:
EnforcerEnforces 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.
- collection(value: Any) list[Any]#
Returns the collection to check for required items.
- enforce(name: str, value: Any)#
Administers rule to check if required items in collection.
- enforcer_type: str = 'required'#
- rule(value: Any) bool#
True if all required parameters are in ‘value’ collection.
- validation_error#
alias of
InCollectionValidationError
- class geoh5py.ui_json.enforcers.RequiredFormMemberEnforcer(validations: set[str | tuple[str, str]])#
Bases:
RequiredEnforcer- enforcer_type: str = 'required_form_members'#
- validation_error#
alias of
RequiredFormMemberValidationError
- class geoh5py.ui_json.enforcers.RequiredObjectDataEnforcer(validations: set)#
Bases:
Enforcer- collection(value: dict[str, Any]) list[list[UUID]]#
Returns list of children for all parents in validations.
- enforce(name: str, value: Any)#
Administers rule to check if required items in collection.
- enforcer_type: str = 'required_object_data'#
- rule(value: Any) bool#
True if object/data have parent/child relationship.
- validation_error#
alias of
RequiredObjectDataValidationError
- class geoh5py.ui_json.enforcers.RequiredUIJsonParameterEnforcer(validations: set[str | tuple[str, str]])#
Bases:
RequiredEnforcer- enforcer_type: str = 'required_uijson_parameters'#
- validation_error#
- class geoh5py.ui_json.enforcers.RequiredWorkspaceObjectEnforcer(validations: set[str | tuple[str, str]])#
Bases:
RequiredEnforcer- collection(value: dict[str, Any]) list[UUID]#
Returns the collection to check for required items.
- enforcer_type: str = 'required_workspace_object'#
- rule(value: Any) bool#
True if all objects are in the workspace.
- validation_error#
- class geoh5py.ui_json.enforcers.TypeEnforcer(validations: set[type])#
Bases:
EnforcerEnforces valid type(s).
- Parameters:
validations – Valid type(s) for parameter value.
- Raises:
TypeValidationError – If value is not a valid type.
- enforce(name: str, value: Any)#
Administers rule to enforce type validation.
- enforcer_type: str = 'type'#
- rule(value) bool#
True if value is one of the valid types.
- class geoh5py.ui_json.enforcers.TypeUIDEnforcer(validations: set[str])#
Bases:
EnforcerEnforces restricted geoh5 entity_type uid(s).
- Parameters:
validations – Valid geoh5py object type uid(s).
- Raises:
TypeValidationError – If value is not a valid type uid.
- enforce(name: str, value: Any)#
Administers rule to enforce type uid validation.
- enforcer_type: str = 'type_uid'#
- rule(value: Any) bool#
True if value is a valid type uid.
- class geoh5py.ui_json.enforcers.UUIDEnforcer(validations=None)#
Bases:
EnforcerEnforces valid uuid string.
- Parameters:
validations – No validations needed, can be empty set.
- Raises:
UUIDValidationError – If value is not a valid uuid string.
- enforce(name: str, value: Any)#
Administers rule to check if valid uuid.
- enforcer_type: str = 'uuid'#
- rule(value: Any) bool#
True if value is a valid uuid string.
- class geoh5py.ui_json.enforcers.ValueEnforcer(validations: set[Any])#
Bases:
EnforcerEnforces restricted value choices.
- Parameters:
validations – Valid parameter value(s).
- Raises:
ValueValidationError – If value is not a valid value choice.
- enforce(name: str, value: Any)#
Administers rule to enforce value validation.
- enforcer_type: str = 'value'#
- rule(value: Any) bool#
True if value is a valid choice.
geoh5py.ui_json.forms module#
- class geoh5py.ui_json.forms.Association(value)#
Bases:
str,EnumGeoh5py 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)#
Bases:
BaseModelBase 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.
verbose – Sets the level at which Geoscience Analyst will make the parameter visible in a ui.json file. Verbosity level is set within Analyst menu.
- dependency: str#
- dependency_type: DependencyType#
- enabled: bool#
- flatten()#
Returns the data for the form.
- group: str#
- group_dependency: str#
- group_dependency_type: DependencyType#
- group_optional: bool#
- classmethod infer(data: dict[str, Any]) type[BaseForm]#
Infer and return the appropriate form.
- Parameters:
data – Dictionary of form data.
- 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- optional: bool#
- tooltip: str#
- validate_data(params: dict[str, Any])#
Validate the form data.
- 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)#
Bases:
BaseFormBoolean valued uijson form.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_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: 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], **extra_data: Any)#
Bases:
BaseFormChoice 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- valid_choice()#
- value: str#
- class geoh5py.ui_json.forms.DataForm(*, label: str, value: Annotated[UUID | float | int | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=uuid_to_string_or_numeric, return_type=PydanticUndefined, when_used=always)], 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: Annotated[UUID | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=uuid_to_string, return_type=PydanticUndefined, when_used=always)] = None, min: float = -inf, max: float = inf, precision: int = 2, **extra_data: Any)#
Bases:
BaseFormGeoh5py data uijson form.
- association: Association | list[Association]#
- flatten()#
Returns the data for the form.
- 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parent: str#
- precision: int#
- property: OptionalUUID#
- property_if_not_is_value()#
- value: UUIDOrNumber#
- value_if_is_value()#
- class geoh5py.ui_json.forms.DataType(value)#
Bases:
str,EnumGeoh5py 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)#
Bases:
str,EnumAn enumeration.
- DISABLED = 'disabled'#
- ENABLED = 'enabled'#
- HIDE = 'hide'#
- SHOW = 'show'#
- 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, directoryOnly: bool = False, **extra_data: Any)#
Bases:
BaseFormFile path uijson form
- classmethod directory_file_type(data)#
- directory_only: bool#
- 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- same_length()#
- to_string(value)#
- classmethod valid_file(value)#
- value: PathList#
- value_file_type()#
- 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)#
Bases:
BaseFormFloat 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, 'validate_by_alias': True, 'validate_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.GroupForm(*, label: str, value: Annotated[UUID | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=uuid_to_string, return_type=PydanticUndefined, when_used=always)], 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, groupType: Annotated[list[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), PlainSerializer(func=types_to_string, return_type=PydanticUndefined, when_used=json)], **extra_data: Any)#
Bases:
BaseFormGeoh5py group uijson form.
- group_type: GroupTypes#
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: OptionalUUID#
- 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)#
Bases:
BaseFormInteger 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: int#
- class geoh5py.ui_json.forms.MultiChoiceForm(*, 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 = True, **extra_data: Any)#
Bases:
BaseFormMulti-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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- multi_select: bool#
- classmethod only_multi_select(value)#
- classmethod to_list(value)#
- valid_choice()#
- value: list[str]#
- class geoh5py.ui_json.forms.ObjectForm(*, label: str, value: Annotated[UUID | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=uuid_to_string, return_type=PydanticUndefined, when_used=always)], 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]], 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), PlainSerializer(func=types_to_string, return_type=PydanticUndefined, when_used=json)], **extra_data: Any)#
Bases:
BaseFormGeoh5py 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, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- value: OptionalUUID#
- class geoh5py.ui_json.forms.RadioLabelForm(*, 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, originalLabel: str, alternateLabel: str, **extra_data: Any)#
Bases:
StringFormRadio button for two-option strings.
The uijson dialogue will render two radio buttons with label choices. Any form labels within the ui.json containing the string matching the original button will be altered to the reflect the new button choice.
- Parameters:
original_label – Label for the original value.
alternative_label – Label for the alternative value.
- alternate_label: str#
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- original_label: str#
- 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)#
Bases:
BaseFormString valued uijson form.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'extra': 'allow', 'frozen': True, 'loc_by_alias': True, 'populate_by_name': True, 'validate_by_alias': True, 'validate_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)#
Bases:
objectHandles loading ui.json input files.
Attributes#
data : Input file content parsed to flat dictionary of key:value. ui_json: User interface serializable as ui.json format workspace: Target
geoh5py.workspace.Workspacevalidations: Dictionary of validations for parameters in the input fileMethods#
- 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>#
- copy(clear_cache: bool = False, validate: bool = True, **kwargs) InputFile#
Create a copy of the input file, and copying the relatives to a new workspace.
- Parameters:
clear_cache – Indicate whether to clear the cache.
validate – Indicate whether to validate the new input file.
kwargs – The parameters to update in the new input file ui_json.
- Returns:
The new input file.
- copy_relatives(parent: Workspace, clear_cache: bool = False)#
Copy the entities referenced in the input file to a new workspace.
- Parameters:
parent – The parent to copy the entities to.
clear_cache – Indicate whether to clear the cache.
- property data: dict[str, Any] | None#
Dictionary representing the input data for the ui.json file.
- property geoh5#
Geoh5 workspace.
- property name: str | None#
Name of ui.json file.
If the name is the default name, it get overridden by the title if exists.
- classmethod numify(ui_json: dict[str, Any]) dict[str, Any]#
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#
- promote(var: dict[str, Any]) dict[str, Any]#
Convert uuids to entities from the workspace.
TODO: change validation to use a simpler function here?
- Parameters:
var – Dictionary to promote.
- Returns:
Promoted dictionary.
- static read_ui_json(json_file: str | Path, **kwargs)#
Read and create an InputFile from ui.json
- set_data_value(key: str, value)#
Set the data and json form values from a dictionary.
- Parameters:
key – Parameter name to update.
value – Value to update with.
- property ui_json: dict | None#
Dictionary representing the ui.json file with promoted values.
- classmethod ui_validation(ui_json: dict[str, Any])#
Validation of the ui_json forms
- update_ui_values(data: dict)#
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#
- write_ui_json(name: str | None = None, path: str | Path | None = None)#
Writes a formatted ui.json file from InputFile data
- Parameters:
name – Name of the file
path – Directory to write the ui.json to.
geoh5py.ui_json.parameters module#
- class geoh5py.ui_json.parameters.BoolParameter(name: str, value: bool = False)#
Bases:
ParameterParameter 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)#
Bases:
ParameterParameter 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)#
Bases:
ParameterParameter for float values.
- static_validations: dict[str, Any] = {'type': <class 'float'>}#
- class geoh5py.ui_json.parameters.IntegerParameter(name: str, value: Any | None = None)#
Bases:
ParameterParameter for integer values.
- static_validations: dict[str, Any] = {'type': <class 'int'>}#
- class geoh5py.ui_json.parameters.NumericParameter(name: str, value: Any | None = None)#
Bases:
ParameterParameter 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)#
Bases:
objectBasic 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] = {}#
- validate()#
Validates data against the pool of enforcers.
- property validations#
Returns a dictionary of static validations.
- property value#
- class geoh5py.ui_json.parameters.PropertyGroupParameter(name: str, value: Any | None = None)#
Bases:
ParameterParameter 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)#
Bases:
ParameterParameter 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)#
Bases:
ParameterParameter 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)#
Bases:
DynamicallyRestrictedParameterParameter 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)#
Bases:
DynamicallyRestrictedParameterParameter 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)#
Bases:
DynamicallyRestrictedParameterParameter 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#
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#
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#
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#
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#
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#
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#
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 | str = (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('e93794b2-525b-45e5-8900-a9426b6b4319'), 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#
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: None | int = None, vmax: None | int = None, optional: str | None = None) dict#
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('c00905d1-bc3b-4d12-9f93-07fcf1450270'), UUID('f495cd13-f09b-4a97-9212-2ea392aeb375'), UUID('0b639533-f35b-44d8-92a8-f70ecff3fd26'), UUID('7d37f28f-f379-4006-984e-043db439ee95')), multi_select: bool = False, value: str | None = None, optional: str | None = None) dict#
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]#
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#
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#
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(*, version: str, title: str, geoh5: Path | None, run_command: str, monitoring_directory: Annotated[Path | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=none_to_empty_string, return_type=PydanticUndefined, when_used=always)], conda_environment: str, workspace_geoh5: Annotated[Path | None, BeforeValidator(func=empty_string_to_none, json_schema_input_type=PydanticUndefined), PlainSerializer(func=none_to_empty_string, return_type=PydanticUndefined, when_used=always)] | None = None, **extra_data: Any)#
Bases:
BaseModelBase 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#
- property groups: dict[str, list[str]]#
Returns grouped forms.
- is_disabled(field: str) bool#
Checks if a field is disabled based on form status.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None#
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.
- monitoring_directory: OptionalPath#
- classmethod read(path: Path)#
Create a UIJson object from file.
- run_command: str#
- title: str#
- to_params(workspace: Workspace | None = None) dict[str, Any]#
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)#
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.
- version: str#
- workspace_geoh5: OptionalPath | None#
- classmethod workspace_path_exists(path: Path)#
- write(path: Path)#
Write the UIJson object to file.
geoh5py.ui_json.utils module#
- geoh5py.ui_json.utils.collect(ui_json: dict[str, dict[str, Any]], member: str, value: Any | None = None) dict[str, dict[str, Any]]#
Collect UI parameters with a common field and optional value.
Searches through the ui_json dictionary for parameters that contain a specific member field, optionally filtering by the value of that field.
- Parameters:
ui_json – The UI JSON dictionary to search through.
member – The field name to search for in each parameter.
value – Optional value to match against the member field.
- Returns:
Dictionary of parameters that match the criteria.
- geoh5py.ui_json.utils.container_group2name(value: Any) Any#
Convert a ContainerGroup object to its name string.
Deprecated: This function will be removed in future releases.
- Parameters:
value – ContainerGroup object or other value to convert.
- Returns:
Name string for ContainerGroup objects, original value otherwise.
- geoh5py.ui_json.utils.dependency_requires_value(ui_json: dict[str, dict[str, Any]], parameter: str) bool#
Check if a parameter requires a value based on its dependency constraints.
Handles dependency and optional requirements for parameters. If a dependency doesn’t require a value then the function returns False. 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 containing the parameters.
parameter – Name of the parameter to check.
- Returns:
True if the parameter requires a value based on dependencies, False otherwise.
- geoh5py.ui_json.utils.find_all(ui_json: dict[str, dict[str, Any]], member: str, value: Any | None = None) list[str]#
Return names of all parameters matching the given criteria.
Convenience function that returns just the parameter names from the collect function results.
- Parameters:
ui_json – The UI JSON dictionary to search through.
member – The field name to search for in each parameter.
value – Optional value to match against the member field.
- Returns:
List of parameter names that match the criteria.
- geoh5py.ui_json.utils.flatten(ui_json: dict[str, dict[str, Any]]) dict[str, Any]#
Flatten ui.json format to simple key/value pairs.
Converts the nested ui.json structure to a flat dictionary where most fields have their values extracted from the ‘value’ member. For widgets storing multiple values, the values are passed as a dictionary.
- Parameters:
ui_json – The form containing the UI data to flatten.
- Returns:
A flattened dictionary with parameter names as keys and their values.
- geoh5py.ui_json.utils.group_enabled(group: dict[str, dict[str, Any]]) bool#
Check if a group is enabled based on groupOptional and enabled flags.
Returns True if both groupOptional and enabled are True for the group.
- Parameters:
group – UI JSON group dictionary containing parameters.
- Returns:
True if the group is enabled, False otherwise.
- Raises:
ValueError – If the provided group does not contain a parameter with groupOptional member.
- geoh5py.ui_json.utils.group_optional(ui_json: dict[str, dict[str, Any]], group_name: str) bool#
Check if a group has the groupOptional flag enabled.
Searches for parameters belonging to the specified group and returns the groupOptional boolean value for that group.
- Parameters:
ui_json – The UI JSON dictionary to search through.
group_name – Name of the group to check.
- Returns:
True if the group is optional, False otherwise.
- geoh5py.ui_json.utils.group_requires_value(ui_json: dict[str, dict[str, Any]], parameter: str) bool#
Check if a parameter requires a value based on its group’s optional status.
Determines if a parameter requires a value by checking if its group is optional and if the group is enabled.
- Parameters:
ui_json – UI JSON dictionary containing the parameters.
parameter – Name of the parameter to check.
- Returns:
True if the group is optional and enabled, or if the group is not optional.
- geoh5py.ui_json.utils.is_form(var: Any) bool#
Check if a variable is a valid form dictionary.
Returns True if the dictionary variable contains both ‘label’ and ‘value’ members, which are required for a valid UI form element.
- Parameters:
var – Variable to check for form structure.
- Returns:
True if the variable is a valid form dictionary, False otherwise.
- geoh5py.ui_json.utils.is_uijson(ui_json: dict[str, dict[str, Any]]) bool#
Check if a dictionary contains all the required UI JSON parameters.
Validates that a dictionary has the structure and required fields of a valid UI JSON configuration.
- Parameters:
ui_json – Dictionary to validate as UI JSON.
- Returns:
True if the dictionary contains all required parameters, False otherwise.
- geoh5py.ui_json.utils.monitored_directory_copy(directory: str, entity: ObjectBase | Group, copy_children: bool = True) str#
Create a temporary geoh5 file in the monitoring folder and export entity for update.
Creates a temporary workspace in the specified monitoring directory and copies the given entity to it. This is useful for monitoring and updating entities in a separate workspace environment.
- Parameters:
directory – Path to the monitoring directory where the temporary file will be created.
entity – Entity (ObjectBase or Group) to be copied for monitoring.
copy_children – Whether to copy children entities along with the main entity.
- Returns:
Full path to the created temporary geoh5 file.
- geoh5py.ui_json.utils.optional_requires_value(ui_json: dict[str, dict[str, Any]], parameter: str) bool#
Check if an optional parameter requires a value based on its enabled state.
For optional parameters, this function checks the ‘enabled’ field to determine if the parameter requires a value.
- Parameters:
ui_json – UI JSON dictionary containing the parameters.
parameter – Name of the parameter to check.
- Returns:
True if the parameter is enabled, False otherwise.
- geoh5py.ui_json.utils.path2workspace(value: Any) Any#
Convert a file path string to a Workspace object if it represents a valid geoh5 file.
Creates a Workspace object from a path string if the file exists and has a .geoh5 extension.
- Parameters:
value – File path string, Path object, or other value to convert.
- Returns:
Workspace object if the value represents a valid geoh5 file, original value otherwise.
- geoh5py.ui_json.utils.requires_value(ui_json: dict[str, dict[str, Any]], parameter: str) bool#
Check if a UI JSON parameter requires a value based on hierarchy of switches.
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 at the bottom is the optional switch. When groupOptional is disabled, all parameters in the group are not required. When the groupOptional is enabled, the required status of a parameter depends first on any dependencies and lastly on its optional status.
- Parameters:
ui_json – UI JSON dictionary containing the parameters.
parameter – Name of the parameter to check.
- Returns:
True if the parameter requires a value, False otherwise.
- geoh5py.ui_json.utils.set_enabled(ui_json: dict[str, Any], parameter: str, value: bool, validate: bool = True) None#
Set the enabled status for an optional or groupOptional parameter.
Updates the ‘enabled’ field for parameters that support it, including optional parameters, parameters with dependencies, and group optional parameters.
- Parameters:
ui_json – UI JSON dictionary containing the parameters.
parameter – Name of the parameter to modify.
value – Boolean value to set for the parameter’s enabled member.
validate – Whether to perform validation checks on the operation.
- Raises:
Warning – If attempting to disable a non-optional parameter.
- geoh5py.ui_json.utils.str2inf(value: Any) Any#
Convert string representations of infinity to float infinity values.
Converts “inf” and “-inf” strings to their corresponding float values.
- Parameters:
value – Value to convert, typically a string.
- Returns:
Float infinity value if input is “inf” or “-inf”, original value otherwise.
- geoh5py.ui_json.utils.str2list(value: Any) Any#
Convert string representation of numbers to list of floats.
Maps string values like “[1,2,3]” or “1,2,3” to [1.0, 2.0, 3.0]. Handles special cases like “inf”, “-inf”, and empty strings.
- Parameters:
value – Value to convert, typically a string or already converted type.
- Returns:
List of floats if conversion successful, original value otherwise.
- geoh5py.ui_json.utils.truth(ui_json: dict[str, dict[str, Any]], name: str, member: str) bool#
Get a parameter’s member value with default fallback for non-existent members.
Returns the value of a specific member field for a parameter, or a default value if the member doesn’t exist.
- Parameters:
ui_json – UI JSON dictionary containing the parameters.
name – Name of the parameter to check.
member – Name of the member field to retrieve.
- Returns:
The member’s value or its default value.
- Raises:
ValueError – If the field was not provided and does not have a default state.
- geoh5py.ui_json.utils.workspace2path(value: Any) str#
Convert a Workspace object to its file path string.
Deprecated: This function has been migrated to geoh5py.shared.utils.workspace2path and will be removed in future versions.
- Parameters:
value – Workspace object or other value to convert.
- Returns:
File path string for Workspace objects, “[in-memory]” for in-memory workspaces, or the original value for non-Workspace inputs.
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)#
Bases:
objectValidations on dictionary of parameters.
Attributes#
validations : Validations 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#
Infer necessary validations from ui json structure.
- validate(name: str, value: Any, validations: dict[str, Any] | None = None)#
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#
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#