Skip to content

Commit 5ca9226

Browse files
authored
Merge pull request #45 from dataiku/feature/sc-205296-add-interval-selection-for-summarydata
feat: [sc-205296] [pi-system plugin] Add interval selection for summarydata
2 parents 804b947 + aa65898 commit 5ca9226

File tree

16 files changed

+162
-51
lines changed

16 files changed

+162
-51
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [Version 1.2.3](https://github.com/dataiku/dss-plugin-pi-server/releases/tag/v1.2.3) - Feature release - 2024-09-26
4+
5+
- Add summaryDuration input (duration of each summary interval)
6+
- Fix issue when using `Starting After` search option in browse PI event frames
7+
- Fix issue with `Value` and `End value` data types in Search attributes dataset
8+
- Add pagination on element retrieval
9+
310
## [Version 1.2.2](https://github.com/dataiku/dss-plugin-pi-server/releases/tag/v1.2.2) - Feature release - 2023-12-11
411

512
- Time range pagination - no more `maxCount` and / or `maxReturnedItemsPerCall` limitation

custom-recipes/pi-system-retrieve-event-frames/recipe.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@
249249
],
250250
"visibilityCondition": "model.data_type == 'SummaryData'"
251251
},
252+
{
253+
"name": "summary_duration",
254+
"label": "Summary duration",
255+
"visibilityCondition": "model.data_type == 'SummaryData'",
256+
"description": "Optional",
257+
"type": "STRING",
258+
"defaultValue": ""
259+
},
252260
{
253261
"name": "max_count",
254262
"label": "Max count",

custom-recipes/pi-system-retrieve-event-frames/recipe.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from safe_logger import SafeLogger
77
from osisoft_plugin_common import (
88
get_credentials, get_interpolated_parameters,
9-
get_advanced_parameters, check_debug_mode, PerformanceTimer, get_max_count, reorder_dataframe
9+
get_advanced_parameters, check_debug_mode, PerformanceTimer,
10+
get_max_count, reorder_dataframe, get_summary_parameters
1011
)
1112
from osisoft_constants import OSIsoftConstants
1213
from osisoft_client import OSIsoftClient
@@ -45,9 +46,9 @@
4546
end_time_column = config.get("end_time_column")
4647
server_url_column = config.get("server_url_column")
4748
search_full_hierarchy = config.get("search_full_hierarchy", None)
48-
summary_type = config.get("summary_type")
4949
use_batch_mode, batch_size = get_advanced_parameters(config)
5050
interval, sync_time, boundary_type = get_interpolated_parameters(config)
51+
summary_type, summary_duration = get_summary_parameters(config)
5152

5253
network_timer = PerformanceTimer()
5354
processing_timer = PerformanceTimer()
@@ -109,7 +110,8 @@
109110
search_full_hierarchy=search_full_hierarchy,
110111
can_raise=False,
111112
max_count=max_count,
112-
summary_type=summary_type
113+
summary_type=summary_type,
114+
summary_duration=summary_duration
113115
)
114116
elif use_batch_mode:
115117
buffer.append({"WebId": object_id, "StartTime": event_frame_start_time, "EndTime": event_frame_end_time})
@@ -120,7 +122,8 @@
120122
search_full_hierarchy=search_full_hierarchy,
121123
can_raise=False,
122124
batch_size=batch_size,
123-
summary_type=summary_type
125+
summary_type=summary_type,
126+
summary_duration=summary_duration
124127
)
125128
batch_buffer_size = 0
126129
buffer = []
@@ -138,7 +141,8 @@
138141
search_full_hierarchy=search_full_hierarchy,
139142
max_count=max_count,
140143
can_raise=False,
141-
summary_type=summary_type
144+
summary_type=summary_type,
145+
summary_duration=summary_duration
142146
)
143147
unnested_items_rows = []
144148
row_count = 0
@@ -155,7 +159,7 @@
155159
item_row = {} if use_batch_mode else {"event_frame_webid": event_frame_webid}
156160
value = item.get("Value", {})
157161
if isinstance(value, dict):
158-
item.pop("Value")
162+
item.pop("Value", None)
159163
item_row.update(value)
160164
item_row.update(base_row)
161165
item_row.update(item)
@@ -164,7 +168,7 @@
164168
item_row = {} if use_batch_mode else {"event_frame_webid": event_frame_webid}
165169
value = base_row.get("Value", {})
166170
if isinstance(value, dict):
167-
base_row.pop("Value")
171+
base_row.pop("Value", None)
168172
base_row.update(value)
169173
item_row.update(base_row)
170174
unnested_items_rows.append(item_row)

custom-recipes/pi-system-retrieve-list/recipe.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@
245245
],
246246
"visibilityCondition": "model.data_type == 'SummaryData'"
247247
},
248+
{
249+
"name": "summary_duration",
250+
"label": "Summary duration",
251+
"visibilityCondition": "model.data_type == 'SummaryData'",
252+
"description": "Optional",
253+
"type": "STRING",
254+
"defaultValue": ""
255+
},
248256
{
249257
"name": "max_count",
250258
"label": "Max count",

custom-recipes/pi-system-retrieve-list/recipe.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
get_credentials, get_interpolated_parameters, normalize_af_path,
88
get_combined_description, get_base_for_data_type, check_debug_mode,
99
PerformanceTimer, get_max_count, check_must_convert_object_to_string,
10-
convert_schema_objects_to_string
10+
convert_schema_objects_to_string, get_summary_parameters
1111
)
1212
from osisoft_client import OSIsoftClient
1313
from osisoft_constants import OSIsoftConstants
@@ -48,6 +48,7 @@
4848
end_time_column = config.get("end_time_column")
4949
server_url_column = config.get("server_url_column")
5050
interval, sync_time, boundary_type = get_interpolated_parameters(config)
51+
summary_type, summary_duration = get_summary_parameters(config)
5152

