diff --git a/utils/general.py b/utils/general.py index bce9d6d7455b..ed38cc0d60cf 100644 --- a/utils/general.py +++ b/utils/general.py @@ -616,10 +616,12 @@ def yaml_load(file="data.yaml"): return yaml.safe_load(f) -def yaml_save(file="data.yaml", data={}): +def yaml_save(file="data.yaml", data=None): """Safely saves `data` to a YAML file specified by `file`, converting `Path` objects to strings; `data` is a dictionary. """ + if data is None: + data = {} with open(file, "w") as f: yaml.safe_dump({k: str(v) if isinstance(v, Path) else v for k, v in data.items()}, f, sort_keys=False) diff --git a/utils/loggers/clearml/clearml_utils.py b/utils/loggers/clearml/clearml_utils.py index f1b56650461e..2b5351ef8533 100644 --- a/utils/loggers/clearml/clearml_utils.py +++ b/utils/loggers/clearml/clearml_utils.py @@ -47,10 +47,11 @@ def construct_dataset(clearml_info_string): {"train", "test", "val", "nc", "names"} ), "The right keys were not found in the yaml file, make sure it at least has the following keys: ('train', 'test', 'val', 'nc', 'names')" - data_dict = {} - data_dict["train"] = ( - str((dataset_root_path / dataset_definition["train"]).resolve()) if dataset_definition["train"] else None - ) + data_dict = { + "train": ( + str((dataset_root_path / dataset_definition["train"]).resolve()) if dataset_definition["train"] else None + ) + } data_dict["test"] = ( str((dataset_root_path / dataset_definition["test"]).resolve()) if dataset_definition["test"] else None )