Skip to content

Commit

Permalink
Add aliases (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur authored Aug 20, 2024
1 parent 7d14b70 commit 4a0d216
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 32 deletions.
13 changes: 11 additions & 2 deletions src/autotrain/cli/run_extractive_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend to use for training",
"required": False,
"default": "local",
},
] + arg_list
arg_list = [arg for arg in arg_list if arg["arg"] != "--disable-gradient-checkpointing"]
run_extractive_qa_parser = parser.add_parser(
"extractive-qa", description="✨ Run AutoTrain Extractive Question Answering"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_extractive_qa_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_extractive_qa_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_image_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
run_image_classification_parser = parser.add_parser(
"image-classification", description="✨ Run AutoTrain Image Classification"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_image_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_image_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_image_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
run_image_regression_parser = parser.add_parser(
"image-regression", description="✨ Run AutoTrain Image Regression"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_image_regression_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_image_regression_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
18 changes: 18 additions & 0 deletions src/autotrain/cli/run_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,25 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
arg_list = [arg for arg in arg_list if arg["arg"] != "--block-size"]
arg_list.append(
{
"arg": "--block_size",
"help": "Block size",
"required": False,
"type": str,
"default": "1024",
"alias": ["--block-size"],
}
)
run_llm_parser = parser.add_parser("llm", description="✨ Run AutoTrain LLM")
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
run_object_detection_parser = parser.add_parser(
"object-detection", description="✨ Run AutoTrain Object Detection"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_object_detection_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_object_detection_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_sent_tranformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
run_sentence_transformers_parser = parser.add_parser(
"sentence-transformers", description="✨ Run AutoTrain Sentence Transformers"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_sentence_transformers_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_sentence_transformers_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,30 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
run_seq2seq_parser = parser.add_parser("seq2seq", description="✨ Run AutoTrain Seq2Seq")
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_seq2seq_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_seq2seq_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,32 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
remove_args = ["--disable_gradient_checkpointing", "--gradient_accumulation", "--epochs", "--log", "--lr"]
arg_list = [arg for arg in arg_list if arg["arg"] not in remove_args]
run_tabular_parser = parser.add_parser("tabular", description="✨ Run AutoTrain Tabular Data Training")
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_tabular_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_tabular_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_text_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,33 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
arg_list = [arg for arg in arg_list if arg["arg"] != "--disable-gradient-checkpointing"]
run_text_classification_parser = parser.add_parser(
"text-classification", description="✨ Run AutoTrain Text Classification"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_text_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_text_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_text_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,33 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
arg_list = [arg for arg in arg_list if arg["arg"] != "--disable-gradient-checkpointing"]
run_text_regression_parser = parser.add_parser(
"text-regression", description="✨ Run AutoTrain Text Regression"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_text_regression_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_text_regression_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
14 changes: 12 additions & 2 deletions src/autotrain/cli/run_token_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,33 @@ def register_subcommand(parser: ArgumentParser):
"required": False,
"action": "store_true",
},
{
"arg": "--backend",
"help": "Backend",
"required": False,
"type": str,
"default": "local",
},
] + arg_list
arg_list = [arg for arg in arg_list if arg["arg"] != "--disable-gradient-checkpointing"]
run_token_classification_parser = parser.add_parser(
"token-classification", description="✨ Run AutoTrain Token Classification"
)
for arg in arg_list:
names = [arg["arg"]] + arg.get("alias", [])
if "action" in arg:
run_token_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
action=arg.get("action"),
default=arg.get("default"),
)
else:
run_token_classification_parser.add_argument(
arg["arg"],
*names,
dest=arg["arg"].replace("--", "").replace("-", "_"),
help=arg["help"],
required=arg.get("required", False),
type=arg.get("type"),
Expand Down
Loading

0 comments on commit 4a0d216

Please sign in to comment.