10
10
from exabel_data_sdk .client .api .bulk_insert import BulkInsertFailedError
11
11
from exabel_data_sdk .client .api .data_classes .signal import Signal
12
12
from exabel_data_sdk .services .csv_exception import CsvLoadingException
13
- from exabel_data_sdk .services .csv_loading_constants import DEFAULT_NUMBER_OF_THREADS
13
+ from exabel_data_sdk .services .csv_loading_constants import (
14
+ DEFAULT_NUMBER_OF_RETRIES ,
15
+ DEFAULT_NUMBER_OF_THREADS ,
16
+ )
14
17
from exabel_data_sdk .services .csv_reader import CsvReader
15
18
from exabel_data_sdk .services .entity_mapping_file_reader import EntityMappingFileReader
16
19
from exabel_data_sdk .stubs .exabel .api .data .v1 .time_series_messages_pb2 import DefaultKnownTime
@@ -40,9 +43,12 @@ def load_time_series(
40
43
pit_current_time : bool = False ,
41
44
pit_offset : int = False ,
42
45
create_missing_signals : bool = False ,
46
+ create_tag : bool = True ,
47
+ create_library_signal : bool = True ,
43
48
threads : int = DEFAULT_NUMBER_OF_THREADS ,
44
49
dry_run : bool = False ,
45
50
error_on_any_failure : bool = False ,
51
+ retries : int = DEFAULT_NUMBER_OF_RETRIES ,
46
52
) -> None :
47
53
"""
48
54
Load a CSV file and upload the time series to the Exabel Data API
@@ -64,6 +70,7 @@ def load_time_series(
64
70
dry_run: if True, the file is processed, but no time series are actually uploaded
65
71
error_on_any_failure: if True, an exception is raised if any time series failed to be
66
72
created
73
+ retries: the maximum number of retries to make for each failed request
67
74
"""
68
75
if dry_run :
69
76
print ("Running dry-run..." )
@@ -79,7 +86,9 @@ def load_time_series(
79
86
time_offset = Duration (seconds = 86400 * pit_offset )
80
87
default_known_time = DefaultKnownTime (time_offset = time_offset )
81
88
82
- ts_data = CsvReader .read_csv (filename , separator = separator , string_columns = [0 ])
89
+ ts_data = CsvReader .read_csv (
90
+ filename , separator = separator , string_columns = [0 ], keep_default_na = True
91
+ )
83
92
entity_mapping = EntityMappingFileReader .read_entity_mapping_file (
84
93
entity_mapping_filename , separator = separator
85
94
)
@@ -194,7 +203,7 @@ def load_time_series(
194
203
for signal in missing_signals :
195
204
self ._client .signal_api .create_signal (
196
205
Signal (name = prefix + signal , display_name = signal ),
197
- create_library_signal = True ,
206
+ create_library_signal = create_library_signal ,
198
207
)
199
208
else :
200
209
raise CsvLoadingException (
@@ -212,7 +221,11 @@ def load_time_series(
212
221
213
222
try :
214
223
result = self ._client .time_series_api .bulk_upsert_time_series (
215
- series , create_tag = True , threads = threads , default_known_time = default_known_time
224
+ series ,
225
+ create_tag = create_tag ,
226
+ threads = threads ,
227
+ default_known_time = default_known_time ,
228
+ retries = retries ,
216
229
)
217
230
if error_on_any_failure and result .has_failure ():
218
231
raise CsvLoadingException ("An error occurred while uploading time series." )
0 commit comments