Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepdraw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
medai
software
deepdraw
Commits
b28ff7d1
Commit
b28ff7d1
authored
5 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[test.test_cli] Test more variants; Use regexp for string matching everywhere
parent
97bc8179
No related branches found
No related tags found
1 merge request
!12
Streamlining
Pipeline
#39123
passed
5 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/ip/binseg/test/test_cli.py
+89
-58
89 additions, 58 deletions
bob/ip/binseg/test/test_cli.py
with
89 additions
and
58 deletions
bob/ip/binseg/test/test_cli.py
+
89
−
58
View file @
b28ff7d1
...
@@ -64,11 +64,10 @@ def test_experiment_help():
...
@@ -64,11 +64,10 @@ def test_experiment_help():
def
_str_counter
(
substr
,
s
):
def
_str_counter
(
substr
,
s
):
return
sum
(
1
for
_
in
re
.
finditer
(
r
"
%s
"
%
re
.
escape
(
substr
)
,
s
))
return
sum
(
1
for
_
in
re
.
finditer
(
substr
,
s
,
re
.
MULTILINE
))
@rc_variable_set
(
"
bob.ip.binseg.stare.datadir
"
)
def
_check_experiment_stare
(
overlay
):
def
test_experiment_stare
():
from
..script.experiment
import
experiment
from
..script.experiment
import
experiment
...
@@ -88,18 +87,17 @@ def test_experiment_stare():
...
@@ -88,18 +87,17 @@ def test_experiment_stare():
config
.
flush
()
config
.
flush
()
output_folder
=
"
results
"
output_folder
=
"
results
"
result
=
runner
.
invoke
(
options
=
[
experiment
,
[
"
m2unet
"
,
"
m2unet
"
,
config
.
name
,
config
.
name
,
"
-vv
"
,
"
-vv
"
,
"
--epochs=1
"
,
"
--epochs=1
"
,
"
--batch-size=1
"
,
"
--batch-size=1
"
,
"
--overlayed
"
,
f
"
--output-folder=
{
output_folder
}
"
,
f
"
--output-folder=
{
output_folder
}
"
,
],
]
)
if
overlay
:
options
+=
[
"
--overlayed
"
]
result
=
runner
.
invoke
(
experiment
,
options
)
_assert_exit_0
(
result
)
_assert_exit_0
(
result
)
# check command-line
# check command-line
...
@@ -118,55 +116,68 @@ def test_experiment_stare():
...
@@ -118,55 +116,68 @@ def test_experiment_stare():
assert
os
.
path
.
exists
(
basedir
)
assert
os
.
path
.
exists
(
basedir
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.hdf5
"
)),
20
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.hdf5
"
)),
20
)
# check overlayed images are there (since we requested them)
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
predictions
"
)
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
predictions
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
assert
os
.
path
.
exists
(
basedir
)
if
overlay
:
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
# check overlayed images are there (since we requested them)
assert
os
.
path
.
exists
(
basedir
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
else
:
assert
not
os
.
path
.
exists
(
basedir
)
# check evaluation outputs
# check evaluation outputs
eval_folder
=
os
.
path
.
join
(
output_folder
,
"
analysis
"
)
eval_folder
=
os
.
path
.
join
(
output_folder
,
"
analysis
"
)
second_folder
=
os
.
path
.
join
(
eval_folder
,
"
second-annotator
"
)
second_folder
=
os
.
path
.
join
(
eval_folder
,
"
second-annotator
"
)
assert
os
.
path
.
exists
(
os
.
path
.
join
(
eval_folder
,
"
train
"
,
"
metrics.csv
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
eval_folder
,
"
train
"
,
"
metrics.csv
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
eval_folder
,
"
test
"
,
"
metrics.csv
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
eval_folder
,
"
test
"
,
"
metrics.csv
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
second_folder
,
"
train
"
,
"
metrics.csv
"
))
assert
os
.
path
.
exists
(
assert
os
.
path
.
exists
(
os
.
path
.
join
(
second_folder
,
"
test
"
,
"
metrics.csv
"
))
os
.
path
.
join
(
second_folder
,
"
train
"
,
"
metrics.csv
"
)
)
assert
os
.
path
.
exists
(
os
.
path
.
join
(
second_folder
,
"
test
"
,
"
metrics.csv
"
)
)
# check overlayed images are there (since we requested them)
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
analysis
"
)
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
analysis
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
assert
os
.
path
.
exists
(
basedir
)
if
overlay
:
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
# check overlayed images are there (since we requested them)
assert
os
.
path
.
exists
(
basedir
)
# check overlayed images from first-to-second annotator comparisons are
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
# there (since we requested them)
else
:
assert
not
os
.
path
.
exists
(
basedir
)
# check overlayed images from first-to-second annotator comparisons
# are there (since we requested them)
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
analysis
"
,
overlay_folder
=
os
.
path
.
join
(
output_folder
,
"
overlayed
"
,
"
analysis
"
,
"
second-annotator
"
)
"
second-annotator
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
basedir
=
os
.
path
.
join
(
overlay_folder
,
"
stare-images
"
)
assert
os
.
path
.
exists
(
basedir
)
if
overlay
:
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
assert
os
.
path
.
exists
(
basedir
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
20
)
else
:
assert
not
os
.
path
.
exists
(
basedir
)
# check outcomes of the comparison phase
# check outcomes of the comparison phase
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
comparison.pdf
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
comparison.pdf
"
))
keywords
=
{
# from different logging systems
keywords
=
{
"
Started training
"
:
1
,
# logging
r
"
^
Started training
$
"
:
1
,
"
Found (dedicated)
'
__train__
'
set for training
"
:
1
,
# logging
r
"
^
Found
\
(dedicated
\
)
'
__train__
'
set for training
$
"
:
1
,
"
epoch:
1
|total-time
"
:
1
,
# logging
r
"
^
epoch:
\d+\
|total-time
"
:
1
,
"
Saving checkpoint
"
:
1
,
# logging
r
"
^
Saving checkpoint
"
:
1
,
"
Ended training
"
:
1
,
# logging
r
"
^
Ended training
$
"
:
1
,
"
Started prediction
"
:
1
,
# logging
r
"
^
Started prediction
$
"
:
1
,
"
Loading checkpoint from
"
:
2
,
# logging
r
"
^
Loading checkpoint from
"
:
2
,
# "Saving results/overlay
ed
/
pr
obabilities": 1, #tqdm.write
r
"
^End
ed
pr
ediction$
"
:
1
,
"
Ended predic
tion
"
:
1
,
# logging
r
"
^Started evalua
tion
$
"
:
1
,
"
Started evaluation
"
:
1
,
# logging
r
"
^Maximum F1-score of.*\(chosen \*a posteriori\*\)$
"
:
3
,
"
Highest
F1-score of
"
:
4
,
# logging
r
"
^
F1-score of
.*\(chosen \*a priori\*\)$
"
:
2
,
"
Saving overall precision-recall plot
"
:
2
,
# logging
r
"
^Maximum F1-score of .* \(second annotator\)$
"
:
2
,
# "
Saving
results/overlayed/analysis": 1, #tqdm.write
r
"
^
Saving
overall precision-recall plot at .*$
"
:
2
,
"
Ended evaluation
"
:
1
,
# logging
r
"
^
Ended evaluation
$
"
:
1
,
"
Started comparison
"
:
1
,
# logging
r
"
^
Started comparison
$
"
:
1
,
"
Loading metrics from
"
:
4
,
# logging
r
"
^
Loading metrics from
"
:
4
,
"
Ended comparison
"
:
1
,
# logging
r
"
^
Ended comparison
.*$
"
:
1
,
}
}
buf
.
seek
(
0
)
buf
.
seek
(
0
)
logging_output
=
buf
.
read
()
logging_output
=
buf
.
read
()
...
@@ -182,6 +193,16 @@ def test_experiment_stare():
...
@@ -182,6 +193,16 @@ def test_experiment_stare():
)
)
@rc_variable_set
(
"
bob.ip.binseg.stare.datadir
"
)
def
test_experiment_stare_with_overlay
():
_check_experiment_stare
(
overlay
=
True
)
@rc_variable_set
(
"
bob.ip.binseg.stare.datadir
"
)
def
test_experiment_stare_without_overlay
():
_check_experiment_stare
(
overlay
=
False
)
def
_check_train
(
runner
):
def
_check_train
(
runner
):
from
..script.train
import
train
from
..script.train
import
train
...
@@ -202,8 +223,14 @@ def _check_train(runner):
...
@@ -202,8 +223,14 @@ def _check_train(runner):
output_folder
=
"
results
"
output_folder
=
"
results
"
result
=
runner
.
invoke
(
result
=
runner
.
invoke
(
train
,
train
,
[
"
m2unet
"
,
config
.
name
,
"
-vv
"
,
"
--epochs=1
"
,
"
--batch-size=1
"
,
[
f
"
--output-folder=
{
output_folder
}
"
],
"
m2unet
"
,
config
.
name
,
"
-vv
"
,
"
--epochs=1
"
,
"
--batch-size=1
"
,
f
"
--output-folder=
{
output_folder
}
"
,
],
)
)
_assert_exit_0
(
result
)
_assert_exit_0
(
result
)
...
@@ -211,11 +238,11 @@ def _check_train(runner):
...
@@ -211,11 +238,11 @@ def _check_train(runner):
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
last_checkpoint
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
last_checkpoint
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
trainlog.csv
"
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
output_folder
,
"
trainlog.csv
"
))
keywords
=
{
# from different logging systems
keywords
=
{
"
Continuing from epoch 0
"
:
1
,
# logging
r
"
^
Continuing from epoch 0
$
"
:
1
,
"
epoch:
1
|total-time
"
:
1
,
# logging
r
"
^
epoch:
\d+\
|total-time
"
:
1
,
f
"
Saving checkpoint to
{
output_folder
}
/model_final.pth
"
:
1
,
# logging
r
f
"
^
Saving checkpoint to
{
output_folder
}
/model_final.pth
$
"
:
1
,
"
Total training time:
"
:
1
,
# logging
r
"
^
Total training time:
"
:
1
,
}
}
buf
.
seek
(
0
)
buf
.
seek
(
0
)
logging_output
=
buf
.
read
()
logging_output
=
buf
.
read
()
...
@@ -276,9 +303,9 @@ def _check_predict(runner):
...
@@ -276,9 +303,9 @@ def _check_predict(runner):
assert
os
.
path
.
exists
(
basedir
)
assert
os
.
path
.
exists
(
basedir
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
10
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
10
)
keywords
=
{
# from different logging systems
keywords
=
{
"
Loading checkpoint from
"
:
1
,
# logging
r
"
^
Loading checkpoint from
.*$
"
:
1
,
"
Total time:
"
:
1
,
# logging
r
"
^
Total time:
.*$
"
:
1
,
}
}
buf
.
seek
(
0
)
buf
.
seek
(
0
)
logging_output
=
buf
.
read
()
logging_output
=
buf
.
read
()
...
@@ -337,10 +364,12 @@ def _check_evaluate(runner):
...
@@ -337,10 +364,12 @@ def _check_evaluate(runner):
assert
os
.
path
.
exists
(
basedir
)
assert
os
.
path
.
exists
(
basedir
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
10
)
nose
.
tools
.
eq_
(
len
(
fnmatch
.
filter
(
os
.
listdir
(
basedir
),
"
*.png
"
)),
10
)
keywords
=
{
# from different logging systems
keywords
=
{
"
Skipping dataset
'
__train__
'"
:
0
,
# logging
r
"
^Skipping dataset
'
__train__
'"
:
0
,
"
Saving averages over all input images
"
:
2
,
# logging
r
"
^Saving averages over all input images.*$
"
:
2
,
"
Highest F1-score
"
:
2
,
# logging
r
"
^Maximum F1-score of.*\(chosen \*a posteriori\*\)$
"
:
1
,
r
"
^F1-score of.*\(chosen \*a priori\*\)$
"
:
1
,
r
"
^Maximum F1-score of .* \(second annotator\)$
"
:
1
,
}
}
buf
.
seek
(
0
)
buf
.
seek
(
0
)
logging_output
=
buf
.
read
()
logging_output
=
buf
.
read
()
...
@@ -370,16 +399,18 @@ def _check_compare(runner):
...
@@ -370,16 +399,18 @@ def _check_compare(runner):
[
[
"
-vv
"
,
"
-vv
"
,
# label - path to metrics
# label - path to metrics
"
test
"
,
os
.
path
.
join
(
output_folder
,
"
metrics.csv
"
),
"
test
"
,
"
test (2nd. human)
"
,
os
.
path
.
join
(
second_folder
,
"
metrics.csv
"
),
os
.
path
.
join
(
output_folder
,
"
metrics.csv
"
),
"
test (2nd. human)
"
,
os
.
path
.
join
(
second_folder
,
"
metrics.csv
"
),
],
],
)
)
_assert_exit_0
(
result
)
_assert_exit_0
(
result
)
assert
os
.
path
.
exists
(
"
comparison.pdf
"
)
assert
os
.
path
.
exists
(
"
comparison.pdf
"
)
keywords
=
{
# from different logging systems
keywords
=
{
"
Loading metrics from
"
:
2
,
# logging
r
"
^
Loading metrics from
"
:
2
,
}
}
buf
.
seek
(
0
)
buf
.
seek
(
0
)
logging_output
=
buf
.
read
()
logging_output
=
buf
.
read
()
...
...
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