Skip to content

Commit

Permalink
Better support for True/False Data Toolkit script arguments (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
anamileva authored Jan 10, 2025
1 parent 5023d6d commit cf0702e
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 301 deletions.
23 changes: 19 additions & 4 deletions data_toolkit/run_data_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,23 @@ def main(args=None):
settings_dict = {}
for index, row in settings_df.iterrows():
if row["script"] not in settings_dict.keys():
settings_dict[row["script"]] = [(row["setting"], row["value"])]
settings_dict[row["script"]] = [
(
row["setting"],
row["value"],
row["script_true_false_arg"],
row["reverse_default_behavior"],
)
]
else:
settings_dict[row["script"]].append((row["setting"], row["value"]))
settings_dict[row["script"]].append(
(
row["setting"],
row["value"],
row["script_true_false_arg"],
row["reverse_default_behavior"],
)
)

for script_name in settings_dict.keys():
skip = determine_skip(
Expand All @@ -186,14 +200,15 @@ def main(args=None):
if not skip:
settings_list = []
for setting in settings_dict[script_name]:
if "overwrite" not in setting[0]:
if pd.isna(setting[2]) or setting[2] == 0:
settings_list.append(f"--{setting[0]}")
settings_list.append(setting[1])
else:
settings_list.append(f"--{setting[0]}" if int(setting[1]) else "")
settings_list.append(f"--{setting[0]}" if int(setting[3]) else "")

settings_list.append("--quiet" if parsed_args.quiet else "")

print(script_name, settings_list)
# Run the script's main function with the requested arguments
getattr(globals()[script_name], "main")(settings_list)

Expand Down
Loading

0 comments on commit cf0702e

Please sign in to comment.