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

Can read accessor from file with name in path itself

parent d166583b
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,7 @@ def get_accessor(accessor_id: str): ...@@ -78,7 +78,7 @@ def get_accessor(accessor_id: str):
def delete_accessor(accessor_id: str): def delete_accessor(accessor_id: str):
return _session_accessor(session.del_accessor, accessor_id) return _session_accessor(session.del_accessor, accessor_id)
@app.put('/accessors/read_from_file') @app.put('/accessors/read_from_file/{filename}')
def read_accessor_from_file(filename: str, accessor_id: Union[str, None] = None): def read_accessor_from_file(filename: str, accessor_id: Union[str, None] = None):
fp = session.paths['inbound_images'] / filename fp = session.paths['inbound_images'] / filename
if not fp.exists(): if not fp.exists():
......
...@@ -11,6 +11,7 @@ from model_server.base.session import session ...@@ -11,6 +11,7 @@ from model_server.base.session import session
from tests.base.test_model import DummyInstanceSegmentationModel, DummySemanticSegmentationModel from tests.base.test_model import DummyInstanceSegmentationModel, DummySemanticSegmentationModel
czifile = conf.meta['image_files']['czifile'] czifile = conf.meta['image_files']['czifile']
cfn = czifile['name']
""" """
Configure additional endpoints for testing Configure additional endpoints for testing
...@@ -64,7 +65,7 @@ class TestServerTestCase(conf.TestServerBaseClass): ...@@ -64,7 +65,7 @@ class TestServerTestCase(conf.TestServerBaseClass):
resp = self._get('paths') resp = self._get('paths')
pa = resp.json()['inbound_images'] pa = resp.json()['inbound_images']
outpath = Path(pa) / czifile['name'] outpath = Path(pa) / cfn
copyfile( copyfile(
czifile['path'], czifile['path'],
outpath outpath
...@@ -129,12 +130,7 @@ class TestApiFromAutomatedClient(TestServerTestCase): ...@@ -129,12 +130,7 @@ class TestApiFromAutomatedClient(TestServerTestCase):
def test_pipeline_errors_when_ids_not_found(self): def test_pipeline_errors_when_ids_not_found(self):
self.copy_input_file_to_server() self.copy_input_file_to_server()
model_id = self._put(f'testing/models/dummy_semantic/load').json()['model_id'] model_id = self._put(f'testing/models/dummy_semantic/load').json()['model_id']
in_acc_id = self._put( in_acc_id = self._put(f'accessors/read_from_file/{cfn}').json()
f'accessors/read_from_file',
query={
'filename': czifile['name'],
},
).json()
# respond with 409 for invalid accessor_id # respond with 409 for invalid accessor_id
self.assertEqual( self.assertEqual(
...@@ -158,12 +154,7 @@ class TestApiFromAutomatedClient(TestServerTestCase): ...@@ -158,12 +154,7 @@ class TestApiFromAutomatedClient(TestServerTestCase):
def test_i2i_dummy_inference_by_api(self): def test_i2i_dummy_inference_by_api(self):
self.copy_input_file_to_server() self.copy_input_file_to_server()
model_id = self._put(f'testing/models/dummy_semantic/load').json()['model_id'] model_id = self._put(f'testing/models/dummy_semantic/load').json()['model_id']
in_acc_id = self._put( in_acc_id = self._put(f'accessors/read_from_file/{cfn}').json()
f'accessors/read_from_file',
query={
'filename': czifile['name'],
},
).json()
# run segmentation pipeline on preloaded accessor # run segmentation pipeline on preloaded accessor
resp_infer = self._put( resp_infer = self._put(
...@@ -246,10 +237,7 @@ class TestApiFromAutomatedClient(TestServerTestCase): ...@@ -246,10 +237,7 @@ class TestApiFromAutomatedClient(TestServerTestCase):
# add accessor to session # add accessor to session
resp_add_acc = self._put( resp_add_acc = self._put(
f'accessors/read_from_file', f'accessors/read_from_file/{cfn}',
query={
'filename': czifile['name'],
},
) )
acc_id = resp_add_acc.json() acc_id = resp_add_acc.json()
self.assertTrue(acc_id.startswith('auto_')) self.assertTrue(acc_id.startswith('auto_'))
......
...@@ -15,6 +15,7 @@ data = conf.meta['image_files'] ...@@ -15,6 +15,7 @@ data = conf.meta['image_files']
output_path = conf.meta['output_path'] output_path = conf.meta['output_path']
params = conf.meta['roiset'] params = conf.meta['roiset']
czifile = conf.meta['image_files']['czifile'] czifile = conf.meta['image_files']['czifile']
cfn = czifile['name']
ilastik_classifiers = conf.meta['ilastik_classifiers'] ilastik_classifiers = conf.meta['ilastik_classifiers']
def _random_int(*args): def _random_int(*args):
...@@ -305,12 +306,7 @@ class TestIlastikOverApi(conf.TestServerBaseClass): ...@@ -305,12 +306,7 @@ class TestIlastikOverApi(conf.TestServerBaseClass):
def test_ilastik_infer_pixel_probability(self): def test_ilastik_infer_pixel_probability(self):
self._copy_input_file_to_server() self._copy_input_file_to_server()
model_id = self.test_load_ilastik_pixel_model() model_id = self.test_load_ilastik_pixel_model()
in_acc_id = self._put( in_acc_id = self._put(f'accessors/read_from_file/{cfn}').json()
f'accessors/read_from_file',
query={
'filename': czifile['name'],
},
).json()
resp_infer = self._put( resp_infer = self._put(
f'pipelines/segment', f'pipelines/segment',
...@@ -324,12 +320,7 @@ class TestIlastikOverApi(conf.TestServerBaseClass): ...@@ -324,12 +320,7 @@ class TestIlastikOverApi(conf.TestServerBaseClass):
px_model_id = self.test_load_ilastik_pixel_model() px_model_id = self.test_load_ilastik_pixel_model()
ob_model_id = self.test_load_ilastik_pxmap_to_obj_model() ob_model_id = self.test_load_ilastik_pxmap_to_obj_model()
in_acc_id = self._put( in_acc_id = self._put(f'accessors/read_from_file/{cfn}').json()
f'accessors/read_from_file',
query={
'filename': czifile['name'],
},
).json()
resp_infer = self._put( resp_infer = self._put(
'ilastik/pipelines/pixel_then_object_classification/infer/', 'ilastik/pipelines/pixel_then_object_classification/infer/',
...@@ -410,12 +401,7 @@ class TestIlastikOnMultichannelInputs(conf.TestServerBaseClass): ...@@ -410,12 +401,7 @@ class TestIlastikOnMultichannelInputs(conf.TestServerBaseClass):
Path(self._get('paths').json()['inbound_images']) / self.pa_input_image.name Path(self._get('paths').json()['inbound_images']) / self.pa_input_image.name
) )
in_acc_id = self._put( in_acc_id = self._put(f'accessors/read_from_file/{self.pa_input_image.name}').json()
f'accessors/read_from_file',
query={
'filename': self.pa_input_image.name
},
).json()
resp_load_px = self._put( resp_load_px = self._put(
'ilastik/seg/load/', 'ilastik/seg/load/',
......
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