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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add 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
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
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews