Giter Club home page Giter Club logo

Comments (6)

josevalim avatar josevalim commented on May 22, 2024 1

@jonatanklosko here is the issue: imagine I want to ship some livebook with some data. I can put it all on a zip file and I can tell folks to unpack and run it. How to do so? :)

Do we at least ensure that ENV.file today points to the livebook.md? Because if it does, I guess we can use Path.join(__DIR__, "file/foo/bar")?

from livebook.

jonatanklosko avatar jonatanklosko commented on May 22, 2024

Changing the directory can lead to unexpected results. Imagine you go to /project and start Livebook server. Then you create notebook in memory, work on stuff and use File.write/read (so you naturally work within /project). Now you save the notebook somewhere else (just to have the notebook persisted). If we switch cwd, then the existing code will start writing/reading into different place and they user may not even notice that.

By default I'd expect cwd to reflect wherever I start the Livebook server, and it's more that Mix and Attached are very specific cases, where cwd is different by their nature.

from livebook.

jonatanklosko avatar jonatanklosko commented on May 22, 2024

Do we at least ensure that ENV.file today points to the livebook.md? Because if it does, I guess we can use Path.join(DIR, "file/foo/bar")?

We don't, but this sounds like an option. This way we could also put File.cd!(__DIR__) at the top to achieve what we want? One detail I'm not sure about is that for cell errors we would report notebook.livemd:n, whereas it's actually this_specific_cell:n.

from livebook.

josevalim avatar josevalim commented on May 22, 2024

This way we could also put File.cd!(DIR) at the top to achieve what we want?

It would, yeah. So let's go with setting the file name to the livebook path. And if it is memory, we set it to "in-memory.livemd"?

I am not sure if the specific cell matters, because we always show errors close to the cell anyway and all of the cell IDs are private?

from livebook.

jonatanklosko avatar jonatanklosko commented on May 22, 2024

I am not sure if the specific cell matters, because we always show errors close to the cell anyway and all of the cell IDs are private?

Yeah, my only point was that we would say notebook.livemd:3, but the 3 refers to the line in the cell, rather than line 3 in notebook.livemd.

from livebook.

josevalim avatar josevalim commented on May 22, 2024

@jonatanklosko oh, I see. We could set the file to something like "notebook.livemd#cell:3" but it means __ENV__.file will be wrong but __DIR__ is still right.

from livebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.