Techniques to run MONAI Deploy App in batch mode or in a long running service #333
Replies: 2 comments 1 reply
-
@aihsani @nakfour @CPBridge This will be useful for some of your use cases. |
Beta Was this translation helpful? Give feedback.
-
The idea we discussed today was to change the entry point for MAP images to be a new Python based program which can run in a command line mode but also as a server using Ray or FastAPI to serve access to the model in a lightweight manner. This would be optional and something that wouldn't interfere with the current mode of using MAPs in other environments eg. Argo. Generating code to make use of Ray/FastAPI/BentoML would be relatively straight forward in addition to the existing main program. |
Beta Was this translation helpful? Give feedback.
-
Questions have been asked
Well, we deliberately leave the run mode decision to the users/app developers, taking advantage of the already supported features of the App SDK
Application
.The
Application
executor
internally maintains a execution index, and each call torun()
will be assigned a new index, making it re-runnable so long as the code calling theApplication.run()
keeps the app object alive.In the following simplest example, I am showing a quick change to the
__main__
function of the Spleen app to process payloads contained in subfolders in the input path, with each run of the app processing one and only one subfolder's content as the discrete payload (though may be multiple DICOM instances). The same app object with PyTorch model network is kept in memory and reused. The output for each run is saved in its own folder under the app output_path.One can also create a service and run the
Application
to process continuous input: make the__main__
function a main loop, with a file monitor, queue listener, interrupt handler, or other means, on-trigger move the input to the app's input folder, call theapp.run()
and then handle/move the output.Note that "multi-threading" to run app has not been tested and is not advised for the time being. This will be tested to ensure no contention or undesirable side effect regarding the
input_path
in the app object. So, please serialize the call torun()
.Beta Was this translation helpful? Give feedback.
All reactions