Skip to content
Snippets Groups Projects

Amelioration execution

Merged Axel Carayon requested to merge ameliorationExecution into main
2 files
+ 25
12
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 22
5
@@ -12,8 +12,10 @@ repo = None
@@ -12,8 +12,10 @@ repo = None
folder = None
folder = None
commandsFile = None
commandsFile = None
 
instructionFile = None
inputFiles = []
inputFiles = []
 
outputFiles = []
beforeHash = None
beforeHash = None
@@ -37,7 +39,7 @@ def init(repository,branch) -> None :
@@ -37,7 +39,7 @@ def init(repository,branch) -> None :
os.chdir(folder)
os.chdir(folder)
def getParameters() -> None :
def getParameters() -> None :
global commandsFile, inputFiles, outputFiles, beforeHash
global commandsFile, inputFiles, outputFiles, beforeHash, instructionFile
if not (os.path.exists('experimentResume.yaml')):
if not (os.path.exists('experimentResume.yaml')):
raise Exception("No exeperimentResume.yaml file found, the branch is not an exeperiment")
raise Exception("No exeperimentResume.yaml file found, the branch is not an exeperiment")
with open('experimentResume.yaml', 'r') as stream:
with open('experimentResume.yaml', 'r') as stream:
@@ -46,6 +48,7 @@ def getParameters() -> None :
@@ -46,6 +48,7 @@ def getParameters() -> None :
outputFiles = parameters.get('outputs')
outputFiles = parameters.get('outputs')
inputFiles = parameters.get('inputs')
inputFiles = parameters.get('inputs')
beforeHash = parameters.get('checksums')
beforeHash = parameters.get('checksums')
 
instructionFile = parameters.get('instructions')
def runExperiment() -> None :
def runExperiment() -> None :
@@ -56,6 +59,15 @@ def runExperiment() -> None :
@@ -56,6 +59,15 @@ def runExperiment() -> None :
process.check_returncode()
process.check_returncode()
print("done")
print("done")
 
def checkForInstructions() -> None :
 
if (instructionFile != None) :
 
print("You can check the instructions for the experiment in the file : " + instructionFile)
 
else :
 
warnings.warn("No instructions for the experiment found in the repository")
 
print("Run the exepriment and then press enter when it's done")
 
done = "nope"
 
while (done != "") :
 
done = input()
def genChecksum(file) -> str :
def genChecksum(file) -> str :
hash_md5 = hashlib.md5()
hash_md5 = hashlib.md5()
@@ -68,7 +80,7 @@ def genChecksums() -> list[dict]:
@@ -68,7 +80,7 @@ def genChecksums() -> list[dict]:
checksums = []
checksums = []
for file in os.listdir(OUTPUT_FOLDER) :
for file in os.listdir(OUTPUT_FOLDER) :
if not file.endswith(".gitkeep"):
if not file.endswith(".gitkeep"):
checksums.append({file : genChecksum(f'outputs/{file}')})
checksums.append({f"{OUTPUT_FOLDER}/{file}" : genChecksum(f'{OUTPUT_FOLDER}/{file}')})
return checksums
return checksums
@@ -77,7 +89,7 @@ def compareChecksums() -> bool:
@@ -77,7 +89,7 @@ def compareChecksums() -> bool:
for (dict1, dict2) in zip(beforeHash, genChecksums()):
for (dict1, dict2) in zip(beforeHash, genChecksums()):
for (key, value) in dict1.items():
for (key, value) in dict1.items():
if dict2.get(key) != value :
if dict2.get(key) != value :
warnings.warn(f"{OUTPUT_FOLDER}/{key} has changed")
warnings.warn(f"{key} has changed")
changes = True
changes = True
return changes
return changes
@@ -88,9 +100,14 @@ def run(repository, branch) -> None :
@@ -88,9 +100,14 @@ def run(repository, branch) -> None :
print("Getting the experiment parameters ...")
print("Getting the experiment parameters ...")
getParameters()
getParameters()
print("Running the experiment ...")
print("Running the experiment ...")
runExperiment()
if (commandsFile != None) :
 
runExperiment()
 
else :
 
checkForInstructions()
print("Comparing checksums of the outputs ...")
print("Comparing checksums of the outputs ...")
if (compareChecksums()) :
if (compareChecksums()) :
print("The exepriment was reproduced with succes but some output files are differents.")
print("The exepriment was reproduced with succes but some output files are differents.")
else :
else :
print("The exepriment was reproduced with succes !")
print("The exepriment was reproduced with succes !")
\ No newline at end of file
 
#TODO : sur la mainExperiment15, on a du changement quand on reproduit l'expérience ...
 
\ No newline at end of file
Loading