Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
ALMF
SVLT
Commits
ef31604c
Commit
ef31604c
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
ilastik and pipeline tests now all use TestServer request assertions
parent
c7485174
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_ilastik/test_ilastik.py
+43
-65
43 additions, 65 deletions
tests/test_ilastik/test_ilastik.py
tests/test_ilastik/test_roiset_workflow.py
+14
-19
14 additions, 19 deletions
tests/test_ilastik/test_roiset_workflow.py
with
57 additions
and
84 deletions
tests/test_ilastik/test_ilastik.py
+
43
−
65
View file @
ef31604c
...
...
@@ -209,11 +209,11 @@ class TestServerTestCase(conf.TestServerBaseClass):
class
TestIlastikOverApi
(
TestServerTestCase
):
def
test_httpexception_if_incorrect_project_file_loaded
(
self
):
resp_load
=
self
.
assertPut
Success
(
self
.
assertPut
Failure
(
'
ilastik/seg/load/
'
,
500
,
body
=
{
'
project_file
'
:
'
improper.ilp
'
},
)
self
.
assertEqual
(
resp_load
.
status_code
,
500
)
def
test_load_ilastik_pixel_model
(
self
):
...
...
@@ -226,21 +226,18 @@ class TestIlastikOverApi(TestServerTestCase):
return
mid
def
test_load_another_ilastik_pixel_model
(
self
):
model_id
=
self
.
test_load_ilastik_pixel_model
()
resp_list_1st
=
self
.
assertGetSuccess
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_1st
),
1
,
resp_list_1st
)
resp_load_2nd
=
self
.
assertPutSuccess
(
self
.
test_load_ilastik_pixel_model
()
self
.
assertEqual
(
len
(
self
.
assertGetSuccess
(
'
models
'
)),
1
)
self
.
assertPutSuccess
(
'
ilastik/seg/load/
'
,
body
=
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
px
'
][
'
path
'
]),
'
duplicate
'
:
True
},
)
resp_list_2nd
=
self
.
assertGetSuccess
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_2nd
),
2
,
resp_list_2nd
)
resp_load_3rd
=
self
.
assertPutSuccess
(
self
.
assertEqual
(
len
(
self
.
assertGetSuccess
(
'
models
'
)),
2
)
self
.
assertPutSuccess
(
'
ilastik/seg/load/
'
,
body
=
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
px
'
][
'
path
'
]),
'
duplicate
'
:
False
},
)
resp_list_3rd
=
self
.
assertGetSuccess
(
'
models
'
).
json
()
self
.
assertEqual
(
len
(
resp_list_3rd
),
2
,
resp_list_3rd
)
self
.
assertEqual
(
len
(
self
.
assertGetSuccess
(
'
models
'
)),
2
)
def
test_load_ilastik_pixel_model_with_params
(
self
):
params
=
{
...
...
@@ -248,67 +245,55 @@ class TestIlastikOverApi(TestServerTestCase):
'
px_class
'
:
0
,
'
px_prob_threshold
'
:
0.5
}
resp_loa
d
=
self
.
assertPutSuccess
(
mi
d
=
self
.
assertPutSuccess
(
'
ilastik/seg/load/
'
,
body
=
params
,
)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
model_id
=
resp_load
.
json
()[
'
model_id
'
]
mods
=
self
.
assertGetSuccess
(
'
models
'
).
json
()
)[
'
model_id
'
]
mods
=
self
.
assertGetSuccess
(
'
models
'
)
self
.
assertEqual
(
len
(
mods
),
1
)
self
.
assertEqual
(
mods
[
m
odel_
id
][
'
params
'
][
'
px_prob_threshold
'
],
0.5
)
self
.
assertEqual
(
mods
[
mid
][
'
params
'
][
'
px_prob_threshold
'
],
0.5
)
def
test_load_ilastik_pxmap_to_obj_model
(
self
):
resp_loa
d
=
self
.
assertPutSuccess
(
mi
d
=
self
.
assertPutSuccess
(
'
ilastik/pxmap_to_obj/load/
'
,
body
=
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
pxmap_to_obj
'
][
'
path
'
])},
)
model_id
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list
=
self
.
assertGetSuccess
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
IlastikObjectClassifierFromPixelPredictionsModel
'
)
return
model_id
)[
'
model_id
'
]
rl
=
self
.
assertGetSuccess
(
'
models
'
)
self
.
assertEqual
(
rl
[
mid
][
'
class
'
],
'
IlastikObjectClassifierFromPixelPredictionsModel
'
)
return
mid
def
test_load_ilastik_model_with_model_id
(
self
):
mid
=
'
new_model_id
'
r
esp_loa
d
=
self
.
assertPutSuccess
(
n
mid
=
'
new_model_id
'
r
mi
d
=
self
.
assertPutSuccess
(
'
ilastik/pxmap_to_obj/load/
'
,
query
=
{
'
model_id
'
:
nmid
,
},
body
=
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
pxmap_to_obj
'
][
'
path
'
]),
'
model_id
'
:
mid
,
},
)
res_mid
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
res_mid
,
mid
)
)[
'
model_id
'
]
self
.
assertEqual
(
rmid
,
nmid
)
def
test_load_ilastik_seg_to_obj_model
(
self
):
resp_loa
d
=
self
.
assertPutSuccess
(
mi
d
=
self
.
assertPutSuccess
(
'
ilastik/seg_to_obj/load/
'
,
body
=
{
'
project_file
'
:
str
(
ilastik_classifiers
[
'
seg_to_obj
'
][
'
path
'
])},
)
model_id
=
resp_load
.
json
()[
'
model_id
'
]
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
resp_list
=
self
.
assertGetSuccess
(
'
models
'
)
self
.
assertEqual
(
resp_list
.
status_code
,
200
)
rj
=
resp_list
.
json
()
self
.
assertEqual
(
rj
[
model_id
][
'
class
'
],
'
IlastikObjectClassifierFromSegmentationModel
'
)
return
model_id
)[
'
model_id
'
]
rl
=
self
.
assertGetSuccess
(
'
models
'
)
self
.
assertEqual
(
rl
[
mid
][
'
class
'
],
'
IlastikObjectClassifierFromSegmentationModel
'
)
return
mid
def
test_ilastik_infer_pixel_probability
(
self
):
fname
=
self
.
copy_input_file_to_server
()
m
odel_
id
=
self
.
test_load_ilastik_pixel_model
()
in_
acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
.
json
()
mid
=
self
.
test_load_ilastik_pixel_model
()
acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
resp_infer
=
self
.
assertPutSuccess
(
self
.
assertPutSuccess
(
f
'
pipelines/segment
'
,
body
=
{
'
model_id
'
:
m
odel_
id
,
'
accessor_id
'
:
in_
acc_id
,
'
channel
'
:
0
},
body
=
{
'
model_id
'
:
mid
,
'
accessor_id
'
:
acc_id
,
'
channel
'
:
0
},
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
def
test_ilastik_infer_px_then_ob
(
self
):
...
...
@@ -316,9 +301,9 @@ class TestIlastikOverApi(TestServerTestCase):
px_model_id
=
self
.
test_load_ilastik_pixel_model
()
ob_model_id
=
self
.
test_load_ilastik_pxmap_to_obj_model
()
in_acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
.
json
()
in_acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
resp_infer
=
self
.
assertPutSuccess
(
self
.
assertPutSuccess
(
'
ilastik/pipelines/pixel_then_object_classification/infer/
'
,
body
=
{
'
px_model_id
'
:
px_model_id
,
...
...
@@ -327,7 +312,6 @@ class TestIlastikOverApi(TestServerTestCase):
'
channel
'
:
0
,
}
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
class
TestIlastikOnMultichannelInputs
(
TestServerTestCase
):
...
...
@@ -394,38 +378,32 @@ class TestIlastikOnMultichannelInputs(TestServerTestCase):
"""
copyfile
(
self
.
pa_input_image
,
Path
(
self
.
assertGetSuccess
(
'
paths
'
)
.
json
()
[
'
inbound_images
'
])
/
self
.
pa_input_image
.
name
Path
(
self
.
assertGetSuccess
(
'
paths
'
)[
'
inbound_images
'
])
/
self
.
pa_input_image
.
name
)
in_acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
self
.
pa_input_image
.
name
}
'
)
.
json
()
in_acc_id
=
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
self
.
pa_input_image
.
name
}
'
)
resp_load_px
=
self
.
assertPutSuccess
(
px_model_id
=
self
.
assertPutSuccess
(
'
ilastik/seg/load/
'
,
body
=
{
'
project_file
'
:
str
(
self
.
pa_px_classifier
)},
)
self
.
assertEqual
(
resp_load_px
.
status_code
,
200
,
resp_load_px
.
json
())
px_model_id
=
resp_load_px
.
json
()[
'
model_id
'
]
)[
'
model_id
'
]
resp_load_ob
=
self
.
assertPutSuccess
(
ob_model_id
=
self
.
assertPutSuccess
(
'
ilastik/pxmap_to_obj/load/
'
,
body
=
{
'
project_file
'
:
str
(
self
.
pa_ob_pxmap_classifier
)},
)
self
.
assertEqual
(
resp_load_ob
.
status_code
,
200
,
resp_load_ob
.
json
())
ob_model_id
=
resp_load_ob
.
json
()[
'
model_id
'
]
)[
'
model_id
'
]
# run the pipeline
resp_infer
=
self
.
assertPutSuccess
(
obmap_id
=
self
.
assertPutSuccess
(
'
ilastik/pipelines/pixel_then_object_classification/infer/
'
,
body
=
{
'
accessor_id
'
:
in_acc_id
,
'
px_model_id
'
:
px_model_id
,
'
ob_model_id
'
:
ob_model_id
,
}
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
)[
'
output_accessor_id
'
]
# save output object map to file and compare
obmap_id
=
resp_infer
.
json
()[
'
output_accessor_id
'
]
obmap_acc
=
self
.
get_accessor
(
obmap_id
)
self
.
assertEqual
(
obmap_acc
.
shape_dict
[
'
C
'
],
1
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_ilastik/test_roiset_workflow.py
+
14
−
19
View file @
ef31604c
...
...
@@ -136,33 +136,30 @@ class TestRoiSetWorkflowOverApi(conf.TestServerBaseClass, BaseTestRoiSetMonoProd
return
conf
.
TestServerBaseClass
.
setUp
(
self
)
def
test_trivial_api_response
(
self
):
resp
=
self
.
assertGetSuccess
(
''
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertGetSuccess
(
''
)
def
test_load_input_accessor
(
self
):
fname
=
self
.
copy_input_file_to_server
()
return
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
.
json
()
return
self
.
assertPutSuccess
(
f
'
accessors/read_from_file/
{
fname
}
'
)
def
test_load_pixel_classifier
(
self
):
resp
=
self
.
assertPutSuccess
(
mid
=
self
.
assertPutSuccess
(
'
ilastik/seg/load/
'
,
body
=
{
'
project_file
'
:
self
.
_get_models
()[
'
pixel_classifier_segmentation
'
][
'
project_file
'
]},
)
model_id
=
resp
.
json
()[
'
model_id
'
]
self
.
assertTrue
(
model_id
.
startswith
(
'
IlastikPixelClassifierModel
'
))
return
model_id
)[
'
model_id
'
]
self
.
assertTrue
(
mid
.
startswith
(
'
IlastikPixelClassifierModel
'
))
return
mid
def
test_load_object_classifier
(
self
):
resp
=
self
.
assertPutSuccess
(
mid
=
self
.
assertPutSuccess
(
'
ilastik/seg_to_obj/load/
'
,
body
=
{
'
project_file
'
:
self
.
_get_models
()[
'
object_classifier
'
][
'
project_file
'
]},
)
model_id
=
resp
.
json
()[
'
model_id
'
]
self
.
assertTrue
(
model_id
.
startswith
(
'
IlastikObjectClassifierFromSegmentationModel
'
))
return
model_id
)[
'
model_id
'
]
self
.
assertTrue
(
mid
.
startswith
(
'
IlastikObjectClassifierFromSegmentationModel
'
))
return
mid
def
_object_map_workflow
(
self
,
ob_classifer_id
):
resp
=
self
.
assertPutSuccess
(
oid
=
self
.
assertPutSuccess
(
'
pipelines/roiset_to_obmap/infer
'
,
body
=
{
'
accessor_id
'
:
self
.
test_load_input_accessor
(),
...
...
@@ -173,11 +170,9 @@ class TestRoiSetWorkflowOverApi(conf.TestServerBaseClass, BaseTestRoiSetMonoProd
'
roi_params
'
:
self
.
_get_roi_params
(),
'
export_params
'
:
self
.
_get_export_params
(),
},
)
self
.
assertEqual
(
resp
.
status_code
,
200
,
resp
.
json
())
oid
=
resp
.
json
()[
'
output_accessor_id
'
]
obmap_fn
=
self
.
assertPutSuccess
(
f
'
/accessors/write_to_file/
{
oid
}
'
).
json
()
where_out
=
self
.
assertGetSuccess
(
'
paths
'
).
json
()[
'
outbound_images
'
]
)[
'
output_accessor_id
'
]
obmap_fn
=
self
.
assertPutSuccess
(
f
'
/accessors/write_to_file/
{
oid
}
'
)
where_out
=
self
.
assertGetSuccess
(
'
paths
'
)[
'
outbound_images
'
]
obmap_fp
=
Path
(
where_out
)
/
obmap_fn
self
.
assertTrue
(
obmap_fp
.
exists
())
return
generate_file_accessor
(
obmap_fp
)
...
...
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