OpenFn / apollo

GNU Lesser General Public License v2.1
0 stars 2 forks source link

Use Child process #61

Closed josephjclark closed 6 months ago

josephjclark commented 6 months ago

This branch uses a node child process to manage python services.

It builds on the websocket stuff: so you can either call a service via POST (in which case you'll get the result but not the logs) or via Websocket (CLI) - in which case you get logs and the result.

The server always logs all statements to stdout and to std error (error reporting is pretty good I think). But if a websocket is connected then print statements do not get sent through - so print can be reserved for server logging stuff.

I may later decide to ignore debug logs, so that we can still use logger.debug on the server. Or I'll add a special logger or something.

This ensures that every python file runs in isolation. Over the last week I've come to realise that this is super important - I really, really don't want python devs to worry about whether credentials, state, clients or loggers leak between runs. The only way to ensure this is to run pure environment each time, which basically means spawning a python child process directly.

This approach is right "on the metal", calling out to poetry run directly to execute our python scripts.

The result of the job is written to a file from python, and read back in from bun to be sent back. The file is deleted upon completion.

Closes #55 #51

Issues

Some of these are aesthetic, but still: