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
ca1db14a
Commit
ca1db14a
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Testing change of data directories over API
parent
214c4a1c
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/api.py
+20
-2
20 additions, 2 deletions
model_server/api.py
tests/test_api.py
+16
-1
16 additions, 1 deletion
tests/test_api.py
with
36 additions
and
3 deletions
model_server/api.py
+
20
−
2
View file @
ca1db14a
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
,
HTTPException
from
model_server.models
import
DummyImageToImageModel
from
model_server.session
import
Session
from
model_server.session
import
Session
,
InvalidPathError
from
model_server.validators
import
validate_workflow_inputs
from
model_server.workflows
import
infer_image_to_image
from
extensions.ilastik.workflows
import
infer_px_then_ob_model
...
...
@@ -28,6 +28,24 @@ def list_bounce_back(par1=None, par2=None):
def
list_session_paths
():
return
session
.
get_paths
()
def
change_path
(
key
,
path
):
try
:
session
.
set_data_directory
(
key
,
path
)
except
InvalidPathError
as
e
:
raise
HTTPException
(
status_code
=
404
,
detail
=
e
.
__str__
(),
)
return
session
.
get_paths
()
@app.put
(
'
/paths/watch_input
'
)
def
watch_input_path
(
path
:
str
):
return
change_path
(
'
inbound_images
'
,
path
)
@app.put
(
'
/paths/watch_output
'
)
def
watch_input_path
(
path
:
str
):
return
change_path
(
'
outbound_images
'
,
path
)
@app.get
(
'
/restart
'
)
def
restart_session
(
root
:
str
=
None
)
->
dict
:
session
.
restart
(
root
=
root
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_api.py
+
16
−
1
View file @
ca1db14a
...
...
@@ -121,4 +121,19 @@ class TestApiFromAutomatedClient(TestServerBaseClass):
resp_restart
=
requests
.
get
(
self
.
uri
+
'
restart
'
)
resp_list_1
=
requests
.
get
(
self
.
uri
+
'
models
'
)
rj1
=
resp_list_1
.
json
()
self
.
assertEqual
(
len
(
rj1
),
0
,
f
'
Unexpected models in response:
{
rj1
}
'
)
\ No newline at end of file
self
.
assertEqual
(
len
(
rj1
),
0
,
f
'
Unexpected models in response:
{
rj1
}
'
)
def
test_change_inbound_path
(
self
):
resp_inpath
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
resp_change
=
requests
.
put
(
self
.
uri
+
f
'
/paths/watch_output
'
,
params
=
{
'
path
'
:
resp_inpath
.
json
()[
'
inbound_images
'
]
}
)
resp_check
=
requests
.
get
(
self
.
uri
+
'
paths
'
)
self
.
assertEqual
(
resp_check
.
json
()[
'
inbound_images
'
],
resp_check
.
json
()[
'
outbound_images
'
])
\ 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