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
df6bc06f
Commit
df6bc06f
authored
3 years ago
by
AxelCarayon
Browse files
Options
Downloads
Patches
Plain Diff
Utilise le Dockerfile si présent pour reproduire une expérimentation
parent
f45ac970
No related branches found
No related tags found
1 merge request
!21
Ajout docker
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loadExperiment.py
+35
-5
35 additions, 5 deletions
loadExperiment.py
with
35 additions
and
5 deletions
loadExperiment.py
+
35
−
5
View file @
df6bc06f
...
@@ -17,6 +17,7 @@ instructionFile = None
...
@@ -17,6 +17,7 @@ instructionFile = None
inputFiles
=
[]
inputFiles
=
[]
outputFiles
=
[]
outputFiles
=
[]
dockerfileIsPresent
=
False
beforeHash
=
None
beforeHash
=
None
def
init
(
repository
,
branch
)
->
None
:
def
init
(
repository
,
branch
)
->
None
:
...
@@ -39,7 +40,7 @@ def init(repository,branch) -> None :
...
@@ -39,7 +40,7 @@ def init(repository,branch) -> None :
os
.
chdir
(
folder
)
os
.
chdir
(
folder
)
def
getParameters
()
->
None
:
def
getParameters
()
->
None
:
global
commandsFile
,
inputFiles
,
outputFiles
,
beforeHash
,
instructionFile
global
commandsFile
,
inputFiles
,
outputFiles
,
beforeHash
,
instructionFile
,
dockerfileIsPresent
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
:
...
@@ -49,6 +50,7 @@ def getParameters() -> None :
...
@@ -49,6 +50,7 @@ def getParameters() -> None :
inputFiles
=
parameters
.
get
(
'
inputs
'
)
inputFiles
=
parameters
.
get
(
'
inputs
'
)
beforeHash
=
parameters
.
get
(
'
checksums
'
)
beforeHash
=
parameters
.
get
(
'
checksums
'
)
instructionFile
=
parameters
.
get
(
'
instructions
'
)
instructionFile
=
parameters
.
get
(
'
instructions
'
)
dockerfileIsPresent
=
parameters
.
get
(
'
dockerfile
'
)
def
runExperiment
()
->
None
:
def
runExperiment
()
->
None
:
...
@@ -94,16 +96,44 @@ def compareChecksums() -> bool:
...
@@ -94,16 +96,44 @@ def compareChecksums() -> bool:
return
changes
return
changes
def
buildDockerImage
()
->
None
:
print
(
"
Building the docker image ...
"
)
try
:
subprocess
.
run
(
f
"
docker build -t experimentreproduction ./
"
,
shell
=
True
).
check_returncode
()
except
:
subprocess
.
run
(
f
"
sudo docker build -t experimentreproduction ./
"
,
shell
=
True
).
check_returncode
()
def
getWorkir
()
->
str
:
workdir
=
"
/
"
with
open
(
"
Dockerfile
"
,
"
r
"
)
as
file
:
for
line
in
file
.
read
().
splitlines
():
if
line
.
startswith
(
"
WORKDIR
"
):
workdir
=
line
.
split
(
"
"
)[
1
]
return
workdir
def
runDockerImage
()
->
None
:
print
(
"
binding docker image to the current directory and running it...
"
)
try
:
subprocess
.
run
(
f
"
docker run -it --mount type=bind,source=
\"
$PWD
\"
,target=
{
getWorkir
()
}
experimentreproduction
"
,
shell
=
True
).
check_returncode
()
except
:
subprocess
.
run
(
f
"
sudo docker run -it --mount type=bind,source=
\"
$PWD
\"
,target=
{
getWorkir
()
}
experimentreproduction
"
,
shell
=
True
).
check_returncode
()
def
run
(
repository
,
branch
)
->
None
:
def
run
(
repository
,
branch
)
->
None
:
print
(
"
Initializing the experiment repository ...
"
)
print
(
"
Initializing the experiment repository ...
"
)
init
(
repository
,
branch
)
init
(
repository
,
branch
)
print
(
"
Getting the experiment parameters ...
"
)
print
(
"
Getting the experiment parameters ...
"
)
getParameters
()
getParameters
()
print
(
"
Running the experiment ...
"
)
print
(
"
Running the experiment ...
"
)
if
(
commandsFile
!=
None
)
:
if
(
dockerfileIsPresent
)
:
runExperiment
()
print
(
"
Dockerimage was found ! Using it to run the experiment...
"
)
else
:
buildDockerImage
()
checkForInstructions
()
runDockerImage
()
else
:
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.
"
)
...
...
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