From c2864d3806799aafe16316a274ae9773715a3573 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Wed, 11 Feb 2026 10:11:28 -0300 Subject: [PATCH 1/2] SIENTIAPDE-1478 Enhance API class with optional operation_type in get_core_labels method - Added a new method get_core_labels to the API class that generates core labels for metrics. - Introduced an optional operation_type parameter to control the inclusion of the operation_type key in the returned labels. - Maintained compatibility with the base implementation while providing flexibility for metrics without the operation_type label. --- laborious/activities/api.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/laborious/activities/api.py b/laborious/activities/api.py index 1ad3059..eb31b73 100644 --- a/laborious/activities/api.py +++ b/laborious/activities/api.py @@ -71,6 +71,38 @@ class API(SientiaMonitoring): }, ) + def get_core_labels( + self, + metadata: dict[str, Any], + operation_type: str | None = None, + ) -> dict[str, Any]: + """ + Generate core labels for metrics, optionally including operation_type. + + This override keeps compatibility with the base implementation while adding + a convenience overload behavior: + - When operation_type is provided, it behaves exactly like the base class, + returning labels that include the operation_type key. + - When operation_type is omitted (None), it removes the operation_type key + from the resulting labels. This is useful for metrics, such as the PI Web + API metrics, that are defined without the operation_type label. + + Args: + - metadata (dict[str, Any]): Workflow execution metadata used to derive labels + - operation_type (str | None): Optional operation type label. If None, the + operation_type key will be removed from the returned labels. + + Return: + dict[str, Any]: Core labels dictionary, with operation_type only when provided + """ + base_labels = super().get_core_labels( + metadata=metadata, + operation_type=operation_type or '-', + ) + if operation_type is None: + base_labels.pop('operation_type', None) + return base_labels + def close(self) -> None: """ Close the PI Web API client and shutdown monitoring services. From 3a15ed805817bba6cb66d61c7b105bd06c24c7e5 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Wed, 11 Feb 2026 10:29:56 -0300 Subject: [PATCH 2/2] SIENTIAPDE-1478 Rename get_core_labels method to get_pi_web_api_core_labels in API class for clarity and consistency with PI Web API integration. --- laborious/activities/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laborious/activities/api.py b/laborious/activities/api.py index eb31b73..366ecd2 100644 --- a/laborious/activities/api.py +++ b/laborious/activities/api.py @@ -71,7 +71,7 @@ class API(SientiaMonitoring): }, ) - def get_core_labels( + def get_pi_web_api_core_labels( self, metadata: dict[str, Any], operation_type: str | None = None, @@ -234,7 +234,7 @@ class API(SientiaMonitoring): prediction_tags = list[str](raw_prediction_tags.values()) confidence_tags = list(raw_confidence_tags.values()) - core_labels = self.get_core_labels(metadata) + core_labels = self.get_pi_web_api_core_labels(metadata) prediction_value = data.head(1)['prediction'].values[0] confidence_value = data.head(1)['prediction_confidence'].values[0]