bgoosman

bgoosman

Notebook global variable

I’d like to define an s3 bucket name as a global in my livebook. I guess I could use a notebook secret for that, but it’s not really a secret, more like an environment variable. How would you solve this?

Marked As Solved

jonatanklosko

jonatanklosko

Creator of Livebook

Secret sounds good, it doesn’t need to be a secret value per se. In the settings you can also define global environment variables.

Also Liked

jonatanklosko

jonatanklosko

Creator of Livebook

I wonder if it can be used for this use case too?

My understanding is that you want a value shared across notebooks, so a secret/env makes sense. Otherwise you can just define a variable in the setup cell, or at the top.

As for Mix.install, in case of runtime config I usually prefer this:

Mix.install([
  {:req, "~> 0.5.6"},
  {:kino, "~> 0.14.0"},
  {:ex_aws, "~> 2.1"},
  {:ex_aws_s3, "~> 2.0"},
  {:hackney, "~> 1.9"},
  {:sweet_xml, "~> 0.6"},
  {:cachex, "~> 4.0"},
  {:exjsx, "~> 4.0"},
  {:kino_slack, "~> 0.1.1"}
])

Application.put_env(:ex_aws,
  debug_requests: true,
  json_codec: Jason,
  access_key_id: {:system, "LB_AWS_ACCESS_KEY_ID"},
  secret_access_key: {:system, "LB_AWS_SECRET_ACCESS_KEY"},
  s3: [
    scheme: "https://",
    host: "fly.storage.tigris.dev",
    region: "auto"
  ]
)

The advantages is that changing config in this way doesn’t invalidate the Mix.install cache.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New

We're in Beta

About us Mission Statement