Skip to content
Snippets Groups Projects
Commit ca1db14a authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Testing change of data directories over API

parent 214c4a1c
No related branches found
No related tags found
No related merge requests found
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)
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment