Skip to content

Commit 0b86fdb

Browse files
authored
Expose --abort-threshold on CLI (#147)
1 parent 80ca08c commit 0b86fdb

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

exabel_data_sdk/client/api/data_classes/prediction_model_run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __repr__(self) -> str:
114114
f"PredictionModelRun(name='{self.name}', description='{self.description}', "
115115
f"configuration={self.configuration}, "
116116
f"configuration_source='{self.configuration_source}', "
117-
f"auto_activate={self.auto_activate}"
117+
f"auto_activate={self.auto_activate})"
118118
)
119119

120120
def __lt__(self, other: object) -> bool:

exabel_data_sdk/scripts/csv_script.py

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from exabel_data_sdk.scripts.actions import DeprecatedArgumentAction
99
from exabel_data_sdk.scripts.base_script import BaseScript
1010
from exabel_data_sdk.services.csv_loading_constants import (
11+
DEFAULT_ABORT_THRESHOLD,
1112
DEFAULT_NUMBER_OF_RETRIES,
1213
DEFAULT_NUMBER_OF_THREADS,
1314
)
@@ -76,6 +77,15 @@ def __init__(self, argv: Sequence[str], description: str):
7677
help=f"The maximum number of retries to make for each failed request. Defaults to "
7778
f"{DEFAULT_NUMBER_OF_RETRIES}.",
7879
)
80+
self.parser.add_argument(
81+
"--abort-threshold",
82+
required=False,
83+
type=abort_threshold,
84+
metavar="[0.0-1.0]",
85+
default=DEFAULT_ABORT_THRESHOLD,
86+
help=f"The threshold for the proportion of failed requests that will cause the "
87+
f"upload to be aborted. Defaults to {DEFAULT_ABORT_THRESHOLD}.",
88+
)
7989

8090
def read_csv(
8191
self, args: argparse.Namespace, string_columns: Optional[Collection[Union[str, int]]] = None
@@ -85,3 +95,14 @@ def read_csv(
8595
if string_columns:
8696
dtype = {column: str for column in string_columns}
8797
return pd.read_csv(args.filename, header=0, sep=args.sep, dtype=dtype)
98+
99+
100+
def abort_threshold(val: str) -> float:
101+
"""Convert argument to a valid value for abort_threshold."""
102+
try:
103+
f = float(val)
104+
except ValueError as exc:
105+
raise argparse.ArgumentTypeError(f"{val} not a floating-point literal") from exc
106+
if not 0.0 <= f <= 1.0:
107+
raise argparse.ArgumentTypeError(f"{val} not in range [0.0, 1.0]")
108+
return f

exabel_data_sdk/scripts/load_entities_from_csv.py

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
136136
dry_run=args.dry_run,
137137
retries=args.retries,
138138
batch_size=args.batch_size,
139+
abort_threshold=args.abort_threshold,
139140
)
140141
except (FileLoadingException, ParsePropertyColumnsError) as e:
141142
print(e)

exabel_data_sdk/scripts/load_relationships_from_csv.py

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
208208
dry_run=args.dry_run,
209209
retries=args.retries,
210210
batch_size=args.batch_size,
211+
abort_threshold=args.abort_threshold,
211212
)
212213
except FileLoadingException as e:
213214
print(e)

exabel_data_sdk/scripts/load_time_series_from_file.py

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def run_script(self, client: ExabelClient, args: argparse.Namespace) -> None:
149149
batch_size=args.batch_size,
150150
skip_validation=args.skip_validation,
151151
case_sensitive_signals=args.case_sensitive_signals,
152+
abort_threshold=args.abort_threshold,
152153
)
153154
except FileLoadingException as e:
154155
print(e)

exabel_data_sdk/services/csv_loading_constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
DEFAULT_ABORT_THRESHOLD = 0.5
12
DEFAULT_BULK_LOAD_CHECKPOINTS = 20
23
DEFAULT_NUMBER_OF_THREADS = 40
34
DEFAULT_NUMBER_OF_THREADS_FOR_IMPORT = 4

0 commit comments

Comments
 (0)