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
ac54d6e0
Commit
ac54d6e0
authored
5 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Trying to access RoiSet products over API, hitting an error in parsing params or something
parent
e2624a9a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model_server/base/api.py
+13
-2
13 additions, 2 deletions
model_server/base/api.py
model_server/base/session.py
+1
-1
1 addition, 1 deletion
model_server/base/session.py
tests/test_ilastik/test_roiset_workflow.py
+22
-13
22 additions, 13 deletions
tests/test_ilastik/test_roiset_workflow.py
with
36 additions
and
16 deletions
model_server/base/api.py
+
13
−
2
View file @
ac54d6e0
from
collections
import
OrderedDict
from
pydantic
import
BaseModel
,
Field
from
typing
import
List
,
Union
from
fastapi
import
FastAPI
,
HTTPException
from
.accessors
import
generate_file_accessor
from
.models
import
BinaryThresholdSegmentationModel
from
.roiset
import
SerializeRoiSetError
from
.roiset
import
RoiSetExportParams
,
SerializeRoiSetError
from
.session
import
session
,
AccessorIdError
,
InvalidPathError
,
RoiSetIdError
,
WriteAccessorError
app
=
FastAPI
(
debug
=
True
)
...
...
@@ -166,4 +167,14 @@ def write_roiset_to_file(roiset_id: str, where: Union[str, None] = None) -> RoiS
except
RoiSetIdError
as
e
:
raise
HTTPException
(
404
,
f
'
Did not find RoiSet with ID
{
roiset_id
}
'
)
except
SerializeRoiSetError
as
e
:
raise
HTTPException
(
409
,
str
(
e
))
\ No newline at end of file
raise
HTTPException
(
409
,
str
(
e
))
@app.put
(
'
/rois/products/{roiset_id}
'
)
def
roiset_export_products
(
roiset_id
:
str
,
channel
:
Union
[
int
,
None
]
=
None
,
params
:
RoiSetExportParams
=
RoiSetExportParams
()
)
->
dict
:
roiset
=
_session_roiset
(
session
.
get_roiset
,
roiset_id
)
products
=
roiset
.
get_export_product_accessors
(
channel
,
params
)
return
[
session
.
add_accessor
(
v
,
f
'
{
roiset_id
}
_
{
k
}
'
)
for
k
,
v
in
products
.
items
()]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/base/session.py
+
1
−
1
View file @
ac54d6e0
...
...
@@ -238,7 +238,7 @@ class _Session(object):
raise
RoiSetIdError
(
f
'
No RoiSet with ID
{
roiset_id
}
is registered
'
)
return
self
.
list_rois
()[
roiset_id
]
def
get_roiset
(
self
,
roiset_id
:
str
,
pop
:
bool
=
Tru
e
)
->
RoiSet
:
def
get_roiset
(
self
,
roiset_id
:
str
,
pop
:
bool
=
Fals
e
)
->
RoiSet
:
"""
Return an RoiSet object
:param acc_id: RoiSet
'
s ID
...
...
This diff is collapsed.
Click to expand it.
tests/test_ilastik/test_roiset_workflow.py
+
22
−
13
View file @
ac54d6e0
...
...
@@ -171,23 +171,32 @@ class TestRoiSetWorkflowOverApi(conf.TestServerBaseClass, BaseTestRoiSetMonoProd
'
export_params
'
:
self
.
_get_export_params
(),
},
)
oid
=
res
[
'
output_accessor_id
'
]
roiset_id
=
res
[
'
roiset_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
())
# check and serialize RoiSet
# check on automatically written RoiSet
roiset_id
=
res
[
'
roiset_id
'
]
roiset_info
=
self
.
assertGetSuccess
(
f
'
/rois/
{
roiset_id
}
'
)
self
.
assertPutSuccess
(
f
'
/rois/write/
{
roiset_id
}
'
)
self
.
assertGreater
(
roiset_info
[
'
count
'
],
0
)
return
generate_file_accessor
(
obmap_fp
)
return
res
def
test_workflow_with_object_classifier
(
self
):
acc
=
self
.
_object_map_workflow
(
self
.
test_load_object_classifier
())
self
.
assertTrue
(
np
.
all
(
acc
.
unique
()[
0
]
==
[
0
,
1
,
2
]))
res
=
self
.
_object_map_workflow
(
self
.
test_load_object_classifier
())
acc_obmap
=
self
.
get_accessor
(
res
[
'
output_accessor_id
'
])
self
.
assertTrue
(
np
.
all
(
acc_obmap
.
unique
()[
0
]
==
[
0
,
1
,
2
]))
# get object map via RoiSet API
roiset_id
=
res
[
'
roiset_id
'
]
obmap_id
=
self
.
assertPutSuccess
(
f
'
/rois/products/
{
roiset_id
}
'
,
query
=
{
'
object_classes
'
})
acc_obmap_roiset
=
self
.
get_accessor
(
obmap_id
)
print
(
acc_obmap_roiset
)
# check serialize RoiSet
self
.
assertPutSuccess
(
f
'
/rois/write/
{
roiset_id
}
'
)
self
.
assertFalse
(
self
.
assertGetSuccess
(
f
'
/rois/
{
roiset_id
}
'
)[
'
loaded
'
]
)
def
test_workflow_without_object_classifier
(
self
):
acc
=
self
.
_object_map_workflow
(
None
)
self
.
assertTrue
(
np
.
all
(
acc
.
unique
()[
0
]
==
[
0
,
1
]))
res
=
self
.
_object_map_workflow
(
None
)
acc_obmap
=
self
.
get_accessor
(
res
[
'
output_accessor_id
'
])
self
.
assertTrue
(
np
.
all
(
acc_obmap
.
unique
()[
0
]
==
[
0
,
1
]))
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