5253
network_timer = PerformanceTimer()
5354
processing_timer = PerformanceTimer()
@@ -104,7 +105,8 @@
104105
max_count=max_count,
105106
can_raise=False,
106107
object_id=object_id,
107-
summary_type=summary_type
108+
summary_type=summary_type,
109+
summary_duration=summary_duration
108110
)
109111
else:
110112
rows = client.get_rows_from_webid(
@@ -118,7 +120,8 @@
118120
max_count=max_count,
119121
can_raise=False,
120122
endpoint_type="AF",
121-
summary_type=summary_type
123+
summary_type=summary_type,
124+
summary_duration=summary_duration
122125
)
123126
for row in rows:
124127
row["Name"] = row_name

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "pi-system",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"meta": {
55
"label": "PI System",
66
"description": "Retrieve data from your OSIsoft PI System servers",

python-connectors/pi-system_attribute-search/connector.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@
360360
],
361361
"visibilityCondition": "((model.must_retrieve_metrics) && (model.data_type == 'SummaryData'))"
362362
},
363+
{
364+
"name": "summary_duration",
365+
"label": "Summary duration",
366+
"visibilityCondition": "((model.must_retrieve_metrics) && (model.data_type == 'SummaryData'))",
367+
"description": "Optional",
368+
"type": "STRING",
369+
"defaultValue": ""
370+
},
363371
{
364372
"name": "max_count",
365373
"label": "Max count",

python-connectors/pi-system_attribute-search/connector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from osisoft_plugin_common import (
77
PISystemConnectorError, RecordsLimit, get_credentials, assert_time_format,
88
remove_unwanted_columns, format_output, filter_columns_from_schema, is_child_attribute_path,
9-
check_debug_mode, PerformanceTimer, get_max_count
9+
check_debug_mode, PerformanceTimer, get_max_count, get_summary_parameters, fields_selector
1010
)
1111
from osisoft_constants import OSIsoftConstants
1212

@@ -55,7 +55,7 @@ def __init__(self, config, plugin_config):
5555
self.must_filter_child_attributes = not (config.get("must_keep_child_attributes", False))
5656
self.max_count = get_max_count(config)
5757
self.config = config
58-
self.summary_type = config.get("summary_type")
58+
self.summary_type, self.summary_duration = get_summary_parameters(config)
5959

6060
def extract_database_webid(self, database_endpoint):
6161
return database_endpoint.split("/")[-1]
@@ -111,9 +111,10 @@ def generate_rows(self, dataset_schema=None, dataset_partitioning=None,
111111
interval=self.interval,
112112
sync_time=self.sync_time,
113113
endpoint_type="AF",
114-
selected_fields="Links%3BItems.Timestamp%3BItems.Value%3BItems.Type",
114+
selected_fields=fields_selector(self.data_type),
115115
max_count=self.max_count,
116-
summary_type=self.summary_type
116+
summary_type=self.summary_type,
117+
summary_duration=self.summary_duration
117118
# boundary_type=self.boundary_type
118119
):
119120
if limit.is_reached():

python-connectors/pi-system_event-frames-search/connector.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@
220220
],
221221
"visibilityCondition": "((model.must_retrieve_metrics) && (model.database_name.length>=0) && (model.data_type == 'SummaryData'))"
222222
},
223+
{
224+
"name": "summary_duration",
225+
"label": "Summary duration",
226+
"visibilityCondition": "((model.must_retrieve_metrics) && (model.data_type == 'SummaryData'))",
227+
"description": "Optional",
228+
"type": "STRING",
229+
"defaultValue": ""
230+
},
223231
{
224232
"name": "max_count",
225233
"label": "Max count",

python-connectors/pi-system_event-frames-search/connector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from osisoft_plugin_common import (
88
PISystemConnectorError, RecordsLimit, get_credentials,
99
build_requests_params, assert_time_format, get_advanced_parameters, check_debug_mode,
10-
PerformanceTimer, get_max_count
10+
PerformanceTimer, get_max_count, get_summary_parameters
1111
)
1212

1313

@@ -59,10 +59,10 @@ def __init__(self, config, plugin_config):
5959
if self.must_retrieve_metrics:
6060
self.search_full_hierarchy = config.get("search_full_hierarchy", None)
6161
self.data_type = config.get("data_type", "Recorded")
62-
self.summary_type = config.get("summary_type", None)
6362
self.max_count = get_max_count(config)
6463
self.config = config
6564
self.use_batch_mode, self.batch_size = get_advanced_parameters(config)
65+
self.summary_type, self.summary_duration = get_summary_parameters(config)
6666

6767
def get_read_schema(self):
6868
return {
@@ -114,6 +114,7 @@ def generate_rows(self, dataset_schema=None, dataset_partitioning=None,
114114
can_raise=False,
115115
batch_size=self.batch_size,
116116
summary_type=self.summary_type,
117+
summary_duration=self.summary_duration,
117118
max_count=self.max_count
118119
)
119120
for batch_row in batch_rows:
@@ -143,7 +144,7 @@ def generate_rows(self, dataset_schema=None, dataset_partitioning=None,
143144
for event_frame in event_frames:
144145
event_frame_id = event_frame.get("WebId")
145146
event_frame_metrics = self.client.get_rows_from_webid(
146-
event_frame_id, self.data_type, summary_type=self.summary_type,
147+
event_frame_id, self.data_type, summary_type=self.summary_type, summary_duration=self.summary_duration,
147148
search_full_hierarchy=self.search_full_hierarchy, max_count=self.max_count,
148149
can_raise=False
149150
)

0 commit comments

Comments
 (0)