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
960405ce
Commit
960405ce
authored
3 years ago
by
AxelCarayon
Browse files
Options
Downloads
Patches
Plain Diff
ajout de la capture des inputs dans un terminal
parent
a2eddec8
Branches
CaptureInputsTerminal
Branches containing commit
No related tags found
1 merge request
!8
ajout de la capture des inputs dans un terminal #3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
registerExperiment.py
+34
-8
34 additions, 8 deletions
registerExperiment.py
with
34 additions
and
8 deletions
registerExperiment.py
+
34
−
8
View file @
960405ce
...
...
@@ -13,7 +13,7 @@ inputFiles = []
paramsFolder
=
None
commandsFile
=
None
commandsFile
=
"
commands.txt
"
experimentName
=
None
...
...
@@ -78,6 +78,24 @@ def askForCommandsFile() -> None:
if
not
fileExists
(
commandsFile
):
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
:
with
open
(
commandsFile
,
"
w
"
)
as
file
:
for
input
in
inputs
:
file
.
write
(
input
+
"
\n
"
)
def
runExperiment
()
->
None
:
print
(
"
Trying to run experiment
"
)
file
=
open
(
commandsFile
,
"
r
"
)
...
...
@@ -118,12 +136,16 @@ def pushBranch(version=1) -> None:
version
+=
1
else
:
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
.
commit
(
m
=
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
push
(
'
--set-upstream
'
,
repository
.
remote
().
name
,
f
"
{
experimentName
}
Experiment
{
version
}
"
)
try
:
repository
.
git
.
checkout
(
'
-b
'
,
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
add
(
all
=
True
)
repository
.
git
.
commit
(
m
=
f
"
{
experimentName
}
Experiment
{
version
}
"
)
repository
.
git
.
push
(
'
--set-upstream
'
,
repository
.
remote
().
name
,
f
"
{
experimentName
}
Experiment
{
version
}
"
)
print
(
"
done
"
)
except
Exception
as
e
:
print
(
"
error while pushing branch
"
)
print
(
e
)
repository
.
git
.
checkout
(
experimentName
)
print
(
"
done
"
)
def
genChecksum
(
file
)
->
str
:
hash_md5
=
hashlib
.
md5
()
...
...
@@ -144,8 +166,12 @@ def run(folder) -> None :
searchForInputFolder
()
searchForOutputFolder
()
searchForParamsFolder
()
askForCommandsFile
()
runExperiment
()
userInput
=
input
(
"
Do you have a pre-recorded commands file? (y/n)
"
)
if
userInput
==
"
y
"
:
askForCommandsFile
()
runExperiment
()
else
:
captureExperiment
()
scanInputFiles
()
scanOutputsGenerated
()
writeInYaml
()
...
...
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