|
12 | 12 | from modalities.config.config import load_app_config_dict
|
13 | 13 | from modalities.config.instantiation_models import TrainingComponentsInstantiationModel, TrainingReportGenerator
|
14 | 14 | from modalities.evaluator import Evaluator
|
| 15 | +from modalities.exceptions import RunningEnvError |
15 | 16 | from modalities.gym import Gym
|
16 | 17 | from modalities.logging_broker.message_broker import MessageBroker
|
17 | 18 | from modalities.logging_broker.messages import MessageTypes, ProgressUpdate
|
|
21 | 22 | from modalities.registry.registry import Registry
|
22 | 23 | from modalities.trainer import Trainer
|
23 | 24 | from modalities.util import get_synced_experiment_id_of_run, get_total_number_of_trainable_parameters, print_rank_0
|
| 25 | +from modalities.utils.file_ops import get_file_md5sum |
24 | 26 | from modalities.utils.logger_utils import get_logger
|
25 | 27 |
|
26 | 28 | logger = get_logger(name="main")
|
@@ -102,7 +104,15 @@ def run(self, components: TrainingComponentsInstantiationModel):
|
102 | 104 | if not (experiment_path / self.config_path.name).exists():
|
103 | 105 | shutil.copy(self.config_path, experiment_path / self.config_path.name)
|
104 | 106 | else:
|
105 |
| - logger.warning(f"Config file {self.config_path.name} already exists in {experiment_path}. Overwriting.") |
| 107 | + logger.warning(f"Config file {self.config_path.name} already exists in {experiment_path}.") |
| 108 | + # compare md5 hashes of the two files |
| 109 | + existing_config_path = experiment_path / self.config_path.name |
| 110 | + if get_file_md5sum(existing_config_path) != get_file_md5sum(self.config_path): |
| 111 | + raise RunningEnvError( |
| 112 | + f"Config file {self.config_path.name} already exists in {experiment_path}, " |
| 113 | + "but the content is different. Please remove the existing config file or " |
| 114 | + "create a new experiment ID." |
| 115 | + ) |
106 | 116 |
|
107 | 117 | resolved_config_path = (experiment_path / self.config_path.name).with_suffix(".yaml.resolved")
|
108 | 118 | with open(resolved_config_path, "w", encoding="utf-8") as f:
|
|
0 commit comments