Index
subsurfaceio.decorators
Reusable function and method decorators.
from subsurfaceio.decorators import set_function_metadata
@set_function_metadata('site_class', scalar=True)
def get_site_class(is_e_site_class: bool) -> str:
return 'E' if is_e_site_class else 'D'
Functions:
| Name | Description |
|---|---|
set_function_metadata |
Attach output metadata to subsurfaceio.functions. |
set_ui_metadata |
Attach UI configuration metadata to a method. |
set_function_metadata
set_function_metadata(
returns: str | tuple[str, ...], *, scalar: bool = False
) -> Callable[[F], F]
Attach output metadata to subsurfaceio.functions.
scalar is the result-model slot for a single-profile run (metadata
vs data), not a numpy rank. Vectorized or parametric calls may still
return arrays for scalar outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
returns
|
str | tuple[str, ...]
|
The output variable name or names produced by the decorated function. |
required |
scalar
|
bool
|
If True, those names belong on result |
False
|
Returns:
| Type | Description |
|---|---|
Callable[[F], F]
|
A decorator that sets |
set_ui_metadata
set_ui_metadata(
exclude: str | tuple[str, ...] | None = None,
*,
upload_accept: str | None = None,
upload_field: str | None = None,
download_extension: str | None = None,
download_path_field: str | None = None
) -> Callable[[F], F]
Attach UI configuration metadata to a method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude
|
str | tuple[str, ...] | None
|
Fields to exclude from rendering. |
None
|
upload_accept
|
str | None
|
Value for the upload component's |
None
|
upload_field
|
str | None
|
Name of the method parameter that should be rendered as a
file upload component. Defaults to |
None
|
download_extension
|
str | None
|
File extension (e.g., |
None
|
download_path_field
|
str | None
|
Name of the method parameter that receives the output
file path. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[F], F]
|
A decorator function that attaches the specified UI metadata to the target method. |