More cleaning
Browse files
src/commands/config/config_utils.py
CHANGED
@@ -13,6 +13,7 @@ DYNAMO_BACKENDS = [
|
|
13 |
"IPEX",
|
14 |
"TVM",
|
15 |
]
|
|
|
16 |
def _ask_field(input_text, convert_value=None, default=None, error_message=None):
|
17 |
ask_again = True
|
18 |
while ask_again:
|
@@ -24,27 +25,35 @@ def _ask_field(input_text, convert_value=None, default=None, error_message=None)
|
|
24 |
except Exception:
|
25 |
if error_message is not None:
|
26 |
print(error_message)
|
|
|
27 |
def _ask_options(input_text, options=[], convert_value=None, default=0):
|
28 |
menu = BulletMenu(input_text, options)
|
29 |
result = menu.run(default_choice=default)
|
30 |
return convert_value(result) if convert_value is not None else result
|
|
|
31 |
def _convert_compute_environment(value):
|
32 |
value = int(value)
|
33 |
return ComputeEnvironment(["LOCAL_MACHINE", "AMAZON_SAGEMAKER"][value])
|
|
|
34 |
def _convert_distributed_mode(value):
|
35 |
value = int(value)
|
36 |
return DistributedType(["NO", "MULTI_CPU", "MULTI_XPU", "MULTI_GPU", "MULTI_NPU", "TPU"][value])
|
|
|
37 |
def _convert_dynamo_backend(value):
|
38 |
value = int(value)
|
39 |
return DynamoBackend(DYNAMO_BACKENDS[value]).value
|
|
|
40 |
def _convert_mixed_precision(value):
|
41 |
value = int(value)
|
42 |
return PrecisionType(["no", "fp16", "bf16", "fp8"][value])
|
|
|
43 |
def _convert_sagemaker_distributed_mode(value):
|
44 |
value = int(value)
|
45 |
return SageMakerDistributedType(["NO", "DATA_PARALLEL", "MODEL_PARALLEL"][value])
|
|
|
46 |
def _convert_yes_no_to_bool(value):
|
47 |
return {"yes": True, "no": False}[value.lower()]
|
|
|
48 |
class SubcommandHelpFormatter(argparse.RawDescriptionHelpFormatter):
|
49 |
"""
|
50 |
A custom formatter that will remove the usage line from the help message for subcommands.
|
|
|
13 |
"IPEX",
|
14 |
"TVM",
|
15 |
]
|
16 |
+
|
17 |
def _ask_field(input_text, convert_value=None, default=None, error_message=None):
|
18 |
ask_again = True
|
19 |
while ask_again:
|
|
|
25 |
except Exception:
|
26 |
if error_message is not None:
|
27 |
print(error_message)
|
28 |
+
|
29 |
def _ask_options(input_text, options=[], convert_value=None, default=0):
|
30 |
menu = BulletMenu(input_text, options)
|
31 |
result = menu.run(default_choice=default)
|
32 |
return convert_value(result) if convert_value is not None else result
|
33 |
+
|
34 |
def _convert_compute_environment(value):
|
35 |
value = int(value)
|
36 |
return ComputeEnvironment(["LOCAL_MACHINE", "AMAZON_SAGEMAKER"][value])
|
37 |
+
|
38 |
def _convert_distributed_mode(value):
|
39 |
value = int(value)
|
40 |
return DistributedType(["NO", "MULTI_CPU", "MULTI_XPU", "MULTI_GPU", "MULTI_NPU", "TPU"][value])
|
41 |
+
|
42 |
def _convert_dynamo_backend(value):
|
43 |
value = int(value)
|
44 |
return DynamoBackend(DYNAMO_BACKENDS[value]).value
|
45 |
+
|
46 |
def _convert_mixed_precision(value):
|
47 |
value = int(value)
|
48 |
return PrecisionType(["no", "fp16", "bf16", "fp8"][value])
|
49 |
+
|
50 |
def _convert_sagemaker_distributed_mode(value):
|
51 |
value = int(value)
|
52 |
return SageMakerDistributedType(["NO", "DATA_PARALLEL", "MODEL_PARALLEL"][value])
|
53 |
+
|
54 |
def _convert_yes_no_to_bool(value):
|
55 |
return {"yes": True, "no": False}[value.lower()]
|
56 |
+
|
57 |
class SubcommandHelpFormatter(argparse.RawDescriptionHelpFormatter):
|
58 |
"""
|
59 |
A custom formatter that will remove the usage line from the help message for subcommands.
|