Running python script in phoenix project on

Hi everyone! I’m building a lightweight phoenix webapp that spits out results from a python script that my friend built. That script runs with tensorflow.

My question is do I host (on the elixir service and python service separately? I mean to create a python flask app and put the tensorflow prediction scripts on it to expose it as an API. Then separately create a phoenix elixir app. 2 compute instance in total.

I understand that for local development, I can simply have both projects in one repository and simply use Erlport to link between them. However, i’m not sure what is the best practise for doing this on production ( Please let me know your thoughts.

There isn’t a best practice I guess, any of the solutions you listed have their pros and cons. I would also add gRPC to the list.

I explored a REST API, Ports, but ended up with gRPC, I feel it’s the “cleaner” solution to integrate external services I control in terms of interoperability and resilience.

1 Like

A left field option you might consider is porting the prediction script to Elixir (provided it isn’t too complex), using Nx - there’s an entry point to the docs here: Announcing Bumblebee: GPT2, Stable Diffusion, and more in Elixir - - The Livebook Blog or here Distributed² Machine Learning notebooks with Elixir and Livebook - Launch Week 1 - Day 2 - - The Livebook Blog

Thank you for the suggestion

Ah, I would if I was the one working on that part of the project but sadly my friend is only familiar with doing it on python. Thank you for the suggestion. The bumblebee project is cool! I’ve tried out that little livebook example.