mercredi 16 janvier 2019

Run different python software versions and avoid saving data to disk

I have a web service which allows user to run certain software written in python3 on the server. The software delivers its own python3 environment and there are multiple versions available.

The user request includes the version and input data, and the reply is basically the output data from APIs in the software. Both the input and output formats are fixed but the result could differ between versions.

What I do now is to have the server (also written in python3) import the latest version of the software library. The library is needed to parse the input and output data. Then if the request is of the same version, run the corresponding function directly in memory and return result. This is quite efficient.

However, if it's of a different version, I wrote a command line tool (with argparse) which is a thin wrapper over the API, using the correct version of the software. The command line saves the output to disk. The server calls the command line using subprocess module, reads the output from disk, and sends back to user.

Is it possible to make the overall design better? For example, in the case of different requested version, is it possible to avoid saving the result to disk?

Aucun commentaire:

Enregistrer un commentaire