Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface the basic configuration with the user before proceeding with validation checking - Issue #196 #321

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions zamba/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def train(

If an argument is specified in both the command line and in a yaml file, the command line input will take precedence.
"""

if config is not None:
with config.open() as f:
config_dict = yaml.safe_load(f)
Expand Down Expand Up @@ -128,6 +129,27 @@ def train(
if skip_load_validation is not None:
train_dict["skip_load_validation"] = skip_load_validation

# surface the configuration before validation checking
msg = f"""Review the following configuration before proceeding with validation checking:

Config file: {config_file}
Data directory: {data_dir if data_dir is not None else config_dict["train_config"].get("data_dir")}
Labels csv: {labels if labels is not None else config_dict["train_config"].get("labels")}
Checkpoint: {checkpoint if checkpoint is not None else config_dict["train_config"].get("checkpoint")}
"""

if yes:
typer.echo(f"{msg}\n\nSkipping confirmation and proceeding to validation checking.")
else:
yes = typer.confirm(
f"{msg}\n\nIs this correct?",
abort=False,
default=True,
)
if not yes:
print("\n\nPlease review and adjust the configuration and run the command again.")
return

try:
manager = ModelManager(
ModelConfig(
Expand Down Expand Up @@ -321,6 +343,27 @@ def predict(
if overwrite is not None:
predict_dict["overwrite"] = overwrite

# surface the configuration before validation checking
msg = f"""Review the following configuration before proceeding with validation checking:

Config file: {config_file}
Data directory: {data_dir if data_dir is not None else config_dict["predict_config"].get("data_dir")}
Filepath csv: {filepaths if filepaths is not None else config_dict["predict_config"].get("filepaths")}
Checkpoint: {checkpoint if checkpoint is not None else config_dict["predict_config"].get("checkpoint")}
"""

if yes:
typer.echo(f"{msg}\n\nSkipping confirmation and proceeding to validation checking.")
else:
yes = typer.confirm(
f"{msg}\n\nIs this correct?",
abort=False,
default=True,
)
if not yes:
print("\n\nPlease review and adjust the configuration and run the command again.")
return

try:
manager = ModelManager(
ModelConfig(
Expand Down
12 changes: 7 additions & 5 deletions zamba/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,13 @@ def validate_filepaths_and_labels(cls, values):
)

elif values["split_proportions"] is not None:
logger.warning(
"Labels contains split column yet split_proportions are also provided. Split column in labels takes precedence."
)
# set to None for clarity in final configuration.yaml
values["split_proportions"] = None
# Check to see if split_proportions contains the default values
if values.get("split_proportions") != {"train": 3, "val": 1, "holdout": 1}:
logger.warning(
"Labels contains split column yet split_proportions are also provided. Split column in labels takes precedence."
)
# set to None for clarity in final configuration.yaml
values["split_proportions"] = None

# error if labels are entirely null
null_labels = labels.label.isnull()
Expand Down