mruoss

mruoss

Hi

Does somebody know if there’s a way to access the special cell pyproject.toml that is created when initializing Python in a Livebook from an Elixir cell? I’d just need the blob as a string.

Showing Posts 1 to 10

josevalim

josevalim

Creator of Elixir

It doesn’t seem there is a straight-forward location to fetch it. What is the use case?

mruoss

mruoss OP

The use case is to reuse it to initialize Python in a FLAME runner. But I guess I can just not use that cell and create a module/function for initializing Python and use that on both sides (in the livebook and in the FLAME runner)

josevalim

josevalim

Creator of Elixir

Ah, that’s something we want to explore. Honestly, I would instead try to find the folder where the Python packages are and transfer them as is instead. No need to download it again.

mruoss

mruoss OP

Tried. Failed… :slight_smile:
There might actually be a small bug in FLAME’s copy_paths option.
https://github.com/phoenixframework/flame/issues/83

mruoss

mruoss OP

I manage to copy all the things over to the runner but somehow it still says Python is not initialized… might dig a bit more…

mruoss

mruoss OP

Alright, I managed to sync the entire pythonx cache directory by passing the following option to the FLAME pool:

copy_paths: Path.wildcard(Path.join(File.cwd!(), ".cache/pythonx/**"), match_dot: true)

However, I still need to run Pythonx.uv_init(my_toml) in order to initialize the NIF? But with the .venv in place, it won’t download stuff anymore. I still need that toml though, but that’s only because there’s currently no function to get the current project path inside .cache/pythonx. If I knew that, I could also only sync that project and didn’t have to sync the entire cache folder with all the projects in it. Plus, I could probably derife the necessary arguments to call Pythonx.NIF.init().

So I guess all in all the Pythonx module API could be improved for this use case but technically it’s not far from supporting it…?

josevalim

josevalim

Creator of Elixir

Yes, it is not something we support yet but we want to make Pythonx work out of the box with FLAME, so any progress or PRs you can send along those lines will be welcome.

For example, we may be fine with moving the TOML to the .cache/pythonx, at least you can try it in a fork and see if that unblocks you.

mruoss

mruoss OP

Happy to support once we have an approach.

For example, we may be fine with moving the TOML to the .cache/pythonx

It’s a bit of a chicken/egg problem if I understand correctly. So when running in Livebook, the pyproject TOML is actually already inside .cache/pythonx. Concretely it’s in .cache/pythonx/PYTHONY_VERSION/uv/UV_VERSION/projects/MD5_OF_TOML/pyproject.toml. But without the toml it’s impossible to calculate that MD5_OF_TOML and derive the directory.

josevalim

josevalim

Creator of Elixir

Perhaps uv_init should return the path to said project, and then we can keep it internally in Livebook or expose it as a var?

mruoss

mruoss OP

Yes that would probably work.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews