Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
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
Christopher Randolph Rhodes
model_server
Commits
b66b851c
Commit
b66b851c
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Removed JSON manifest file, logged summaries to logging service instead
parent
339b737d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!16
Completed (de)serialization of RoiSet
,
!9
Session exposes a python log
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
model_server/base/api.py
+8
-3
8 additions, 3 deletions
model_server/base/api.py
model_server/base/session.py
+0
-18
0 additions, 18 deletions
model_server/base/session.py
with
8 additions
and
21 deletions
model_server/base/api.py
+
8
−
3
View file @
b66b851c
...
...
@@ -46,6 +46,7 @@ def change_path(key, path):
status_code
=
404
,
detail
=
e
.
__str__
(),
)
session
.
log_info
(
f
'
Change
{
key
}
path to
{
path
}
'
)
return
session
.
get_paths
()
@app.put
(
'
/paths/watch_input
'
)
...
...
@@ -67,11 +68,15 @@ def list_active_models():
@app.put
(
'
/models/dummy_semantic/load/
'
)
def
load_dummy_model
()
->
dict
:
return
{
'
model_id
'
:
session
.
load_model
(
DummySemanticSegmentationModel
)}
mid
=
session
.
load_model
(
DummySemanticSegmentationModel
)
session
.
log_info
(
f
'
Loaded model
{
mid
}
'
)
return
{
'
model_id
'
:
mid
}
@app.put
(
'
/models/dummy_instance/load/
'
)
def
load_dummy_model
()
->
dict
:
return
{
'
model_id
'
:
session
.
load_model
(
DummyInstanceSegmentationModel
)}
mid
=
session
.
load_model
(
DummyInstanceSegmentationModel
)
session
.
log_info
(
f
'
Loaded model
{
mid
}
'
)
return
{
'
model_id
'
:
mid
}
@app.put
(
'
/workflows/segment
'
)
def
infer_img
(
model_id
:
str
,
input_filename
:
str
,
channel
:
int
=
None
)
->
dict
:
...
...
@@ -83,5 +88,5 @@ def infer_img(model_id: str, input_filename: str, channel: int = None) -> dict:
session
.
paths
[
'
outbound_images
'
],
channel
=
channel
,
)
session
.
record_workflow_run
(
record
)
session
.
log_info
(
f
'
Completed segmentation of
{
input_filename
}
'
)
return
record
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/base/session.py
+
0
−
18
View file @
b66b851c
import
json
import
logging
import
os
...
...
@@ -8,14 +7,10 @@ from typing import Dict
import
model_server.conf.defaults
from
model_server.base.models
import
Model
from
model_server.base.workflows
import
WorkflowRunRecord
logger
=
logging
.
getLogger
(
__name__
)
def
create_manifest_json
():
pass
class
Singleton
(
type
):
_instances
=
{}
...
...
@@ -34,7 +29,6 @@ class Session(object, metaclass=Singleton):
def
__init__
(
self
,
root
:
str
=
None
):
print
(
'
Initializing session
'
)
self
.
models
=
{}
# model_id : model object
self
.
manifest
=
[]
# paths to data as well as other metadata from each inference run
self
.
paths
=
self
.
make_paths
(
root
)
self
.
logfile
=
self
.
paths
[
'
logs
'
]
/
f
'
session.log
'
...
...
@@ -42,9 +36,6 @@ class Session(object, metaclass=Singleton):
self
.
log_info
(
'
Initialized session
'
)
self
.
manifest_json
=
self
.
paths
[
'
logs
'
]
/
f
'
manifest.json
'
open
(
self
.
manifest_json
,
'
w
'
).
close
()
# instantiate empty json file
def
get_paths
(
self
):
return
self
.
paths
...
...
@@ -97,15 +88,6 @@ class Session(object, metaclass=Singleton):
def
log_error
(
self
,
msg
):
logger
.
error
(
msg
)
def
record_workflow_run
(
self
,
record
:
WorkflowRunRecord
or
None
):
"""
Append a JSON describing inference data to this session
'
s manifest
"""
self
.
log_info
(
f
'
Ran model
{
record
.
model_id
}
on
{
record
.
input_filepath
}
to infer
{
record
.
output_filepath
}
'
)
with
open
(
self
.
manifest_json
,
'
w+
'
)
as
fh
:
json
.
dump
(
record
.
dict
(),
fh
)
def
load_model
(
self
,
ModelClass
:
Model
,
params
:
Dict
[
str
,
str
]
=
None
)
->
dict
:
"""
Load an instance of a given model class and attach to this session
'
s model registry
...
...
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