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
2464806c
Commit
2464806c
authored
7 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Implemented and tested method to write intermediate pipeline products to file
parent
8bf70444
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
model_server/base/util.py
+45
-4
45 additions, 4 deletions
model_server/base/util.py
tests/base/test_pipelines.py
+7
-1
7 additions, 1 deletion
tests/base/test_pipelines.py
with
52 additions
and
5 deletions
model_server/base/util.py
+
45
−
4
View file @
2464806c
...
...
@@ -171,6 +171,12 @@ class PipelineTrace(OrderedDict):
tfunc
=
perf_counter
def
__init__
(
self
,
enforce_accessors
=
True
,
allow_overwrite
=
False
):
"""
A container and timer for data at each stage of a pipeline.
:param enforce_accessors: if True, only allow accessors to be appended as items
:param allow_overwrite: if True, allow an item to be overwritten
"""
self
.
enforce_accessors
=
enforce_accessors
self
.
allow_overwrite
=
allow_overwrite
self
.
last_time
=
self
.
tfunc
()
...
...
@@ -187,18 +193,53 @@ class PipelineTrace(OrderedDict):
self
.
last_time
=
self
.
tfunc
()
return
super
().
__setitem__
(
key
,
value
)
@property
def
accessors
(
self
):
return
self
.
items
()
@property
def
times
(
self
):
"""
Return an ordered dictionary of incremental times for each item that is appended
"""
return
{
k
:
self
.
timer
[
k
]
for
k
in
self
.
keys
()}
@property
def
last
(
self
):
"""
Return most recently appended item
:return:
"""
return
list
(
self
.
values
())[
-
1
]
def
write_interm
(
self
,
where
:
Path
,
prefix
:
str
=
'
interm
'
,
skip_first
=
True
,
skip_last
=
True
,
debug
=
False
)
->
List
[
Path
]:
"""
Write accessor data to TIF files under specified path
:param where: directory in which to write image files
:param prefix: (optional) file prefix
:param skip_first: if True, do not write first item in trace
:param skip_last: if False, do not write last item in trace
:param debug: if True, report destination filepaths but do not write files
:return: list of destination filepaths
"""
paths
=
[]
for
i
,
item
in
enumerate
(
self
.
items
()):
k
,
v
=
item
if
not
isinstance
(
v
,
GenericImageDataAccessor
):
continue
if
skip_first
and
k
==
list
(
self
.
keys
())[
0
]:
continue
if
skip_last
and
k
==
list
(
self
.
keys
())[
-
1
]:
continue
fp
=
where
/
f
'
{
prefix
}
_
{
i
:
02
d
}
_
{
k
}
.tif
'
paths
.
append
(
fp
)
if
not
debug
:
v
.
write
(
fp
)
return
paths
class
Error
(
Exception
):
pass
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_pipelines.py
+
7
−
1
View file @
2464806c
...
...
@@ -39,4 +39,10 @@ class TestGetSessionObject(unittest.TestCase):
img
[
0
,
0
],
0
,
'
First pixel is not black as expected
'
)
\ No newline at end of file
)
interm_fps
=
trace
.
write_interm
(
output_path
/
'
pipelines
'
/
'
segment_interm
'
,
prefix
=
czifile
[
'
name
'
]
)
self
.
assertTrue
([
ofp
.
stem
.
split
(
'
_
'
)[
-
1
]
for
ofp
in
interm_fps
]
==
[
'
mono
'
,
'
inference
'
,
'
smooth
'
])
\ 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