8
8
from exabel_data_sdk .scripts .actions import DeprecatedArgumentAction
9
9
from exabel_data_sdk .scripts .base_script import BaseScript
10
10
from exabel_data_sdk .services .csv_loading_constants import (
11
+ DEFAULT_ABORT_THRESHOLD ,
11
12
DEFAULT_NUMBER_OF_RETRIES ,
12
13
DEFAULT_NUMBER_OF_THREADS ,
13
14
)
@@ -76,6 +77,15 @@ def __init__(self, argv: Sequence[str], description: str):
76
77
help = f"The maximum number of retries to make for each failed request. Defaults to "
77
78
f"{ DEFAULT_NUMBER_OF_RETRIES } ." ,
78
79
)
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
+ )
79
89
80
90
def read_csv (
81
91
self , args : argparse .Namespace , string_columns : Optional [Collection [Union [str , int ]]] = None
@@ -85,3 +95,14 @@ def read_csv(
85
95
if string_columns :
86
96
dtype = {column : str for column in string_columns }
87
97
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
0 commit comments