# Untitled notebook ```elixir # This is the notebook configuration, for a production app you would handle this with mix.exs # and the various config files to build a packaged release with the appropriate configurations baked in Mix.install([ {:pythonx, "~> 0.4.0"}, {:req, "~> 0.5.8"}, {:flame, "~> 0.5.2"} ], config: [ flame: [ backend: FLAME.LocalBackend ], pythonx: [ uv_init: [ pyproject_toml: """ [project] name = "project" version = "0.0.0" requires-python = "==3.13.*" dependencies = [ "pytesseract==0.3.13", "pillow==11.1.0" ] """ ] ] ]) ``` ## Section ```elixir # Configure the Flame Pool on the calling node # Normally you do this on application startup # Note that startup needs to be handled slightly differently # on FLAME worker nodes, see the flame docs for details children = [ {FLAME.Pool, name: Demo.FlameRunner, min: 0, max: 10, max_concurrency: 5, idle_shutdown_after: 30_000}, ] opts = [strategy: :one_for_one, name: Demo.Supervisor] Supervisor.start_link(children, opts) ``` ```elixir # Load the image from unsplash # Note that the image is loaded here on the calling node url = "https://unsplash.com/photos/95t94hZTESw/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzQwMDYwMjg4fA&force=true&w=640" binary = Req.get!(url).body ``` ```elixir # Calling process - this runs on whatever node wants to start the task, # and will block until the call finishes executing on the Flame node (or times out) {:ok, result} = FLAME.call(Demo.FlameRunner, fn -> # Flame Process - this is executed on a FLAME Runner Node, started on the configured backend {result, _globals} = Pythonx.eval( """ import pytesseract import io import PIL # This is a fix for an issue on the machines I am using - # python was having trouble finding tesseract, which is installed globally pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/tesseract' image = PIL.Image.open(io.BytesIO(binary)) pytesseract.image_to_string(image) """, %{"binary" => binary} ) decoded_result = Pythonx.decode(result) {:ok, decoded_result} end) # Back on the calling node IO.puts result ```