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
b0b8499d
Commit
b0b8499d
authored
7 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Intermediate data can now be kept in session context
parent
fb7e1245
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
model_server/base/pipelines/params.py
+4
-0
4 additions, 0 deletions
model_server/base/pipelines/params.py
model_server/base/pipelines/util.py
+21
-1
21 additions, 1 deletion
model_server/base/pipelines/util.py
tests/base/test_api.py
+5
-0
5 additions, 0 deletions
tests/base/test_api.py
with
30 additions
and
1 deletion
model_server/base/pipelines/params.py
+
4
−
0
View file @
b0b8499d
from
typing
import
List
,
Union
from
fastapi
import
HTTPException
from
fastapi
import
HTTPException
from
pydantic
import
BaseModel
,
Field
,
validator
from
pydantic
import
BaseModel
,
Field
,
validator
...
@@ -7,6 +9,7 @@ from ..session import session, AccessorIdError
...
@@ -7,6 +9,7 @@ from ..session import session, AccessorIdError
class
SingleModelPipelineParams
(
BaseModel
):
class
SingleModelPipelineParams
(
BaseModel
):
accessor_id
:
str
=
Field
(
description
=
'
ID(s) of previously loaded accessor(s) to use as pipeline input
'
)
accessor_id
:
str
=
Field
(
description
=
'
ID(s) of previously loaded accessor(s) to use as pipeline input
'
)
model_id
:
str
=
Field
(
description
=
'
ID(s) of previously loaded segmentation model(s)
'
)
model_id
:
str
=
Field
(
description
=
'
ID(s) of previously loaded segmentation model(s)
'
)
keep_interm
:
bool
=
Field
(
False
,
description
=
'
Keep accessors to intermediate images in session
'
)
@validator
(
'
model_id
'
)
@validator
(
'
model_id
'
)
def
models_are_loaded
(
cls
,
model_id
):
def
models_are_loaded
(
cls
,
model_id
):
...
@@ -27,6 +30,7 @@ class SingleModelPipelineParams(BaseModel):
...
@@ -27,6 +30,7 @@ class SingleModelPipelineParams(BaseModel):
class
PipelineRecord
(
BaseModel
):
class
PipelineRecord
(
BaseModel
):
output_accessor_id
:
str
output_accessor_id
:
str
interm_accessor_ids
:
Union
[
List
[
str
],
None
]
model_id
:
str
model_id
:
str
success
:
bool
success
:
bool
timer
:
dict
timer
:
dict
This diff is collapsed.
Click to expand it.
model_server/base/pipelines/util.py
+
21
−
1
View file @
b0b8499d
...
@@ -13,8 +13,28 @@ def call_pipeline(func, p: SingleModelPipelineParams):
...
@@ -13,8 +13,28 @@ def call_pipeline(func, p: SingleModelPipelineParams):
session
.
log_info
(
f
'
Completed
{
func
.
__name__
}
on
{
p
.
accessor_id
}
.
'
)
session
.
log_info
(
f
'
Completed
{
func
.
__name__
}
on
{
p
.
accessor_id
}
.
'
)
if
p
.
keep_interm
:
interm_ids
=
[]
acc_interm
=
steps
.
accessors
(
skip_first
=
True
,
skip_last
=
True
).
items
()
for
i
,
item
in
enumerate
(
acc_interm
):
stk
,
acc
=
item
interm_ids
.
append
(
session
.
add_accessor
(
acc
,
accessor_id
=
f
'
{
p
.
accessor_id
}
_
{
func
.
__name__
}
_step
{
(
i
+
1
)
:
02
d
}
_
{
stk
}
'
)
)
else
:
interm_ids
=
None
result_id
=
session
.
add_accessor
(
steps
.
last
,
accessor_id
=
f
'
{
p
.
accessor_id
}
_
{
func
.
__name__
}
_result
'
)
return
PipelineRecord
(
return
PipelineRecord
(
output_accessor_id
=
session
.
add_accessor
(
steps
.
last
),
output_accessor_id
=
result_id
,
interm_accessor_ids
=
interm_ids
,
model_id
=
p
.
model_id
,
model_id
=
p
.
model_id
,
success
=
True
,
success
=
True
,
timer
=
steps
.
times
timer
=
steps
.
times
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_api.py
+
5
−
0
View file @
b0b8499d
...
@@ -151,6 +151,7 @@ class TestApiFromAutomatedClient(TestServerTestCase):
...
@@ -151,6 +151,7 @@ class TestApiFromAutomatedClient(TestServerTestCase):
'
accessor_id
'
:
in_acc_id
,
'
accessor_id
'
:
in_acc_id
,
'
model_id
'
:
model_id
,
'
model_id
'
:
model_id
,
'
channel
'
:
2
,
'
channel
'
:
2
,
'
keep_interm
'
:
True
,
},
},
)
)
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
self
.
assertEqual
(
resp_infer
.
status_code
,
200
,
resp_infer
.
content
.
decode
())
...
@@ -166,6 +167,10 @@ class TestApiFromAutomatedClient(TestServerTestCase):
...
@@ -166,6 +167,10 @@ class TestApiFromAutomatedClient(TestServerTestCase):
acc_out
=
generate_file_accessor
(
fp_out
)
acc_out
=
generate_file_accessor
(
fp_out
)
self
.
assertEqual
(
acc_out
.
shape_dict
[
'
C
'
],
1
)
self
.
assertEqual
(
acc_out
.
shape_dict
[
'
C
'
],
1
)
# validate intermediate data
resp_list
=
self
.
_get
(
f
'
accessors
'
).
json
()
self
.
assertEqual
(
len
([
k
for
k
in
resp_list
.
keys
()
if
'
_step
'
in
k
]),
2
)
def
test_restarting_session_clears_loaded_models
(
self
):
def
test_restarting_session_clears_loaded_models
(
self
):
resp_load
=
self
.
_put
(
f
'
testing/models/dummy_semantic/load
'
,)
resp_load
=
self
.
_put
(
f
'
testing/models/dummy_semantic/load
'
,)
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
self
.
assertEqual
(
resp_load
.
status_code
,
200
,
resp_load
.
json
())
...
...
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