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

Unfinished changes to automic simulator and testing 3D ilastik model

parent d09bdffb
No related branches found
No related tags found
No related merge requests found
from typing import Dict
from fastapi import FastAPI, HTTPException
from model_server.ilastik import IlastikPixelClassifierModel, IlastikObjectClassifierModel
......
......@@ -17,7 +17,7 @@ input_filename = os.path.split(abspath)[-1]
outpath = 'C:\\Users\\rhodes\\projects\\proj0015-model-server\\resources\\testdata'
def hit_endpoint(method, endpoint, params=None, verbose=False):
def hit_endpoint(method, endpoint, params=None, verbose=True):
connection = httplib.HTTPConnection(host, port)
if not method in ['GET', 'PUT']:
raise Exception('Can only handle GET and PUT requests')
......@@ -32,9 +32,7 @@ def hit_endpoint(method, endpoint, params=None, verbose=False):
print(method + ' ' + url + ', status ' + str(resp.status) + ':\n' + resp_str)
return json.loads(resp_str)
#hit_endpoint('GET', '/')
#hit_endpoint('GET', '/models')
#hit_endpoint('PUT', '/bounce_back', {'par1': 'ghij'})
hit_endpoint('GET', '/restart')
resp = hit_endpoint('PUT', '/models/ilastik/pixel_classification/load/', {'project_file': 'demo_px.ilp'})
pxmid = resp['model_id']
resp = hit_endpoint('GET', '/models', verbose=True)
......@@ -45,4 +43,14 @@ infer_params = {
'channel': 0
}
hit_endpoint('PUT', '/infer/from_image_file', infer_params)
\ No newline at end of file
hit_endpoint('PUT', '/infer/from_image_file', infer_params)
import time
dt_arr = []
for i in range(0, 10):
t0 = time()
time.sleep(0.1)
dt_arr.append(time() - t0)
print(dt_arr)
print('mean [s]': sum(dt_arr)/len(dt_arr))
from multiprocessing import Process
import os
import requests
import unittest
import uvicorn
import conf.server
# run server in subprocess
host = '127.0.0.1'
port = 5000
server_process = Process(
target=uvicorn.run,
args=('api:app', ),
kwargs={'host': host, 'port': port, 'log_level': 'debug'},
daemon=True
)
uri = f'http://{host}:{port}/'
server_process.start()
# configure and validate folders etc.
paths = conf.server.paths
paths['automic_watch_folder'] = paths['images']['inbound']
paths['test_source_files'] = ''
# load models by API
# prompt user start AutoMic loop
# move files from one folder to another
def copy_one_input_image_files(copy=True):
pattern = ''
os.listdir(paths['test_source_files'])
# order by increaseing alpha order? timestamp?
if copy:
# copy image from test source files to automic watch folder
else:
# move them
# recursive repeat until nothign is left
# point to server session logs
# shut down server
server_process.terminate()
# do something with the data?
......@@ -152,3 +152,21 @@ class TestIlastikOverApi(TestServerBaseClass):
},
)
self.assertEqual(resp_infer.status_code, 200, resp_infer.content.decode())
def test_load_ilastik_pixel_model_in_subdirectory(self):
px_ilp = 'proj0011-exp0004/px3d.ilp'
pf = px_ilp
resp_load = requests.put(
self.uri + 'models/ilastik/pixel_classification/load/',
params={'project_file': pf},
)
model_id = resp_load.json()['model_id']
self.assertEqual(resp_load.status_code, 200, resp_load.json())
resp_list = requests.get(self.uri + 'models')
self.assertEqual(resp_list.status_code, 200)
rj = resp_list.json()
self.assertEqual(rj[model_id]['class'], 'IlastikPixelClassifierModel')
return model_id
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