in mtrl/utils/config.py [0:0]
def _process_setup_config(config: ConfigType) -> ConfigType:
"""Process the `setup` node of the config.
Args:
config (ConfigType): config object.
Returns:
[ConfigType]: processed config.
"""
setup_config = config.setup
if setup_config.base_path is None:
setup_config.base_path = hydra.utils.get_original_cwd()
if not setup_config.debug.should_enable:
setup_config.id = f"{hashlib.sha224(setup_config.description.encode()).hexdigest()}_issue_{setup_config.git.issue_id}_seed_{setup_config.seed}"
current_commit_id = utils.get_current_commit_id()
if not setup_config.git.commit_id:
setup_config.git.commit_id = current_commit_id
else:
# if the commit id is already set, assert that the commit id (in the
# config) is the same as the current commit id.
if setup_config.git.commit_id != current_commit_id:
raise RuntimeError(
f"""The current commit id ({current_commit_id}) does
not match the commit id from the config
({setup_config.git.commit_id})"""
)
if setup_config.git.has_uncommitted_changes == "":
setup_config.git.has_uncommitted_changes = utils.has_uncommitted_changes()
if not setup_config.date:
setup_config.date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
slurm_id = []
env_var_names = ["SLURM_JOB_ID", "SLURM_STEP_ID"]
for var_name in env_var_names:
if var_name in os.environ:
slurm_id.append(str(os.environ[var_name]))
if slurm_id:
setup_config.slurm_id = "-".join(slurm_id)
else:
setup_config.slurm_id = "-1"
return config