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
423afe65
Commit
423afe65
authored
4 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Can append stacks for tracking pipelines
parent
a851ef4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/pipelines/shared.py
+21
-0
21 additions, 0 deletions
model_server/base/pipelines/shared.py
tests/base/test_pipelines.py
+16
-0
16 additions, 0 deletions
tests/base/test_pipelines.py
with
37 additions
and
0 deletions
model_server/base/pipelines/shared.py
+
21
−
0
View file @
423afe65
...
...
@@ -140,6 +140,19 @@ class PipelineTrace(OrderedDict):
self
.
last_time
=
self
.
tfunc
()
return
super
().
__setitem__
(
key
,
value
)
def
append
(
self
,
tr
):
new_tr
=
self
.
copy
()
for
k
,
v
in
tr
.
items
():
dt
=
tr
.
timer
[
k
]
if
k
==
'
input
'
:
k
=
'
appended_input
'
if
not
self
.
allow_overwrite
and
k
in
self
.
keys
():
raise
KeyAlreadyExists
(
f
'
Trying to append trace with key
{
k
}
that already exists
'
)
new_tr
.
__setitem__
(
k
,
v
)
new_tr
.
timer
.
__setitem__
(
k
,
dt
)
new_tr
.
last_time
=
self
.
tfunc
()
return
new_tr
@property
def
times
(
self
):
"""
...
...
@@ -147,6 +160,14 @@ class PipelineTrace(OrderedDict):
"""
return
{
k
:
self
.
timer
[
k
]
for
k
in
self
.
keys
()}
@property
def
first
(
self
):
"""
Return first item
:return:
"""
return
list
(
self
.
values
())[
0
]
@property
def
last
(
self
):
"""
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_pipelines.py
+
16
−
0
View file @
423afe65
import
unittest
import
numpy
as
np
from
model_server.base.accessors
import
generate_file_accessor
,
write_accessor_data_to_file
from
model_server.base.pipelines
import
router
,
segment
,
segment_zproj
from
model_server.base.pipelines.shared
import
PipelineTrace
import
model_server.conf.testing
as
conf
from
model_server.conf.testing
import
DummySemanticSegmentationModel
...
...
@@ -64,3 +67,16 @@ class TestSegmentationPipelines(unittest.TestCase):
trace3
=
segment_zproj
.
segment_zproj_pipeline
({
''
:
acc
},
{
''
:
self
.
model
})
self
.
assertEqual
(
trace3
.
last
.
chroma
,
1
)
# still == 1: model returns a single channel regardless of input
self
.
assertEqual
(
trace3
.
last
.
nz
,
1
)
def
test_append_traces
(
self
):
acc
=
generate_file_accessor
(
zstack
[
'
path
'
])
trace1
=
PipelineTrace
(
acc
)
trace1
[
'
halve
'
]
=
trace1
.
last
.
apply
(
lambda
x
:
0.5
*
x
)
trace2
=
PipelineTrace
(
trace1
.
last
)
trace2
[
'
double
'
]
=
trace2
.
last
.
apply
(
lambda
x
:
2
*
x
)
trace3
=
trace1
.
append
(
trace2
)
self
.
assertEqual
(
len
(
trace3
),
len
(
trace1
)
+
len
(
trace2
))
self
.
assertEqual
(
trace3
[
'
halve
'
],
trace3
[
'
appended_input
'
])
self
.
assertTrue
(
np
.
all
(
trace3
[
'
input
'
].
data
==
trace3
[
'
double
'
].
data
))
\ No newline at end of file
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