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
18449743
Commit
18449743
authored
7 months ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Added option to remove all accessors
parent
3fa8292a
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
+5
-4
5 additions, 4 deletions
model_server/base/api.py
model_server/base/session.py
+14
-0
14 additions, 0 deletions
model_server/base/session.py
tests/base/test_api.py
+7
-0
7 additions, 0 deletions
tests/base/test_api.py
with
26 additions
and
4 deletions
model_server/base/api.py
+
5
−
4
View file @
18449743
...
...
@@ -87,7 +87,10 @@ def get_accessor(accessor_id: str):
@app.get
(
'
/accessors/delete/{accessor_id}
'
)
def
delete_accessor
(
accessor_id
:
str
):
return
_session_accessor
(
session
.
del_accessor
,
accessor_id
)
if
accessor_id
==
'
*
'
:
return
session
.
del_all_accessors
()
else
:
return
_session_accessor
(
session
.
del_accessor
,
accessor_id
)
@app.put
(
'
/accessors/read_from_file/{filename}
'
)
...
...
@@ -106,6 +109,4 @@ def write_accessor_to_file(accessor_id: str, filename: Union[str, None] = None)
except
AccessorIdError
as
e
:
raise
HTTPException
(
404
,
f
'
Did not find accessor with ID
{
accessor_id
}
'
)
except
WriteAccessorError
as
e
:
raise
HTTPException
(
409
,
str
(
e
))
# TODO: endpoint to unload all accessors
\ No newline at end of file
raise
HTTPException
(
409
,
str
(
e
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
model_server/base/session.py
+
14
−
0
View file @
18449743
...
...
@@ -114,6 +114,20 @@ class _Session(object):
v
[
'
object
'
]
=
None
return
accessor_id
def
del_all_accessors
(
self
)
->
list
[
str
]:
"""
Remove (unload) all accessors but keep their info in dictionary
:return: list of removed accessor IDs
"""
res
=
[]
for
k
,
v
in
self
.
accessors
.
items
():
if
v
[
'
loaded
'
]:
v
[
'
object
'
]
=
None
v
[
'
loaded
'
]
=
False
res
.
append
(
k
)
return
res
def
list_accessors
(
self
)
->
dict
:
"""
List information about all accessors in JSON-readable format
...
...
This diff is collapsed.
Click to expand it.
tests/base/test_api.py
+
7
−
0
View file @
18449743
...
...
@@ -240,6 +240,13 @@ class TestApiFromAutomatedClient(TestServerTestCase):
resp_wrong_acc
=
self
.
_get
(
'
accessors/auto_123456
'
)
self
.
assertEqual
(
resp_wrong_acc
.
status_code
,
404
)
# load another... then remove all
self
.
_put
(
f
'
accessors/read_from_file/
{
fname
}
'
)
self
.
assertEqual
(
sum
([
v
[
'
loaded
'
]
for
v
in
self
.
_get
(
'
accessors
'
).
json
().
values
()]),
1
)
self
.
assertEqual
(
len
(
self
.
_get
(
f
'
accessors/delete/*
'
).
json
()),
1
)
self
.
assertEqual
(
sum
([
v
[
'
loaded
'
]
for
v
in
self
.
_get
(
'
accessors
'
).
json
().
values
()]),
0
)
def
test_empty_accessor_list
(
self
):
resp_list_acc
=
self
.
_get
(
f
'
accessors
'
,
...
...
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