How to expose multiprocessing python application to support invocation from command line and web

  softwareengineering

I have a python forecasting application that, for a given Entity, executes a fbprophet model multiple times varying the hyperparameters for each execution while tracking the best fit across the runs. The models need to be run in parallel to minimize run time. The data associated with a given Entity is small (~1mb). The application will run on a 32 CPU box.

The application needs to support a batch mode to process data from another process (~ 1000 Entities in a batch). The batch mode can be invoked from the command line.

It also needs to support an on-demand mode that will process a single Entity. The data for this Entity will be provided from a web front end.

I was thinking I could host in Django but not sure if it will scale the model executions out across all the processors.

Another option I am considering is a web front end that spins up the python script in a separate process.

Looking for advise on how to architect the solution to support invoking from a web interface and command line.

The easiest way is probably to build some sort of web service that allows clients to submit jobs to it, which it fulfills using available compute resources as possible. The client could then query for the result or possibly provide a callback URL to be notified when the work is done. Then all that needs to be done is to write command line and web integrations with the new web service API.

LEAVE A COMMENT