Skip to content

Commit 8b31b17

Browse files
authored
exabel-data-sdk 4.5.0 (#150)
* Add KPI mappings to library search * Expose --abort-threshold on CLI * Add page-size argument to list_relationships script * Don't convert iterator to list * Support --replace-existing-time-series in time series import * Upgrade gRPC libraries
1 parent 4af8dd2 commit 8b31b17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+953
-751
lines changed

Pipfile.lock

+68-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.4.0
1+
4.5.0

exabel_data_sdk/client/api/data_classes/folder_item.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ class FolderItemType(Enum):
2828
TAG = ProtoFolderItemType.TAG
2929
# Screen.
3030
SCREEN = ProtoFolderItemType.SCREEN
31-
# Financial Model
31+
# Financial Model.
3232
FINANCIAL_MODEL = ProtoFolderItemType.FINANCIAL_MODEL
33-
# Chart
33+
# Chart.
3434
CHART = ProtoFolderItemType.CHART
35+
# KPI mapping.
36+
KPI_MAPPING = ProtoFolderItemType.KPI_MAPPING
3537

3638

3739
class FolderItem:

exabel_data_sdk/client/api/time_series_api.py

+18
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def import_time_series(
284284
allow_missing: bool = False,
285285
create_tag: bool = False,
286286
status_in_response: bool = False,
287+
replace_existing_time_series: bool = False,
287288
) -> Optional[Sequence[ResourceCreationResult]]:
288289
"""
289290
Import multiple time series.
@@ -309,6 +310,13 @@ def import_time_series(
309310
ResourceCreationResult.
310311
If set to false, a failure for one time series will fail the entire
311312
request, and a sample of the failures will be reported in the exception.
313+
replace_existing_time_series:
314+
Set to true to first delete all data from existing time series. This
315+
means that all historical and point-in-time data for the time series
316+
will be destroyed and replaced with the data in this call.
317+
Use with care! For instance: If this flag is set, and an import job
318+
splits one time series over multiple calls, only the data in the last
319+
call will be kept.
312320
Returns:
313321
If status_in_response is set to true, a list of ResourceCreationResult will be returned.
314322
Otherwise, None is returned.
@@ -324,6 +332,7 @@ def import_time_series(
324332
allow_missing=allow_missing,
325333
create_tag=create_tag,
326334
status_in_response=status_in_response,
335+
replace_existing_time_series=replace_existing_time_series,
327336
),
328337
)
329338

@@ -424,6 +433,7 @@ def bulk_upsert_time_series(
424433
create_tag: bool = False,
425434
threads: int = DEFAULT_NUMBER_OF_THREADS_FOR_IMPORT,
426435
default_known_time: Optional[DefaultKnownTime] = None,
436+
replace_existing_time_series: bool = False,
427437
retries: int = DEFAULT_NUMBER_OF_RETRIES,
428438
abort_threshold: Optional[float] = 0.5,
429439
# Deprecated arguments
@@ -450,6 +460,13 @@ def bulk_upsert_time_series(
450460
the Known Time for data points where a specific known time timestamp
451461
has not been given. If not provided, the Exabel API defaults to the
452462
current time (upload time) as the Known Time.
463+
replace_existing_time_series:
464+
Set to true to first delete all data from existing time series. This
465+
means that all historical and point-in-time data for the time series
466+
will be destroyed and replaced with the data in this call.
467+
Use with care! For instance: If this flag is set, and an import job
468+
splits one time series over multiple calls, only the data in the last
469+
call will be kept.
453470
retries: Maximum number of retries to make for each failed request.
454471
abort_threshold:
455472
The threshold for the proportion of failed requests that will cause the
@@ -467,6 +484,7 @@ def import_func(ts_sequence: Sequence[pd.Series]) -> Sequence[ResourceCreationRe
467484
allow_missing=True,
468485
create_tag=create_tag,
469486
status_in_response=True,
487+
replace_existing_time_series=replace_existing_time_series,
470488
)
471489
assert result is not None
472490
return result

exabel_data_sdk/scripts/list_relationships.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def __init__(self, argv: Sequence[str], description: str):
3535
type=str,
3636
help="The resource name of the entity the relationships go to",
3737
)
38+
self.parser.add_argument(
39+
"--page-size",
40+
required=False,
41+
type=int,
42+
default=1000,
43+
help="The page size to use for retrieving all relationships"
44+
" (not applicable when specifying an entity)",
45+
)
3846

3947
def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
4048
if args.from_entity and args.to_entity:
@@ -49,20 +57,16 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
4957
return
5058
relationship_type = args.relationship_type
5159
if args.from_entity is not None:
52-
all_relationships = list(
53-
client.relationship_api.get_relationships_from_entity_iterator(
54-
relationship_type, entity
55-
)
60+
all_relationships = client.relationship_api.get_relationships_from_entity_iterator(
61+
relationship_type, entity
5662
)
5763
elif args.to_entity is not None:
58-
all_relationships = list(
59-
client.relationship_api.get_relationships_to_entity_iterator(
60-
relationship_type, entity
61-
)
64+
all_relationships = client.relationship_api.get_relationships_to_entity_iterator(
65+
relationship_type, entity
6266
)
6367
else:
64-
all_relationships = list(
65-
client.relationship_api.get_relationships_iterator(relationship_type)
68+
all_relationships = client.relationship_api.get_relationships_iterator(
69+
relationship_type, page_size=args.page_size
6670
)
6771

6872
if not all_relationships:

exabel_data_sdk/scripts/load_time_series_from_file.py

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def __init__(self, argv: Sequence[str]):
129129
"'known_time'. Take care to maintain correct casing in the file when using this "
130130
"option.",
131131
)
132+
self.parser.add_argument(
133+
"--replace-existing-time-series",
134+
required=False,
135+
action="store_true",
136+
default=False,
137+
help="Replace any existing time series when importing",
138+
)
132139

133140
def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
134141
try:
@@ -150,6 +157,7 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
150157
skip_validation=args.skip_validation,
151158
case_sensitive_signals=args.case_sensitive_signals,
152159
abort_threshold=args.abort_threshold,
160+
replace_existing_time_series=args.replace_existing_time_series,
153161
)
154162
except FileLoadingException as e:
155163
print(e)

0 commit comments

Comments
 (0)