Skip to content
Snippets Groups Projects
Unverified Commit 257d91ca authored by AxelCarayon's avatar AxelCarayon Committed by GitHub
Browse files

Merge pull request #18 from AxelCarayon/gestionExecution

modification de la gestion de l'exécution et suivi des changements po…
parents e54ed43f 8c2f2f58
Branches
No related tags found
No related merge requests found
...@@ -93,4 +93,5 @@ def run(repository, branch) -> None : ...@@ -93,4 +93,5 @@ def run(repository, branch) -> None :
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 : laisser à l'utilisateur le temps de reproduire l'experience
\ No newline at end of file
...@@ -3,7 +3,6 @@ import git ...@@ -3,7 +3,6 @@ import git
import subprocess import subprocess
import yaml import yaml
import hashlib import hashlib
import collections
import warnings import warnings
EXPERIMENT_RESUME = "experimentResume.yaml" EXPERIMENT_RESUME = "experimentResume.yaml"
...@@ -117,18 +116,6 @@ def askForCommandsFile() -> None: ...@@ -117,18 +116,6 @@ def askForCommandsFile() -> None:
if not fileExists(commandsFile): if not fileExists(commandsFile):
raise Exception(f"{commandsFile} file does not exist") raise Exception(f"{commandsFile} file does not exist")
def captureExperiment() -> None :
print("Capturing commands in terminal, when the experiment is done, type \"done\"")
inputs = []
userInput = input()
while (userInput != "done"):
inputs.append(userInput)
process = subprocess.run(userInput, shell=True)
process.check_returncode()
userInput = input()
print(f"Done recording the experiment, writing commands in a {commandsFile} file")
registeringExperimentInputs(inputs)
def registeringExperimentInputs(inputs) -> None: def registeringExperimentInputs(inputs) -> None:
with open(commandsFile, "w") as file: with open(commandsFile, "w") as file:
for input in inputs: for input in inputs:
...@@ -160,10 +147,23 @@ def scanParameters() -> None: ...@@ -160,10 +147,23 @@ def scanParameters() -> None:
paramsFiles.append(f"{paramsFolder}{file}") paramsFiles.append(f"{paramsFolder}{file}")
def checkGeneratedFiles() -> None : def checkGeneratedFiles() -> None :
changesNotAdded = [ item.a_path for item in repository.index.diff(None) ] editedFiles = [ item.a_path for item in repository.index.diff(None) ] + repository.untracked_files
untrackedFiles = repository.untracked_files outOfPlaceFiles = []
if collections.Counter(outputFiles + inputFiles) != collections.Counter(untrackedFiles + changesNotAdded): logFile = open("outOfPlaceFiles.log","w")
raise Exception("There were files generated or modified outside the input and output folders") for file in editedFiles:
if (outputFolder is not None and file.startswith(outputFolder)) and \
(inputFolder is not None and file.startswith(inputFolder)) and \
(paramsFolder is not None and file.startswith(paramsFolder)):
outOfPlaceFiles.append(file)
logFile.write(f"{file}\n")
logFile.close()
if len(outOfPlaceFiles) == 0:
os.remove("outOfPlaceFiles.log")
else :
raise Exception("""Some files modified or created were not registered as input, output or parameter file.
Thoses files are logged in the file outOfPlaceFiles.log""")
def writeInYaml() -> None: def writeInYaml() -> None:
with open(EXPERIMENT_RESUME, "r") as yamlFile: with open(EXPERIMENT_RESUME, "r") as yamlFile:
...@@ -212,6 +212,7 @@ def genChecksums() -> list[dict]: ...@@ -212,6 +212,7 @@ def genChecksums() -> list[dict]:
checksums.append({file : genChecksum(file)}) checksums.append({file : genChecksum(file)})
return checksums return checksums
def run(folder) -> None : def run(folder) -> None :
init(folder) init(folder)
repository.active_branch.checkout() repository.active_branch.checkout()
...@@ -223,7 +224,9 @@ def run(folder) -> None : ...@@ -223,7 +224,9 @@ def run(folder) -> None :
askForCommandsFile() askForCommandsFile()
runExperiment() runExperiment()
else: else:
captureExperiment() done = ""
while(done != "done"):
done = input("Run your experiment and then type 'done' when you are done : ")
if inputFolder != None : if inputFolder != None :
scanInputFiles() scanInputFiles()
if outputFolder != None : if outputFolder != None :
...@@ -232,4 +235,4 @@ def run(folder) -> None : ...@@ -232,4 +235,4 @@ def run(folder) -> None :
scanParameters() scanParameters()
checkGeneratedFiles() checkGeneratedFiles()
writeInYaml() writeInYaml()
pushBranch() pushBranch()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment