fhunleth

fhunleth

Co-author of Nerves

We’re using Livebook for data analysis and are putting all of our notebooks in a common private git repository. We’ve built up some utility code to help with querying our data warehouse and other things. It’s nice to maintain that code in the same git repository since it’s tightly coupled to the notebooks. I was wondering how others did this, since what we’re doing right now seems “just ok”.

Our current solution is to put the utility code in a little library and Mix.install’ it as a path dependency from each Livebook. The directory structure looks like this:

.
├── notebooks
│   ├── xyz.livemd
│   └── ...
├── sandbox
│   └── ...
├── our_utils
│   ├── lib
│   ├── mix.exs
│   └── README.md
├── README.md
├── template.livemd
└── tutorial.livemd

The notebooks and sandbox directories contain Livebooks organized at various path depths. When creating a new notebook, we copy template.livemd which has a good Mix.install line and a couple generic sections. The Mix.install includes the our_utils library.

This mostly works, but could be improved.

For example, here’s the dependency snippet to find the our_utils directory since it could be at any depth:

base_dir = Stream.iterate(Path.expand(__DIR__), &Path.dirname/1) |> Enum.find(&File.dir?(Path.join(&1, "our_utils")))
Mix.install([
  {:kino_explorer, "~> 0.1.20"},
  {:our_utils, path: Path.join(base_dir, "our_utils")},
])

It’s a one-liner and spares us from errors based on different directory depths. It doesn’t work when the notebook hasn’t been saved in a subdirectory of our main project.

We’ve talked about switching the dependency to a github reference, but the branch would almost certainly effectively be main. It would also require switching back to a path dependency every time we work on it. Not terrible, but also seems like it could be better.

I suppose I’ll leave it at that and just see what has worked for others in this situation.

Showing Posts 1 to 2

Eiji

Eiji

How about environment variable?

base_dir = System.get_env("OUR_APP_GIT_DIR")

Simply add this env once to your shell script (like ~/.basrc) and you can easily use it even with git:

git clone url "$OUR_APP_GIT_DIR"

Yes, it’s “extra work” for each team member, but it’s better not only because it’s shorter, but also because it’s using a common way for environment-specific configuration. Also Livebook should support environment variables as well.

fhunleth

fhunleth OP

Co-author of Nerves

Hi @Eiji,

Thanks. An environment variable seems reasonable.

It’s hard for me to argue that any of the “extra work” is difficult in isolation, but somehow it comes together. Your point is well taken, and I’ll try to embrace the environment variable and look for friction reduction elsewhere.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
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
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
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
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews