nallwhy

nallwhy

Doumi.Port is a helper library that facilitates the usage of Python in Elixir powered by Erlport, NimblePool.

https://github.com/nallwhy/doumi_port

It’s inspired by Export, but not just a wrapper of Erlport, will be a toolchain for using Python, Ruby in Elixir.

defmodule MyApp.Application do
  ...

  @impl true
  def start(_type, _args) do
    children = [
      ...
      {Doumi.Port.Pool, port: {Doumi.Port.Python, python_path: [...]}, name: MyApp.PythonPool}
    ]

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

defmodule MyApp.Native do
  def add(a, b) do
    Doumi.Port.Pool.command(MyApp.PythonPool, :operator, :add, [a, b])
  end
end

> MyApp.Native.add(1, 2)
3

Thanks!

Showing Posts 1 to 6

ivanhercaz

ivanhercaz

I will test it as soon as possible! :heart_eyes::heart_eyes:

I recommend you to link to the Doumi.Port repository and the Hex package in the post. It will be easier for the people to check them :smiling_face_with_three_hearts:.

nallwhy

nallwhy OP

Oh, I forgot it. Thanks!!

kokolegorille

kokolegorille

Nice, I might use it soon too…

I use poolboy with erlport, but I see You use nimble_pool instead :slight_smile:

nallwhy

nallwhy OP

v0.2.0 is released!

use macro is added to make it easier.

defmodule MyApp.PythonPool do
  use Doumi.Port.Pool,
    port: {Doumi.Port.Python, python_path: [...]}
end

defmodule MyApp.Application do
  ...

  @impl true
  def start(_type, _args) do
    children = [
      ...
      MyApp.PythonPool
    ]

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

defmodule MyApp.Native do
  def add(a, b) do
    MyApp.PythonPool.command(:operator, :add, [a, b])
  end
end
nallwhy

nallwhy OP

v0.4.0 is released!

  • It supports Ruby also.
  • mix doumi.port.init, mix doumi.port.setup is added.

# Create requirements.txt, .gitignores to ./priv/python

mix doumi.port.init --port python

# Add Python dependency

echo "pypdf2==3.0.1" >> ./priv/python/requirements.txt

# Install Python dependecies

mix doumi.port.setup --port python

You can install Python dependencies to your release with mix doumi.port.setup.

defmodule MyApp.MixProject do
  defp aliases do
    [
      ...,
      "release.setup": ["doumi.port.setup --port python", ...]
    ]
  end
end
...

# release setup (ex. install Python dependencies, compile assets)
RUN mix release.setup

...
sundevilyang

sundevilyang

there is an error when following the README

[notice] Application runtime_tools exited: :stopped
** (Mix) Could not start application doumi_port_demo: exited in: DoumiPortDemo.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (KeyError) key :port not found in: [adapter: {Doumi.Port.Adapter.Python, [python_path: 
— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews