API Reference¶
Auto-generated documentation pulled from source code docstrings:
io ¶
API client for the shm extension.
This module exposes :class:ShmAPI as the low-level entry point
for SHM transport and persistence helpers.
Examples:
Classes¶
ShmEndpoints
dataclass
¶
ShmEndpoints(
api_subdir="/shm/routes/",
sensor_type="sensortype",
sensor="sensor",
sensor_calibration="sensorcalibration",
signal="signal",
signal_history="signalhistory",
signal_calibration="signalcalibration",
derived_signal="derivedsignal",
derived_signal_history="derivedsignalhistory",
derived_signal_calibration="derivedsignalcalibration",
)
ShmAPI ¶
Bases: API
Low-level API client for the SHM extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_subdir
|
str
|
API sub-path appended to the base root. |
"/shm/routes/"
|
**kwargs
|
Any
|
Forwarded to :class: |
{}
|
Examples:
Source code in src/owi/metadatabase/shm/io.py
Functions¶
ping ¶
Return a basic health response.
Examples:
get_signal ¶
Return a single SHM signal by its backend signal identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_id
|
str
|
Backend-facing SHM signal identifier. |
required |
**kwargs
|
QueryValue
|
Additional query parameters forwarded to the SHM route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Examples:
>>> from unittest.mock import patch
>>> api = ShmAPI(token="dummy")
>>> with patch.object(
... ShmAPI,
... "process_data",
... return_value=(pd.DataFrame([{"id": 7, "signal_id": "SG-01"}]), {"existance": True, "id": 7}),
... ):
... result = api.get_signal("SG-01")
>>> result["id"]
7
Source code in src/owi/metadatabase/shm/io.py
get_sensor_type ¶
Return a single SHM sensor type by query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the SHM sensor-type route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
get_sensor ¶
Return a single SHM sensor by query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the SHM sensor route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
get_sensor_calibration ¶
Return a single SHM sensor calibration by query parameters.
get_signal_history ¶
Return a single SHM signal history row by query parameters.
get_signal_calibration ¶
Return a single SHM signal calibration by query parameters.
get_derived_signal ¶
Return a single SHM derived signal by query parameters.
get_derived_signal_history ¶
Return a single SHM derived signal history row by query parameters.
get_derived_signal_calibration ¶
Return a single SHM derived signal calibration by query parameters.
create_signal ¶
Create a signal record.
Examples:
>>> from unittest.mock import patch
>>> api = ShmAPI(token="dummy")
>>> with patch.object(ShmAPI, "_mutate_resource", return_value={"id": 12, "exists": True}) as mocker:
... result = api.create_signal({"signal_id": "SG-01"})
>>> mocker.assert_called_once_with(api.endpoints.signal, {"signal_id": "SG-01"})
>>> result["id"]
12
Source code in src/owi/metadatabase/shm/io.py
create_signal_history ¶
create_signal_calibration ¶
create_derived_signal ¶
create_derived_signal_history ¶
Create a derived signal history record.
patch_derived_signal_history ¶
Patch a derived signal history record by id.
Source code in src/owi/metadatabase/shm/io.py
create_derived_signal_calibration ¶
Create a derived signal calibration record.
list_sensor_types ¶
Return all SHM sensor types matching the query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the sensor-type list route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
list_sensors ¶
Return all SHM sensors matching the query parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
QueryValue
|
Query parameters forwarded to the sensor list route. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary containing |
Source code in src/owi/metadatabase/shm/io.py
list_sensor_calibrations ¶
Return all SHM sensor calibrations matching the query parameters.
list_signals ¶
list_signal_history ¶
Return all SHM signal history rows matching the query parameters.
list_signal_calibrations ¶
Return all SHM signal calibrations matching the query parameters.
list_derived_signals ¶
Return all SHM derived signals matching the query parameters.
list_derived_signal_history ¶
Return all SHM derived signal history rows matching the query parameters.
list_derived_signal_calibrations ¶
Return all SHM derived signal calibrations matching the query parameters.
Source code in src/owi/metadatabase/shm/io.py
create_sensor_type ¶
Create a sensor type record, optionally with an image attachment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
Form fields for the sensor type resource. |
required |
files
|
Mapping[str, Any] | None
|
Optional file mapping (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |
Source code in src/owi/metadatabase/shm/io.py
create_sensor ¶
Create a sensor record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
JSON payload for the sensor resource. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |
Source code in src/owi/metadatabase/shm/io.py
create_sensor_calibration ¶
Create a sensor calibration record, optionally with a PDF attachment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
Form fields for the sensor calibration resource. |
required |
files
|
Mapping[str, Any] | None
|
Optional file mapping (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parent-SDK-style result dictionary. |
Source code in src/owi/metadatabase/shm/io.py
lookup ¶
Parent-SDK lookup services for SHM workflows.
This module centralizes the parent SDK lookups required by SHM upload and orchestration flows while keeping transport concerns outside the workflows themselves.
Classes¶
ParentLocationsLookupClient ¶
ParentGeometryLookupClient ¶
Bases: Protocol
Protocol for parent SDK geometry lookups used by SHM services.
LookupRecord
dataclass
¶
Normalized lookup record returned by SHM services.
AssetLookupContext
dataclass
¶
Resolved lookup context for an SHM asset workflow.
ShmLookupError ¶
ProjectSiteLookupError ¶
Bases: ShmLookupError
Raised when a project site lookup cannot be resolved.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
AssetLocationLookupError ¶
Bases: ShmLookupError
Raised when an asset location lookup cannot be resolved.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
SubassembliesLookupError ¶
Bases: ShmLookupError
Raised when a subassembly lookup cannot be resolved.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
ModelDefinitionLookupError ¶
Bases: ShmLookupError
Raised when a SHM model definition cannot be derived from subassemblies.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
SignalUploadContextError ¶
Bases: ShmLookupError
Raised when parent lookup data cannot be translated into upload ids.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
ParentSDKLookupService ¶
Resolve parent-SDK lookup data for SHM workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locations_client
|
ParentLocationsLookupClient
|
Parent SDK client that resolves project and asset location details. |
required |
geometry_client
|
ParentGeometryLookupClient
|
Parent SDK client that resolves geometry subassemblies. |
required |
Source code in src/owi/metadatabase/shm/lookup.py
Functions¶
get_projectsite ¶
Resolve a project site detail lookup.
Source code in src/owi/metadatabase/shm/lookup.py
get_assetlocation ¶
Resolve an asset location detail lookup.
Source code in src/owi/metadatabase/shm/lookup.py
get_subassemblies ¶
Resolve a subassembly lookup.
Source code in src/owi/metadatabase/shm/lookup.py
get_asset_context ¶
Resolve the lookup context needed for an SHM asset workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str | None
|
Parent SDK project site title. When omitted, the service derives it from the asset-location lookup data. |
required |
assetlocation
|
str
|
Parent SDK asset location title. |
required |
model_definition
|
str | None
|
Optional parent SDK model-definition title used when an asset has subassemblies for multiple model definitions. |
None
|
Returns:
| Type | Description |
|---|---|
AssetLookupContext
|
Typed lookup records plus the resolved model definition. |
Examples:
>>> from unittest.mock import Mock
>>> locations_client = Mock()
>>> geometry_client = Mock()
>>> locations_client.get_assetlocation_detail.return_value = {
... "data": pd.DataFrame([{"id": 11, "projectsite_name": "Project A"}]),
... "exists": True,
... "id": 11,
... }
>>> locations_client.get_projectsite_detail.return_value = {
... "data": pd.DataFrame([{"id": 10, "title": "Project A"}]),
... "exists": True,
... "id": 10,
... }
>>> geometry_client.get_subassemblies.return_value = {
... "data": pd.DataFrame([{"id": 40, "subassembly_type": "TP", "model_definition": "MD-01"}]),
... "exists": True,
... }
>>> geometry_client.get_modeldefinition_id.return_value = {"id": 99}
>>> service = ParentSDKLookupService(locations_client=locations_client, geometry_client=geometry_client)
>>> context = service.get_asset_context(projectsite=None, assetlocation="Asset-01")
>>> (context.site.record_id, context.asset.record_id, context.model_definition)
(10, 11, 99)
Source code in src/owi/metadatabase/shm/lookup.py
get_signal_upload_context ¶
get_signal_upload_context(
projectsite,
assetlocation,
permission_group_ids=None,
model_definition=None,
)
Resolve the payload-builder context for SHM signal uploads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str | None
|
Parent SDK project site title. When omitted, the service derives it from the asset-location lookup data. |
required |
assetlocation
|
str
|
Parent SDK asset location title. |
required |
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM records. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when an asset has subassemblies for multiple model definitions. |
None
|
Returns:
| Type | Description |
|---|---|
SignalUploadContext
|
Upload context compatible with legacy payload builders. |
Examples:
>>> from unittest.mock import Mock
>>> locations_client = Mock()
>>> geometry_client = Mock()
>>> locations_client.get_projectsite_detail.return_value = {
... "data": pd.DataFrame([{"id": 10, "title": "Project A"}]),
... "exists": True,
... "id": 10,
... }
>>> locations_client.get_assetlocation_detail.return_value = {
... "data": pd.DataFrame([{"id": 11, "title": "Asset-01"}]),
... "exists": True,
... "id": 11,
... }
>>> geometry_client.get_subassemblies.return_value = {
... "data": pd.DataFrame(
... [
... {"id": 40, "subassembly_type": "TP", "model_definition": "MD-01"},
... {"id": 41, "subassembly_type": "TW", "model_definition": "MD-01"},
... ]
... ),
... "exists": True,
... }
>>> service = ParentSDKLookupService(locations_client=locations_client, geometry_client=geometry_client)
>>> context = service.get_signal_upload_context("Project A", "Asset-01", permission_group_ids=[7])
>>> context.site_id, context.asset_location_id, context.subassembly_id_for("TP")
(10, 11, 40)
Source code in src/owi/metadatabase/shm/lookup.py
build_signal_upload_context
staticmethod
¶
Translate parent lookup records into upload payload ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_context
|
AssetLookupContext
|
Normalized parent SDK lookup context. |
required |
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM records. |
None
|
Returns:
| Type | Description |
|---|---|
SignalUploadContext
|
Upload context compatible with legacy payload builders. |
Raises:
| Type | Description |
|---|---|
SignalUploadContextError
|
If required parent lookup ids or subassembly columns are missing. |
Examples:
>>> asset_context = AssetLookupContext(
... site=LookupRecord(pd.DataFrame([{"id": 10}]), record_id=10),
... asset=LookupRecord(pd.DataFrame([{"id": 11}]), record_id=11),
... subassemblies=LookupRecord(
... pd.DataFrame(
... [
... {"id": 40, "subassembly_type": "TP", "model_definition": "MD-01"},
... {"id": 41, "subassembly_type": "TW", "model_definition": "MD-01"},
... ]
... )
... ),
... model_definition="MD-01",
... )
>>> upload_context = ParentSDKLookupService.build_signal_upload_context(asset_context, [3, 5])
>>> upload_context.permission_group_ids
[3, 5]
Source code in src/owi/metadatabase/shm/lookup.py
get_model_definition ¶
Resolve the model definition reference used by SHM payload builders.
The lookup uses an explicit model-definition title when provided.
Otherwise it derives the title from transition-piece subassembly rows.
When the parent geometry client exposes get_modeldefinition_id(),
it upgrades a model-definition title into the corresponding backend id.
Source code in src/owi/metadatabase/shm/lookup.py
get_transition_piece_model_definition
staticmethod
¶
Extract the transition-piece model definition from subassemblies.
Source code in src/owi/metadatabase/shm/lookup.py
models ¶
Pydantic models for typed SHM resources.
Classes¶
ShmEntityName ¶
Bases: str, Enum
Supported SHM entity names.
ShmBaseModel ¶
Bases: BaseModel
Base Pydantic configuration for SHM models.
ShmResourceRecord ¶
ShmQuery ¶
Bases: BaseModel
Validated wrapper for backend filter payloads.
SensorTypeRecord ¶
SensorRecord ¶
SensorCalibrationRecord ¶
SignalRecord ¶
SignalHistoryRecord ¶
SignalCalibrationRecord ¶
DerivedSignalRecord ¶
DerivedSignalHistoryRecord ¶
DerivedSignalCalibrationRecord ¶
serializers ¶
Serializers for typed SHM resources.
Classes¶
ShmEntitySerializer ¶
Bases: Generic[TShmRecord]
Generic serializer for a single SHM entity type.
Source code in src/owi/metadatabase/shm/serializers.py
Functions¶
to_payload ¶
Serialize a resource model or mapping into a backend payload.
Source code in src/owi/metadatabase/shm/serializers.py
from_mapping ¶
Deserialize a backend row into a typed resource model.
Source code in src/owi/metadatabase/shm/serializers.py
registry ¶
Entity registry for typed SHM resources.
Classes¶
ShmEntityDefinition
dataclass
¶
Typed description of one SHM resource.
ShmEntityRegistry ¶
Simple in-process registry for SHM entities.
Source code in src/owi/metadatabase/shm/registry.py
Functions¶
register ¶
get ¶
Return the configured entity definition.
Source code in src/owi/metadatabase/shm/registry.py
services ¶
Service facades for typed SHM entities.
Classes¶
ApiShmRepository ¶
Repository adapter built on top of :class:ShmAPI.
Source code in src/owi/metadatabase/shm/services/core.py
Functions¶
list_records ¶
Return backend rows for a collection query.
Source code in src/owi/metadatabase/shm/services/core.py
get_record ¶
Return the raw backend response for a single-resource query.
Source code in src/owi/metadatabase/shm/services/core.py
create_record ¶
Create a resource through the configured SHM API client.
Source code in src/owi/metadatabase/shm/services/core.py
SensorService ¶
ShmEntityService ¶
Facade for typed SHM retrieval and creation.
Source code in src/owi/metadatabase/shm/services/core.py
Functions¶
list_records ¶
Return typed resources for a collection query.
Source code in src/owi/metadatabase/shm/services/core.py
get_record ¶
Return a single typed resource when it exists.
Source code in src/owi/metadatabase/shm/services/core.py
create_record ¶
Create and deserialize one SHM resource.
Source code in src/owi/metadatabase/shm/services/core.py
SignalService ¶
processing ¶
Signal processing subpackage.
Re-exports all public symbols so from owi.metadatabase.shm.processing import X
continues to work unchanged.
Classes¶
ConfigDiscovery ¶
Bases: ABC
Discover farm configuration files from a filesystem path.
Functions¶
discover
abstractmethod
¶
Return a turbine-to-config-path mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Filesystem path to a directory of configuration files or a single configuration file. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine identifiers to retain from the discovered files. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Mapping from turbine identifier to configuration file path. |
Source code in src/owi/metadatabase/shm/processing/discovery.py
JsonStemConfigDiscovery
dataclass
¶
Bases: ConfigDiscovery
Discover JSON configuration files by stem name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
File suffix treated as a valid configuration file. |
'.json'
|
Examples:
Functions¶
discover ¶
Return available JSON config files keyed by turbine name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory containing configuration files or a single JSON config path. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to retain from the discovered files. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Mapping from turbine stem to configuration path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the path does not resolve to usable JSON files or the requested turbine subset is empty. |
Source code in src/owi/metadatabase/shm/processing/discovery.py
DelimitedSignalKeyParser
dataclass
¶
Parse delimited signal-property keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_prefixes
|
tuple[str, ...]
|
Raw key prefixes that belong to direct signal properties. |
required |
separator
|
str
|
Separator between the signal identifier and the property name. |
'/'
|
Examples:
>>> parser = DelimitedSignalKeyParser(signal_prefixes=("WF", "X/", "Y/", "Z/"))
>>> parser.parse("WF_WTG_TP_STRAIN/status")
SignalEventKey(signal_name='WF_WTG_TP_STRAIN', property_name='status')
>>> parser.parse("acceleration/yaw_transformation") is None
True
Functions¶
matches ¶
Return True when the raw key belongs to a direct signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_key
|
str
|
Raw configuration key to test. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the key starts with one of the configured signal prefixes. |
Source code in src/owi/metadatabase/shm/processing/parsing.py
parse ¶
Parse a raw key into a signal/property pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_key
|
str
|
Raw configuration key containing a signal name and property name
separated by :attr: |
required |
Returns:
| Type | Description |
|---|---|
SignalEventKey or None
|
Parsed key, or None when the key does not match or lacks a separator. |
Source code in src/owi/metadatabase/shm/processing/parsing.py
SignalEventKey
dataclass
¶
Parsed signal-property key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_name
|
str
|
Canonical signal identifier. |
required |
property_name
|
str
|
Property name carried by the raw configuration key. |
required |
ConfiguredSignalConfigProcessor ¶
Bases: SignalConfigProcessor
Signal processor backed by an explicit farm spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory or JSON file containing farm signal configuration events. |
required |
processor_spec
|
SignalProcessorSpec
|
Explicit processor specification that defines parsing, derivation, and discovery behavior. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to process during discovery. |
None
|
Examples:
>>> from owi.metadatabase.shm.processing import DelimitedSignalKeyParser, SignalProcessorSpec
>>> spec = SignalProcessorSpec(
... farm_name="Demo",
... signal_key_parser=DelimitedSignalKeyParser(signal_prefixes=("WF_",)),
... derived_signal_strategies={},
... )
>>> processor = ConfiguredSignalConfigProcessor(path_configs='.', processor_spec=spec)
>>> result = processor.process_events([{"WF_SIG/status": "ok"}])
>>> result.to_legacy_data()[0]["WF_SIG"]["status"][0]["status"]
'ok'
Source code in src/owi/metadatabase/shm/processing/processor.py
Functions¶
process_events ¶
Transform raw configuration events into typed signal records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[Mapping[str, Any]]
|
Ordered raw configuration events loaded from one farm config. |
required |
Returns:
| Type | Description |
|---|---|
SignalProcessingResult
|
Typed signal and derived-signal records that can be converted to the archive-compatible uploader payload shape. |
Examples:
>>> from owi.metadatabase.shm.processing import (
... ConfiguredSignalConfigProcessor,
... DelimitedSignalKeyParser,
... SignalProcessorSpec,
... )
>>> spec = SignalProcessorSpec(
... farm_name="Demo",
... signal_key_parser=DelimitedSignalKeyParser(signal_prefixes=("WF_",)),
... derived_signal_strategies={},
... )
>>> processor = ConfiguredSignalConfigProcessor(path_configs='.', processor_spec=spec)
>>> result = processor.process_events([{"WF_SIG/status": "ok"}])
>>> result.to_legacy_data()[0]["WF_SIG"]["status"][0]["status"]
'ok'
Source code in src/owi/metadatabase/shm/processing/processor.py
signal_preprocess_data ¶
Process one configuration file into archive-compatible mappings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_config
|
str | Path
|
JSON configuration file to load and process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[LegacySignalMap, LegacySignalMap]
|
Main-signal and derived-signal mappings ready for uploader seams. |
Source code in src/owi/metadatabase/shm/processing/processor.py
signals_process_data ¶
Process all discovered configuration files under path_configs.
The processed results are stored on :attr:signals_data and
:attr:signals_derived_data, keyed by turbine stem.
Source code in src/owi/metadatabase/shm/processing/processor.py
build_processor_spec ¶
Return the explicit processor spec passed to the constructor.
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
The specification supplied at construction time. |
Source code in src/owi/metadatabase/shm/processing/processor.py
from_yaml_spec
classmethod
¶
Construct a configured processor from a YAML-backed processor spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory or JSON file containing farm configuration events. |
required |
processor_spec_path
|
str | Path
|
Path to a YAML processor specification file. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to process during discovery. |
None
|
Returns:
| Type | Description |
|---|---|
ConfiguredSignalConfigProcessor
|
Processor loaded with the given YAML spec. |
Source code in src/owi/metadatabase/shm/processing/processor.py
DefaultSignalConfigProcessor ¶
Bases: ConfiguredSignalConfigProcessor
Built-in specialization of the generic signal processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory or JSON file containing default wind-farm configuration events. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to process during discovery. |
None
|
processor_spec
|
SignalProcessorSpec | None
|
Optional override for the built-in default processor specification. |
None
|
Source code in src/owi/metadatabase/shm/processing/processor.py
Functions¶
build_processor_spec ¶
Return the explicit processor spec passed to the constructor.
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
The specification supplied at construction time. |
Source code in src/owi/metadatabase/shm/processing/processor.py
process_events ¶
Transform raw configuration events into typed signal records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[Mapping[str, Any]]
|
Ordered raw configuration events loaded from one farm config. |
required |
Returns:
| Type | Description |
|---|---|
SignalProcessingResult
|
Typed signal and derived-signal records that can be converted to the archive-compatible uploader payload shape. |
Examples:
>>> from owi.metadatabase.shm.processing import (
... ConfiguredSignalConfigProcessor,
... DelimitedSignalKeyParser,
... SignalProcessorSpec,
... )
>>> spec = SignalProcessorSpec(
... farm_name="Demo",
... signal_key_parser=DelimitedSignalKeyParser(signal_prefixes=("WF_",)),
... derived_signal_strategies={},
... )
>>> processor = ConfiguredSignalConfigProcessor(path_configs='.', processor_spec=spec)
>>> result = processor.process_events([{"WF_SIG/status": "ok"}])
>>> result.to_legacy_data()[0]["WF_SIG"]["status"][0]["status"]
'ok'
Source code in src/owi/metadatabase/shm/processing/processor.py
signal_preprocess_data ¶
Process one configuration file into archive-compatible mappings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_config
|
str | Path
|
JSON configuration file to load and process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[LegacySignalMap, LegacySignalMap]
|
Main-signal and derived-signal mappings ready for uploader seams. |
Source code in src/owi/metadatabase/shm/processing/processor.py
signals_process_data ¶
Process all discovered configuration files under path_configs.
The processed results are stored on :attr:signals_data and
:attr:signals_derived_data, keyed by turbine stem.
Source code in src/owi/metadatabase/shm/processing/processor.py
from_yaml_spec
classmethod
¶
Construct a configured processor from a YAML-backed processor spec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory or JSON file containing farm configuration events. |
required |
processor_spec_path
|
str | Path
|
Path to a YAML processor specification file. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to process during discovery. |
None
|
Returns:
| Type | Description |
|---|---|
ConfiguredSignalConfigProcessor
|
Processor loaded with the given YAML spec. |
Source code in src/owi/metadatabase/shm/processing/processor.py
SignalConfigProcessor ¶
Bases: ABC
ABC-backed base class for wind-farm signal config processors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_configs
|
str | Path
|
Directory or JSON file containing farm signal configuration events. |
required |
turbines
|
Sequence[str] | None
|
Optional subset of turbine stems to process during discovery. |
None
|
Notes
Subclasses provide the farm-specific :class:SignalProcessorSpec used by
the generic processing pipeline.
Source code in src/owi/metadatabase/shm/processing/processor.py
Functions¶
build_processor_spec
abstractmethod
¶
Return the farm-specific processor specification.
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
Specification controlling signal key parsing, derived-signal strategies, and postprocessors. |
Source code in src/owi/metadatabase/shm/processing/processor.py
process_events ¶
Transform raw configuration events into typed signal records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
Sequence[Mapping[str, Any]]
|
Ordered raw configuration events loaded from one farm config. |
required |
Returns:
| Type | Description |
|---|---|
SignalProcessingResult
|
Typed signal and derived-signal records that can be converted to the archive-compatible uploader payload shape. |
Examples:
>>> from owi.metadatabase.shm.processing import (
... ConfiguredSignalConfigProcessor,
... DelimitedSignalKeyParser,
... SignalProcessorSpec,
... )
>>> spec = SignalProcessorSpec(
... farm_name="Demo",
... signal_key_parser=DelimitedSignalKeyParser(signal_prefixes=("WF_",)),
... derived_signal_strategies={},
... )
>>> processor = ConfiguredSignalConfigProcessor(path_configs='.', processor_spec=spec)
>>> result = processor.process_events([{"WF_SIG/status": "ok"}])
>>> result.to_legacy_data()[0]["WF_SIG"]["status"][0]["status"]
'ok'
Source code in src/owi/metadatabase/shm/processing/processor.py
signal_preprocess_data ¶
Process one configuration file into archive-compatible mappings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_config
|
str | Path
|
JSON configuration file to load and process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[LegacySignalMap, LegacySignalMap]
|
Main-signal and derived-signal mappings ready for uploader seams. |
Source code in src/owi/metadatabase/shm/processing/processor.py
signals_process_data ¶
Process all discovered configuration files under path_configs.
The processed results are stored on :attr:signals_data and
:attr:signals_derived_data, keyed by turbine stem.
Source code in src/owi/metadatabase/shm/processing/processor.py
ProcessedDerivedSignalRecord
dataclass
¶
Typed in-memory representation of one processed derived signal.
Examples:
>>> record = ProcessedDerivedSignalRecord()
>>> record.ensure_source_name("strain/bending_moment", {"suffix": "N"})
>>> record.set_parent_signals(["SIG_A", "SIG_B"])
>>> record.add_calibration("01/01/1972 00:00", {"yaw_offset": 2.0})
>>> sorted(record.to_legacy_dict())
['calibration', 'data', 'parent_signals']
Functions¶
ensure_source_name ¶
Initialize immutable source metadata for the derived signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_name
|
str
|
Event key that produced the derived signal. |
required |
extra_fields
|
Mapping[str, Any] | None
|
Optional metadata merged into the legacy |
None
|
Source code in src/owi/metadatabase/shm/processing/records.py
set_parent_signals ¶
Set parent signals when they are first known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_signals
|
Sequence[str]
|
Ordered parent signal identifiers for the derived signal. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
add_calibration ¶
Append a derived-signal calibration row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
Event timestamp associated with the calibration. |
required |
calibration_fields
|
Mapping[str, Any]
|
Calibration fields emitted by the derived-signal strategy. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
to_legacy_dict ¶
Return the uploader-facing legacy mapping.
Returns:
| Type | Description |
|---|---|
LegacyRecord
|
Archive-compatible mapping consumed by uploader payload builders. |
Source code in src/owi/metadatabase/shm/processing/records.py
ProcessedSignalRecord
dataclass
¶
ProcessedSignalRecord(
scalar_fields=dict(),
status_rows=list(),
offset_rows=list(),
cwl_rows=list(),
)
Typed in-memory representation of one processed signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scalar_fields
|
dict[str, Any]
|
Arbitrary scalar properties stored on the signal. |
dict()
|
status_rows
|
list[dict[str, Any]]
|
Collected status event rows. |
list()
|
offset_rows
|
list[dict[str, Any]]
|
Collected offset event rows. |
list()
|
cwl_rows
|
list[dict[str, Any]]
|
Collected CWL event rows. |
list()
|
Examples:
>>> record = ProcessedSignalRecord()
>>> record.add_status("01/01/1972 00:00", "ok")
>>> record.to_legacy_dict()["status"][0]["status"]
'ok'
Functions¶
set_scalar ¶
Store a scalar property on the signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
property_name
|
str
|
Scalar field name from the raw configuration event. |
required |
value
|
Any
|
Value to persist on the signal record. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
add_status ¶
Append a status row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
Event timestamp associated with the status. |
required |
status
|
Any
|
Status value to store. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
add_status_alias ¶
Append a status row that carries a legacy alias name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
Event timestamp associated with the alias. |
required |
alias_name
|
str
|
Legacy signal name that points at this record. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
add_offset ¶
Append an offset row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
Event timestamp associated with the offset. |
required |
offset
|
Any
|
Offset value to store. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
add_cwl ¶
Append a CWL row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
Event timestamp associated with the CWL value. |
required |
cwl
|
Any
|
CWL value to store. |
required |
Source code in src/owi/metadatabase/shm/processing/records.py
to_legacy_dict ¶
Return the uploader-facing legacy mapping.
Returns:
| Type | Description |
|---|---|
LegacyRecord
|
Archive-compatible mapping consumed by uploader payload builders. |
Source code in src/owi/metadatabase/shm/processing/records.py
SignalProcessingResult
dataclass
¶
Processed signal and derived-signal records.
Examples:
>>> signal = ProcessedSignalRecord()
>>> signal.add_status("01/01/1972 00:00", "ok")
>>> result = SignalProcessingResult(signals={"SIG": signal}, derived_signals={})
>>> result.to_legacy_data()[0]["SIG"]["status"][0]["status"]
'ok'
Functions¶
to_legacy_data ¶
Return archive-compatible dicts for uploader seams.
Returns:
| Type | Description |
|---|---|
tuple[LegacySignalMap, LegacySignalMap]
|
Main-signal and derived-signal mappings in the uploader-facing archive shape. |
Source code in src/owi/metadatabase/shm/processing/records.py
SignalProcessorSpec
dataclass
¶
SignalProcessorSpec(
farm_name,
signal_key_parser,
derived_signal_strategies,
config_discovery=JsonStemConfigDiscovery(),
postprocessors=(),
time_field="time",
default_initial_time="01/01/1972 00:00",
)
Farm-specific configuration for signal processing.
The YAML structure expected by this spec is designed to be flexible enough to cover a wide range of use cases while remaining human-friendly and avoiding excessive nesting. The top-level keys are:
farm_name: A human-readable farm identifier used by the caller.signal_key_parser: A configuration for the signal key parser, which recognizes direct signal-property keys in the input data.derived_signal_strategies: A mapping from raw event keys to derived-signal strategies, which define how to generate derived signals based on specific events in the input data.config_discovery: A strategy used to discover configuration files on disk, allowing the processor to locate and load necessary configurations for processing signals.postprocessors: A list of pure normalization hooks applied after all events are processed, enabling additional transformations or clean-up steps on the processed signals.time_field: The event field used to update the active timestamp during processing.default_initial_time: The timestamp assigned to the first event when the payload omits one, ensuring that all events have a valid timestamp for processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
farm_name
|
str
|
Human-readable farm identifier used by the caller. |
required |
signal_key_parser
|
DelimitedSignalKeyParser
|
Parser that recognizes direct signal-property keys. |
required |
derived_signal_strategies
|
Mapping[str, DerivedSignalStrategy]
|
Mapping from raw event keys to derived-signal strategies. |
required |
config_discovery
|
ConfigDiscovery
|
Strategy used to discover configuration files on disk. |
JsonStemConfigDiscovery()
|
postprocessors
|
tuple[SignalPostprocessor, ...]
|
Pure normalization hooks applied after all events are processed. |
()
|
time_field
|
str
|
Event field used to update the active timestamp. |
'time'
|
default_initial_time
|
str
|
Timestamp assigned to the first event when the payload omits one. |
'01/01/1972 00:00'
|
Examples:
>>> spec = SignalProcessorSpec(
... farm_name="Demo Farm",
... signal_key_parser=DelimitedSignalKeyParser(signal_prefixes=("WF_",)),
... derived_signal_strategies={},
... )
>>> spec.default_initial_time
'01/01/1972 00:00'
YAML example ~~~~~~~~~~~~
.. code-block:: yaml farm_name: Demo Farm signal_key_parser: kind: delimited signal_prefixes: ["WF_"] derived_signal_strategies: {} config_discovery: kind: json_stem postprocessors: [] time_field: time default_initial_time: '01/01/1972 00:00'
DerivedSignalStrategy ¶
Bases: ABC
Strategy for translating one event into derived-signal updates.
Implementations keep farm-specific derived-signal semantics outside the generic processor loop.
Functions¶
emit_updates
abstractmethod
¶
Build derived-signal updates for one event payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_key
|
str
|
Raw event key that selected the strategy. |
required |
payload
|
Mapping[str, Any]
|
Mapping stored under the raw event key. |
required |
Returns:
| Type | Description |
|---|---|
list[DerivedSignalUpdate]
|
Derived-signal mutations emitted for the event. |
Source code in src/owi/metadatabase/shm/processing/strategies.py
LevelBasedDerivedSignalStrategy
dataclass
¶
LevelBasedDerivedSignalStrategy(
suffixes,
signal_name_builder=_default_level_signal_name,
parent_signals_builder=_parent_signals_from_level,
calibration_fields_builder=_yaw_calibration_fields,
data_builder=None,
levels_key="levels",
)
Bases: DerivedSignalStrategy
Expand a level-based event into derived signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffixes
|
tuple[str, ...]
|
Suffixes appended to each level identifier. |
required |
signal_name_builder
|
SignalNameBuilder
|
Callback used to derive the final signal name for a level/suffix pair. |
_default_level_signal_name
|
parent_signals_builder
|
ParentSignalsBuilder
|
Callback that returns parent signal identifiers for a level. |
_parent_signals_from_level
|
calibration_fields_builder
|
CalibrationFieldsBuilder
|
Callback that returns calibration data for a level. |
_yaw_calibration_fields
|
data_builder
|
DerivedDataBuilder | None
|
Optional callback for extra metadata stored under |
None
|
Examples:
>>> strategy = LevelBasedDerivedSignalStrategy(
... suffixes=("FA",),
... parent_signals_builder=lambda payload, level: tuple(payload[level]),
... calibration_fields_builder=lambda payload, level: {"yaw_offset": payload["yaw_offset"]},
... )
>>> updates = strategy.emit_updates(
... "acceleration/yaw_transformation",
... {"levels": ["SIG_A"], "yaw_offset": 2.0, "SIG_A": ["PARENT_1", "PARENT_2"]},
... )
>>> updates[0].signal_name
'SIG_A_FA'
>>> updates[0].parent_signals
('PARENT_1', 'PARENT_2')
Functions¶
emit_updates ¶
Build derived-signal updates for a level-based payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_key
|
str
|
Raw event key that triggered the strategy. The value is accepted for interface parity and is not used directly by the default implementation. |
required |
payload
|
Mapping[str, Any]
|
Mapping that must contain the configured |
required |
Returns:
| Type | Description |
|---|---|
list[DerivedSignalUpdate]
|
One update per level and configured suffix. |
Source code in src/owi/metadatabase/shm/processing/strategies.py
Functions¶
default_signal_processor_spec ¶
Return the built-in default processor spec for wind-farm signal configs.
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
Pre-loaded default specification. |
Examples:
>>> spec = default_signal_processor_spec()
>>> tuple(spec.derived_signal_strategies)
('acceleration/yaw_transformation', 'strain/bending_moment')
Source code in src/owi/metadatabase/shm/processing/spec.py
get_default_signal_processor_spec_path ¶
Return the packaged YAML path for the built-in default processor spec.
Returns:
| Type | Description |
|---|---|
Path
|
Absolute path to |
Source code in src/owi/metadatabase/shm/processing/spec.py
load_default_signal_processor_spec ¶
Load the built-in default processor spec from its YAML document.
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
Processor specification loaded from the packaged YAML file. |
Source code in src/owi/metadatabase/shm/processing/spec.py
load_signal_processor_spec ¶
Load a signal processor spec from a YAML document.
The YAML document must conform to the structure expected by
SignalProcessorSpec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the YAML document describing the processor spec. |
required |
Returns:
| Type | Description |
|---|---|
SignalProcessorSpec
|
Parsed processor specification. |
Source code in src/owi/metadatabase/shm/processing/spec.py
upload ¶
Upload subpackage for SHM signal and sensor upload orchestration.
Re-exports all public symbols so from owi.metadatabase.shm.upload import X
works unchanged.
Classes¶
ParentSignalLookupError ¶
Bases: ShmUploadError
Raised when a derived signal refers to unresolved parent signals.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
ShmUploadError ¶
UploadResultError ¶
Bases: ShmUploadError
Raised when a backend mutation result does not include the expected id.
Source code in .venv/lib/python3.14/site-packages/owi/metadatabase/_utils/exceptions.py
AssetSignalUploadRequest
dataclass
¶
AssetSignalUploadRequest(
projectsite,
assetlocation,
signals,
derived_signals=None,
permission_group_ids=None,
sensor_serial_numbers_by_signal=None,
temperature_compensation_signal_ids=None,
temperature_compensation_signal_refs=None,
model_definition=None,
)
Input data for uploading one asset's SHM signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Parent SDK project site title. |
required |
assetlocation
|
str
|
Parent SDK asset location title. |
required |
signals
|
SignalConfigMap
|
Archive-compatible main signal data keyed by signal identifier. |
required |
derived_signals
|
SignalConfigMap | None
|
Archive-compatible derived signal data keyed by derived signal identifier. |
None
|
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM objects. |
None
|
sensor_serial_numbers_by_signal
|
Mapping[str, int] | None
|
Optional map from signal identifier to the backend SHM sensor identifier stored on signal history rows. |
None
|
temperature_compensation_signal_ids
|
TemperatureCompensationSignalIDMap | None
|
Optional map from legacy temperature-compensation sensor token to backend SHM signal id. |
None
|
temperature_compensation_signal_refs
|
TemperatureCompensationSignalRefMap | None
|
Optional map from legacy temperature-compensation sensor token to SHM signal identifier. These references are resolved during upload after main signal creation. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when an asset has subassemblies for multiple model definitions. |
None
|
Examples:
>>> request = AssetSignalUploadRequest(
... projectsite="Project A",
... assetlocation="Asset-01",
... signals={},
... )
>>> request.result_key
'Project A/Asset-01'
Attributes¶
Functions¶
from_processing_result
classmethod
¶
from_processing_result(
*,
projectsite,
assetlocation,
processing_result,
permission_group_ids=None,
model_definition=None,
sensor_serial_numbers_by_signal=None,
temperature_compensation_signal_ids=None,
temperature_compensation_signal_refs=None,
)
Build an upload request from a processed signal-config result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Parent SDK project site title. |
required |
assetlocation
|
str
|
Parent SDK asset location title. |
required |
processing_result
|
SignalProcessingResult
|
Processed signal and derived-signal records emitted by a processor. |
required |
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM objects. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when an asset has subassemblies for multiple model definitions. |
None
|
sensor_serial_numbers_by_signal
|
Mapping[str, int] | None
|
Optional map from signal identifier to backend sensor serial number used for signal history rows. |
None
|
temperature_compensation_signal_ids
|
TemperatureCompensationSignalIDMap | None
|
Optional map from legacy temperature-compensation sensor token to backend SHM signal id. |
None
|
temperature_compensation_signal_refs
|
TemperatureCompensationSignalRefMap | None
|
Optional map from legacy temperature-compensation sensor token to SHM signal identifier. |
None
|
Returns:
| Type | Description |
|---|---|
AssetSignalUploadRequest
|
Asset-scoped upload request that preserves the archive-compatible payload shape. |
Examples:
>>> from owi.metadatabase.shm.processing import ProcessedSignalRecord, SignalProcessingResult
>>> signal = ProcessedSignalRecord()
>>> signal.add_status("01/01/1972 00:00", "ok")
>>> request = AssetSignalUploadRequest.from_processing_result(
... projectsite="Project A",
... assetlocation="Asset-01",
... processing_result=SignalProcessingResult(signals={"SIG": signal}, derived_signals={}),
... )
>>> request.signals["SIG"]["status"][0]["status"]
'ok'
Source code in src/owi/metadatabase/shm/upload/models.py
AssetSignalUploadResult
dataclass
¶
AssetSignalUploadResult(
asset_key,
signal_ids_by_name,
derived_signal_ids_by_name,
results_main,
results_secondary,
results_derived_main,
results_derived_secondary,
)
Upload result for one asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_key
|
str
|
Stable asset-scoped result key in |
required |
signal_ids_by_name
|
Mapping[str, int]
|
Backend ids for created main signals keyed by signal identifier. |
required |
derived_signal_ids_by_name
|
Mapping[str, int]
|
Backend ids for created derived signals keyed by signal identifier. |
required |
results_main
|
Sequence[dict[str, Any]]
|
Raw backend responses for main signal creation calls. |
required |
results_secondary
|
Sequence[dict[str, Any]]
|
Raw backend responses for signal history and calibration calls. |
required |
results_derived_main
|
Sequence[dict[str, Any]]
|
Raw backend responses for derived signal creation calls. |
required |
results_derived_secondary
|
Sequence[dict[str, Any]]
|
Raw backend responses for derived history, parent patch, and calibration calls. |
required |
This
|
|
required | |
migrate
|
|
required |
DerivedSignalCalibrationPayload
dataclass
¶
DerivedSignalCalibrationPayload(
derived_signal_id,
calibration_date,
data,
status_approval="yes",
)
Payload model for derived signal calibration records.
DerivedSignalHistoryPayload
dataclass
¶
DerivedSignalHistoryPayload(
derived_signal_id,
activity_start_timestamp,
is_latest_status,
status,
parent_signals=None,
status_approval="yes",
)
Payload model for derived signal history records.
DerivedSignalPayload
dataclass
¶
DerivedSignalPayload(
site,
model_definition,
asset_location,
sub_assembly,
signal_type,
derived_signal_id,
visibility_groups,
heading=None,
level=None,
orientation=None,
stats=None,
data_additional=None,
visibility="usergroup",
)
Payload model for derived signal records.
SensorCalibrationPayload
dataclass
¶
Payload model for sensor calibration records.
SensorPayload
dataclass
¶
SensorPayload(
sensor_type_id,
serial_number,
cabinet,
visibility="usergroup",
visibility_groups=None,
)
Payload model for sensor records.
SensorTypePayload
dataclass
¶
SensorTypePayload(
name,
type,
type_extended,
hardware_supplier,
file=None,
visibility="usergroup",
visibility_groups=None,
)
Payload model for sensor type records.
SignalCalibrationPayload
dataclass
¶
SignalCalibrationPayload(
signal_id,
calibration_date,
data,
tempcomp_signal_id=None,
status_approval="yes",
)
Payload model for signal calibration records.
SignalHistoryPayload
dataclass
¶
SignalHistoryPayload(
signal_id,
activity_start_timestamp,
is_latest_status,
status,
sensor_serial_number=None,
status_approval="yes",
legacy_signal_id=None,
)
Payload model for signal history records.
SignalPayload
dataclass
¶
SignalPayload(
site,
model_definition,
asset_location,
signal_type,
signal_id,
visibility_groups,
sub_assembly=None,
heading=None,
level=None,
orientation=None,
stats=None,
data_additional=None,
visibility="usergroup",
)
Payload model for signal records.
ShmSignalUploadClient ¶
Bases: Protocol
Protocol describing the SHM transport methods used by the uploader.
SignalConfigUploadSource ¶
Bases: Protocol
Protocol for processors that feed turbine-scoped upload data.
ShmSensorUploadClient ¶
ShmSensorUploader ¶
Upload sensor types, sensors, and sensor calibrations for SHM assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shm_api
|
ShmSensorUploadClient
|
SHM transport client that satisfies :class: |
required |
Source code in src/owi/metadatabase/shm/upload/sensors.py
Functions¶
upload_sensor_types ¶
Upload sensor type records, optionally with image attachments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensor_types_data
|
Sequence[Mapping[str, Any]]
|
List of sensor type records (e.g. loaded from |
required |
permission_group_ids
|
Sequence[int] | None
|
Permission groups applied to every sensor type. |
required |
path_to_images
|
str | Path | None
|
Optional directory containing sensor type image files. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
Raw backend responses for each created sensor type. |
Source code in src/owi/metadatabase/shm/upload/sensors.py
upload_sensors ¶
upload_sensors(
sensor_type_name,
sensor_type_params,
sensors_data,
permission_group_ids,
turbines=None,
)
Upload sensor records for a single sensor category across turbines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensor_type_name
|
str
|
Key identifying the sensor category within each turbine's data
(e.g. |
required |
sensor_type_params
|
Mapping[str, str]
|
Query parameters used to resolve the backend sensor type id
(e.g. |
required |
sensors_data
|
SensorsDataByTurbine
|
Per-turbine sensor data keyed by turbine identifier. Each turbine
has categories mapping to |
required |
permission_group_ids
|
Sequence[int] | None
|
Permission groups applied to every sensor. |
required |
turbines
|
Sequence[str] | None
|
Optional filter to upload only specific turbines. When None,
all turbines in |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
Raw backend responses for each created sensor. |
Source code in src/owi/metadatabase/shm/upload/sensors.py
upload_sensor_calibrations ¶
upload_sensor_calibrations(
signal_sensor_map_data,
signal_calibration_map_data,
path_to_datasheets,
turbines=None,
)
Upload sensor calibration records with optional PDF attachments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_sensor_map_data
|
Mapping[str, Mapping[str, Mapping[str, Any]]]
|
Per-turbine signal-to-sensor mapping (keyed by turbine, then signal
name, with sensor lookup params including |
required |
signal_calibration_map_data
|
Mapping[str, Mapping[str, Mapping[str, str]]]
|
Per-turbine calibration data (keyed by turbine, then signal name,
with |
required |
path_to_datasheets
|
str | Path
|
Directory containing calibration PDF files. |
required |
turbines
|
Sequence[str] | None
|
Optional turbine filter. When None, all turbines are processed. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
Raw backend responses for each created calibration. |
Source code in src/owi/metadatabase/shm/upload/sensors.py
ShmSignalUploader ¶
Upload archive-compatible SHM signal data for arbitrary wind-farm assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shm_api
|
ShmSignalUploadClient
|
SHM transport client, typically :class: |
required |
lookup_service
|
ParentSDKLookupService
|
Parent SDK lookup service used to resolve site, asset, and subassembly ids. |
required |
Source code in src/owi/metadatabase/shm/upload/signals.py
Functions¶
from_clients
classmethod
¶
Construct the uploader from SHM and parent SDK clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shm_api
|
ShmSignalUploadClient
|
SHM transport client used for backend mutations. |
required |
locations_client
|
ParentLocationsLookupClient
|
Parent SDK client that resolves project and asset locations. |
required |
geometry_client
|
ParentGeometryLookupClient
|
Parent SDK client that resolves subassemblies and model definitions. |
required |
Returns:
| Type | Description |
|---|---|
ShmSignalUploader
|
Uploader wired to the canonical SHM lookup service. |
Source code in src/owi/metadatabase/shm/upload/signals.py
upload_asset ¶
Upload main and secondary SHM records for one asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
AssetSignalUploadRequest
|
Asset-scoped upload request containing the archive-compatible main and derived signal mappings. |
required |
Returns:
| Type | Description |
|---|---|
AssetSignalUploadResult
|
Created backend ids plus raw backend responses grouped by upload phase. |
Source code in src/owi/metadatabase/shm/upload/signals.py
upload_assets ¶
Upload SHM signal data for multiple assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests
|
Sequence[AssetSignalUploadRequest]
|
Asset-scoped upload requests to execute in order. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, AssetSignalUploadResult]
|
Upload results keyed by each request's stable result key. |
Source code in src/owi/metadatabase/shm/upload/signals.py
upload_turbines ¶
upload_turbines(
*,
projectsite,
signals_by_turbine,
derived_signals_by_turbine=None,
assetlocations_by_turbine=None,
permission_group_ids=None,
model_definition=None,
sensor_serial_numbers_by_turbine=None,
temperature_compensation_signal_ids_by_turbine=None,
temperature_compensation_signal_refs_by_turbine=None,
)
Upload SHM signal data for multiple turbine-scoped config bundles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Parent SDK project site title shared by the turbine batch. |
required |
signals_by_turbine
|
SignalConfigMapByTurbine
|
Main signal mappings keyed by turbine identifier. |
required |
derived_signals_by_turbine
|
SignalConfigMapByTurbine | None
|
Optional derived signal mappings keyed by turbine identifier. |
None
|
assetlocations_by_turbine
|
Mapping[str, str] | None
|
Optional turbine-to-asset-location override mapping. |
None
|
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM objects. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when the project has multiple model definitions for the same asset location. |
None
|
sensor_serial_numbers_by_turbine
|
Mapping[str, Mapping[str, int]] | None
|
Optional per-turbine mapping of signal identifiers to sensor serial numbers used for signal history rows. |
None
|
temperature_compensation_signal_ids_by_turbine
|
Mapping[str, TemperatureCompensationSignalIDMap] | None
|
Optional per-turbine mapping of temperature-compensation tokens to backend SHM signal ids. |
None
|
temperature_compensation_signal_refs_by_turbine
|
Mapping[str, TemperatureCompensationSignalRefMap] | None
|
Optional per-turbine mapping of temperature-compensation tokens to SHM signal identifiers resolved during upload. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, AssetSignalUploadResult]
|
Upload results keyed by turbine identifier. |
This keeps the response keyed by turbine while parent lookups use the
|
|
corresponding asset-location title.
|
|
Source code in src/owi/metadatabase/shm/upload/signals.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
upload_from_processor ¶
upload_from_processor(
*,
projectsite,
processor,
assetlocations_by_turbine=None,
permission_group_ids=None,
model_definition=None,
sensor_serial_numbers_by_turbine=None,
temperature_compensation_signal_ids_by_turbine=None,
temperature_compensation_signal_refs_by_turbine=None,
)
Process turbine configs and upload them through the generic SHM seam.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Parent SDK project site title shared by the processor output. |
required |
processor
|
SignalConfigUploadSource
|
Processor instance that populates |
required |
assetlocations_by_turbine
|
Mapping[str, str] | None
|
Optional turbine-to-asset-location override mapping. |
None
|
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM objects. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when the project has multiple model definitions for the same asset location. |
None
|
sensor_serial_numbers_by_turbine
|
Mapping[str, Mapping[str, int]] | None
|
Optional per-turbine mapping of signal identifiers to sensor serial numbers used for signal history rows. |
None
|
temperature_compensation_signal_ids_by_turbine
|
Mapping[str, TemperatureCompensationSignalIDMap] | None
|
Optional per-turbine mapping of temperature-compensation tokens to backend SHM signal ids. |
None
|
temperature_compensation_signal_refs_by_turbine
|
Mapping[str, TemperatureCompensationSignalRefMap] | None
|
Optional per-turbine mapping of temperature-compensation tokens to SHM signal identifiers resolved during upload. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, AssetSignalUploadResult]
|
Upload results keyed by turbine identifier. |
Source code in src/owi/metadatabase/shm/upload/signals.py
upload_from_processor_files ¶
upload_from_processor_files(
*,
projectsite,
processor,
path_signal_sensor_map=None,
path_sensor_tc_map=None,
assetlocations_by_turbine=None,
permission_group_ids=None,
model_definition=None,
)
Process configs, resolve optional file maps, and upload by turbine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Parent SDK project site title shared by the batch. |
required |
processor
|
SignalConfigUploadSource
|
Processor that populates turbine-scoped signal mappings. |
required |
path_signal_sensor_map
|
str | Path | None
|
Optional JSON file keyed by turbine and signal id with SHM sensor
lookup parameters. When |
None
|
path_sensor_tc_map
|
str | Path | None
|
Optional JSON file keyed by turbine with temperature- compensation signal identifiers resolved after main signal creation. |
None
|
assetlocations_by_turbine
|
Mapping[str, str] | None
|
Optional turbine-to-asset-location override mapping. |
None
|
permission_group_ids
|
Sequence[int] | None
|
Visibility groups applied to created SHM objects. |
None
|
model_definition
|
str | None
|
Optional parent SDK model-definition title used when the project has multiple model definitions for the same asset location. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, AssetSignalUploadResult]
|
Upload results keyed by turbine identifier. |
Examples:
>>> from unittest.mock import Mock
>>> uploader = ShmSignalUploader(shm_api=Mock(), lookup_service=Mock())
>>> processor = Mock()
>>> processor.signals_data = {}
>>> processor.signals_derived_data = {}
>>> uploader.upload_from_processor_files(projectsite="Project A", processor=processor)
{}
Source code in src/owi/metadatabase/shm/upload/signals.py
Functions¶
build_derived_signal_calibration_payloads ¶
Build derived-signal calibration payloads from archive-style data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_main_payload ¶
Build the main derived-signal payload from archive-style data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_parent_patch ¶
Build the parent-signals patch payload for derived signal status rows.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_status_payload ¶
Build the derived-signal status payload used before parent patching.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_sensor_calibration_payloads ¶
Build sensor calibration payload models for one turbine.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_sensor_payloads ¶
build_sensor_payloads(
sensor_type_id,
serial_numbers,
cabinets,
visibility_groups,
visibility="usergroup",
)
Build sensor payload models from parallel columns.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_sensor_type_payloads ¶
build_sensor_type_payloads(
sensor_types_data,
visibility_groups,
path_to_images=None,
visibility="usergroup",
)
Build sensor type payload models from raw records.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_calibration_payloads ¶
Build signal calibration payloads from archive-style offset and CWL data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_main_payload ¶
Build the main signal payload from archive-style signal data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_status_payloads ¶
Build signal status payloads from archive-style status rows.
Source code in src/owi/metadatabase/shm/upload/payloads.py
json_utils ¶
JSON loading helpers shared across SHM modules.
Functions¶
load_json_data ¶
Load JSON data from disk using pathlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_data
|
str | Path | None
|
Path to the JSON document, or |
required |
Returns:
| Type | Description |
|---|---|
Any | None
|
Parsed JSON document, or |
Examples:
Source code in src/owi/metadatabase/shm/json_utils.py
signal_ids ¶
Typed parsing for SHM signal identifiers.
Classes¶
LegacySignalIdentifier
dataclass
¶
LegacySignalIdentifier(
raw,
parts,
subassembly,
signal_type,
lateral_position,
angular_position,
orientation,
)
Parsed representation of an SHM signal identifier.
Functions¶
to_legacy_dict ¶
Return the historical dict shape used by archive payload code.
Source code in src/owi/metadatabase/shm/signal_ids.py
Functions¶
parse_legacy_signal_id ¶
Parse an SHM signal identifier into a typed model.
Source code in src/owi/metadatabase/shm/signal_ids.py
upload_context ¶
Shared context models for SHM upload workflows.
Classes¶
payloads ¶
Non-legacy payload helpers for SHM upload workflows.
Classes¶
SignalPayload
dataclass
¶
SignalPayload(
site,
model_definition,
asset_location,
signal_type,
signal_id,
visibility_groups,
sub_assembly=None,
heading=None,
level=None,
orientation=None,
stats=None,
data_additional=None,
visibility="usergroup",
)
Payload model for signal records.
SignalHistoryPayload
dataclass
¶
SignalHistoryPayload(
signal_id,
activity_start_timestamp,
is_latest_status,
status,
sensor_serial_number=None,
status_approval="yes",
legacy_signal_id=None,
)
Payload model for signal history records.
LeadCorrectionPayload
dataclass
¶
Nested payload model for signal lead correction data.
SignalCalibrationData
dataclass
¶
SignalCalibrationData(
offset=None,
cwl=None,
coefficients=None,
t_ref=None,
gauge_correction=None,
lead_correction=None,
)
Nested payload model for signal calibration data.
SignalCalibrationPayload
dataclass
¶
SignalCalibrationPayload(
signal_id,
calibration_date,
data,
tempcomp_signal_id=None,
status_approval="yes",
)
Payload model for signal calibration records.
DerivedSignalPayload
dataclass
¶
DerivedSignalPayload(
site,
model_definition,
asset_location,
sub_assembly,
signal_type,
derived_signal_id,
visibility_groups,
heading=None,
level=None,
orientation=None,
stats=None,
data_additional=None,
visibility="usergroup",
)
Payload model for derived signal records.
DerivedSignalHistoryPayload
dataclass
¶
DerivedSignalHistoryPayload(
derived_signal_id,
activity_start_timestamp,
is_latest_status,
status,
parent_signals=None,
status_approval="yes",
)
Payload model for derived signal history records.
DerivedSignalHistoryParentSignalsPatch
dataclass
¶
Patch payload for linking parent signals to a derived signal history.
DerivedSignalCalibrationData
dataclass
¶
Nested payload model for derived signal calibration data.
DerivedSignalCalibrationPayload
dataclass
¶
DerivedSignalCalibrationPayload(
derived_signal_id,
calibration_date,
data,
status_approval="yes",
)
Payload model for derived signal calibration records.
SensorTypePayload
dataclass
¶
SensorTypePayload(
name,
type,
type_extended,
hardware_supplier,
file=None,
visibility="usergroup",
visibility_groups=None,
)
Payload model for sensor type records.
SensorPayload
dataclass
¶
SensorPayload(
sensor_type_id,
serial_number,
cabinet,
visibility="usergroup",
visibility_groups=None,
)
Payload model for sensor records.
SensorCalibrationPayload
dataclass
¶
Payload model for sensor calibration records.
Functions¶
build_sensor_payloads ¶
build_sensor_payloads(
sensor_type_id,
serial_numbers,
cabinets,
visibility_groups,
visibility="usergroup",
)
Build sensor payload models from parallel columns.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_sensor_type_payloads ¶
build_sensor_type_payloads(
sensor_types_data,
visibility_groups,
path_to_images=None,
visibility="usergroup",
)
Build sensor type payload models from raw records.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_sensor_calibration_payloads ¶
Build sensor calibration payload models for one turbine.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_main_payload ¶
Build the main signal payload from archive-style signal data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_status_payloads ¶
Build signal status payloads from archive-style status rows.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_signal_calibration_payloads ¶
Build signal calibration payloads from archive-style offset and CWL data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_main_payload ¶
Build the main derived-signal payload from archive-style data.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_status_payload ¶
Build the derived-signal status payload used before parent patching.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_parent_patch ¶
Build the parent-signals patch payload for derived signal status rows.
Source code in src/owi/metadatabase/shm/upload/payloads.py
build_derived_signal_calibration_payloads ¶
Build derived-signal calibration payloads from archive-style data.