Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reproductionTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
Reproductibilité des recherches dans SMAC
reproductionTool
Commits
2bb439ca
Unverified
Commit
2bb439ca
authored
3 years ago
by
AxelCarayon
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #20 from AxelCarayon/ameliorationExecution
Amelioration execution
parents
257d91ca
ad1490f1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
loadExperiment.py
+22
-6
22 additions, 6 deletions
loadExperiment.py
registerExperiment.py
+20
-10
20 additions, 10 deletions
registerExperiment.py
with
42 additions
and
16 deletions
loadExperiment.py
+
22
−
6
View file @
2bb439ca
...
@@ -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,8 @@ def getParameters() -> None :
...
@@ -46,6 +48,8 @@ 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
:
file
=
open
(
commandsFile
,
"
r
"
)
file
=
open
(
commandsFile
,
"
r
"
)
...
@@ -55,6 +59,15 @@ def runExperiment() -> None :
...
@@ -55,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
()
...
@@ -67,7 +80,7 @@ def genChecksums() -> list[dict]:
...
@@ -67,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
...
@@ -76,7 +89,7 @@ def compareChecksums() -> bool:
...
@@ -76,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
...
@@ -87,11 +100,14 @@ def run(repository, branch) -> None :
...
@@ -87,11 +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 !
"
)
#TODO : laisser à l'utilisateur le temps de reproduire l'experience
#TODO : sur la mainExperiment15, on a du changement quand on reproduit l'expérience ...
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
registerExperiment.py
+
20
−
10
View file @
2bb439ca
...
@@ -17,7 +17,8 @@ inputFiles = []
...
@@ -17,7 +17,8 @@ inputFiles = []
paramsFolder
=
None
paramsFolder
=
None
paramsFiles
=
[]
paramsFiles
=
[]
commandsFile
=
"
commands.txt
"
commandsFile
=
None
instructionFile
=
None
experimentName
=
None
experimentName
=
None
...
@@ -111,11 +112,19 @@ def searchForParamsFolder() -> None:
...
@@ -111,11 +112,19 @@ def searchForParamsFolder() -> None:
def
askForCommandsFile
()
->
None
:
def
askForCommandsFile
()
->
None
:
global
commandsFile
global
commandsFile
commandsFile
=
input
(
"
Enter the name of the commands file:
"
)
commandsFile
=
input
(
"
Enter the name of the commands file:
"
)
if
commandsFile
==
""
:
raise
Exception
(
"
No commands file given
"
)
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
askForInstructionFile
()
->
None
:
global
instructionFile
print
(
"
If you have an instruction file, enter its name, otherwise press enter
"
)
instructionFile
=
input
()
if
instructionFile
==
""
:
warnings
.
warn
(
"
No instruction file given, make sure you give instructions to reproduce the experiment along with it
"
)
else
:
if
not
fileExists
(
instructionFile
):
raise
Exception
(
f
"
{
instructionFile
}
file does not exist
"
)
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
:
...
@@ -173,24 +182,21 @@ def writeInYaml() -> None:
...
@@ -173,24 +182,21 @@ def writeInYaml() -> None:
cur_yaml
.
update
({
"
inputs
"
:
inputFiles
})
cur_yaml
.
update
({
"
inputs
"
:
inputFiles
})
cur_yaml
.
update
({
"
outputs
"
:
outputFiles
})
cur_yaml
.
update
({
"
outputs
"
:
outputFiles
})
cur_yaml
.
update
({
"
params
"
:
paramsFiles
})
cur_yaml
.
update
({
"
params
"
:
paramsFiles
})
cur_yaml
.
update
({
"
instruction
"
:
instructionFile
})
checksums
=
{
"
checksums
"
:
genChecksums
()}
checksums
=
{
"
checksums
"
:
genChecksums
()}
cur_yaml
.
update
(
checksums
)
cur_yaml
.
update
(
checksums
)
with
open
(
'
experimentResume.yaml
'
,
'
w
'
)
as
yamlFile
:
with
open
(
'
experimentResume.yaml
'
,
'
w
'
)
as
yamlFile
:
yaml
.
safe_dump
(
cur_yaml
,
yamlFile
)
yaml
.
safe_dump
(
cur_yaml
,
yamlFile
)
def
successfullyCreatedNewBranch
(
name
)
->
bool
:
try
:
repository
.
git
.
checkout
(
'
-b
'
,
name
)
return
True
except
Exception
as
e
:
return
False
def
pushBranch
(
version
=
1
)
->
None
:
def
pushBranch
(
version
=
1
)
->
None
:
print
(
"
Pushing branch...
"
)
print
(
"
Pushing branch...
"
)
while
not
(
successfullyCreatedNewBranch
(
f
"
{
experimentName
}
Experiment
{
version
}
"
)):
while
f
"
{
experimentName
}
Experiment
{
version
}
"
in
repository
.
remote
().
refs
:
print
(
f
"
{
experimentName
}
Experiment
{
version
}
already exists
"
)
version
+=
1
version
+=
1
newTag
=
f
"
{
currentTag
}
-e
{
version
}
"
newTag
=
f
"
{
currentTag
}
-e
{
version
}
"
print
(
f
"
creating
{
experimentName
}
Experiment
{
version
}
branch and pushing changes to it ...
"
)
print
(
f
"
creating
{
experimentName
}
Experiment
{
version
}
branch and pushing changes to it ...
"
)
repository
.
git
.
checkout
(
b
=
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
add
(
all
=
True
)
repository
.
git
.
add
(
all
=
True
)
repository
.
git
.
commit
(
m
=
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
commit
(
m
=
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
push
(
'
--set-upstream
'
,
repository
.
remote
().
name
,
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
push
(
'
--set-upstream
'
,
repository
.
remote
().
name
,
f
"
{
experimentName
}
Experiment
{
version
}
"
)
...
@@ -224,6 +230,7 @@ def run(folder) -> None :
...
@@ -224,6 +230,7 @@ def run(folder) -> None :
askForCommandsFile
()
askForCommandsFile
()
runExperiment
()
runExperiment
()
else
:
else
:
askForInstructionFile
()
done
=
""
done
=
""
while
(
done
!=
"
done
"
):
while
(
done
!=
"
done
"
):
done
=
input
(
"
Run your experiment and then type
'
done
'
when you are done :
"
)
done
=
input
(
"
Run your experiment and then type
'
done
'
when you are done :
"
)
...
@@ -235,4 +242,7 @@ def run(folder) -> None :
...
@@ -235,4 +242,7 @@ def run(folder) -> None :
scanParameters
()
scanParameters
()
checkGeneratedFiles
()
checkGeneratedFiles
()
writeInYaml
()
writeInYaml
()
print
(
"
Please check the experimentResume.yaml, if everything is correct, press enter to continue, otherwise type
\"
abort
\"
"
)
if
input
()
==
"
abort
"
:
raise
Exception
(
"
Aborted
"
)
pushBranch
()
pushBranch
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment