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

Added more reporting of inference and model-loading events

parent cc0190dc
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,7 @@ def load_model(model_id: str, params: Dict[str, str] = None) -> dict: ...@@ -30,7 +30,7 @@ def load_model(model_id: str, params: Dict[str, str] = None) -> dict:
session.load_model(model_id, params=params) session.load_model(model_id, params=params)
return session.describe_loaded_models() return session.describe_loaded_models()
@app.put('/i2i/infer/') # image file in, image file out @app.put('/i2i/infer/')
def infer_img(model_id: str, input_filename: str, channel: int = None) -> dict: def infer_img(model_id: str, input_filename: str, channel: int = None) -> dict:
if model_id not in session.describe_loaded_models().keys(): if model_id not in session.describe_loaded_models().keys():
raise HTTPException( raise HTTPException(
...@@ -43,18 +43,11 @@ def infer_img(model_id: str, input_filename: str, channel: int = None) -> dict: ...@@ -43,18 +43,11 @@ def infer_img(model_id: str, input_filename: str, channel: int = None) -> dict:
status_code=404, status_code=404,
detail=f'Could not find file:\n{inpath}' detail=f'Could not find file:\n{inpath}'
) )
model = session.models[model_id]['object']
record = infer_image_to_image( record = infer_image_to_image(
inpath, inpath,
session.models[model_id]['object'], session.models[model_id]['object'],
session.outbound.path, session.outbound.path,
channel=channel, channel=channel,
# TODO: optional callback for status reporting
) )
session.record_workflow_run(record) session.record_workflow_run(record)
return record return record
\ No newline at end of file
# TODO: report out model inference status
@app.get('/i2i/status/{model_id}')
def status_model_inference(model_id: str) -> dict:
pass
\ No newline at end of file
...@@ -59,6 +59,7 @@ class Session(object): ...@@ -59,6 +59,7 @@ class Session(object):
""" """
Append a JSON describing inference data to this session's manifest Append a JSON describing inference data to this session's manifest
""" """
self.log_event(f'Ran model {record.model_id} on {record.input_filepath} to infer {record.output_filepath}')
with open(self.manifest_json, 'w+') as fh: with open(self.manifest_json, 'w+') as fh:
json.dump(record.dict(), fh) json.dump(record.dict(), fh)
...@@ -81,6 +82,7 @@ class Session(object): ...@@ -81,6 +82,7 @@ class Session(object):
'object': mi, 'object': mi,
'params': params, 'params': params,
} }
self.log_event(f'Loaded model {model_id}')
return True return True
raise CouldNotFindModelError( raise CouldNotFindModelError(
f'Could not find {model_id} in:\n{models}', f'Could not find {model_id} in:\n{models}',
......
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