From 2fa33f2053fdb37738e2b3d8f0b413b789459646 Mon Sep 17 00:00:00 2001 From: AxelCarayon <axel.carayon@gmail.com> Date: Tue, 1 Mar 2022 17:52:56 +0100 Subject: [PATCH] ne crash plus si le fichier experimentResume.yaml n'existe pas --- registerExperiment.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/registerExperiment.py b/registerExperiment.py index aa1b061..e763be8 100644 --- a/registerExperiment.py +++ b/registerExperiment.py @@ -209,19 +209,23 @@ def checkGeneratedFiles() -> None : def writeInYaml() -> None: - with open(EXPERIMENT_RESUME, "r") as yamlFile: - cur_yaml = yaml.safe_load(yamlFile) - cur_yaml.update({"name":experimentName}) - cur_yaml.update({"commands":commandsFile}) - cur_yaml.update({"inputs":inputFiles}) - cur_yaml.update({"outputs":outputFiles}) - cur_yaml.update({"params":paramsFiles}) - cur_yaml.update({"instruction":instructionFile}) - cur_yaml.update({"dockerfile":fileExists(DOCKERFILE)}) - checksums = {"checksums":genChecksums()} - cur_yaml.update(checksums) - with open(EXPERIMENT_RESUME, 'w') as yamlFile: - yaml.safe_dump(cur_yaml, yamlFile) + if fileExists(EXPERIMENT_RESUME): + with open(EXPERIMENT_RESUME, "r") as yamlFile: + cur_yaml = yaml.safe_load(yamlFile) + cur_yaml.update({"name":experimentName}) + cur_yaml.update({"commands":commandsFile}) + cur_yaml.update({"inputs":inputFiles}) + cur_yaml.update({"outputs":outputFiles}) + cur_yaml.update({"params":paramsFiles}) + cur_yaml.update({"instruction":instructionFile}) + cur_yaml.update({"dockerfile":fileExists(DOCKERFILE)}) + checksums = {"checksums":genChecksums()} + cur_yaml.update(checksums) + with open(EXPERIMENT_RESUME, 'w') as yamlFile: + yaml.safe_dump(cur_yaml, yamlFile) + else: + with open(EXPERIMENT_RESUME, "w") as yamlFile: + yaml.safe_dump({"name":experimentName, "commands":commandsFile, "inputs":inputFiles, "outputs":outputFiles, "params":paramsFiles, "instruction":instructionFile, "dockerfile":fileExists(DOCKERFILE), "checksums":genChecksums()}, yamlFile) def pushBranch(version=1) -> None: -- GitLab