USGS-R / drb-estuary-salinity-ml

Creative Commons Zero v1.0 Universal
0 stars 4 forks source link

Develop Binder for Salt_front_drivers_exploration notebook #41

Open ted80810 opened 2 years ago

ted80810 commented 2 years ago

Questions: How do users run binder on local machine (outside of web browser)? Can users make changes to Notebook on Binder? How do you save notebook with environment to local machine?

Sub-topics: How to increase start up time.

ted80810 commented 2 years ago

I started thinking about how to increase the start-up time of the Binder, after @aappling-usgs suggested loading the notebook from a checkpoint. So, the binder loads faster each time a user clicks the link, but there is a way to "static" load the environment. Binder will only need to load the notebook. However, this method requires creating a separate repository to house the environment as a "content repository".

I wanted to know everyone's thoughts about this as an option. I was thinking of only testing it, if the test notebook takes to much time to load. The steps to this are relatively simple and outline here.

galengorski commented 2 years ago

I'm not sure I totally understand the idea of a content repository, however if it decreases the binder load time, I think it could be worth testing at least. I think the major goals for this issue are:

The second one is where we got stuck yesterday, not sure if binder would allow you to interact with your local file paths while still executing the notebook in the container. Maybe @jds485 might have some ideas?

jds485 commented 2 years ago

It should be possible to use the container for any file path (where the user has read/write permissions). I can chat with you if that would be helpful. I've not tried with binder before, but I did run code locally from the container

ted80810 commented 2 years ago

Here is the link to the test binder. It should be working with all the libraries in the conda environment. One thing to note is that I created a requirement.txt file that lists all the libraries needed for the notebook. I found that it was much easier to use a requirement file for Binder to point to when creating the docker image.

In regards to loading local files, Binder deploys the image in the cloud; it searches for files in a cloud workspace (/home/jovan/). However you can upload any of your local files to the workspace folder (/home/jovyan/). You simply have to upload it from the file menu. You can also download any files generated by the notebook (right-click, download) in the workspace. Alternatively, we can opt to store the docker file in the repo. Binder would just build the image from the docker file in the repo. This way we can use the container for any file path, as @jds485 mentioned. On the other hand, the current setup does not require docker to be installed on your machine. Regardless, I would definitely be up for discussing this more with you @jds485 .

You can download the notebook at any time, with changes you make in the Binder. As far as the environment, there are two options. With the current setup, you will have to create an environment on your local machine. I added detailed instruction in the README document on how to load the environment from the yaml file in the repository. The second option requires the user to have docker installed on their computer. This option works if we opt to store the docker file in the repo.

Binder creates a new image every time it detects a change to the notebook, so you just have to push the commits for Binder to recognize them. I tested this out and it worked fine. I saw all the changes when the Binder loaded.

Feel free to test out the Binder and the notebook locally on your machine. Let me know if there are some pain points.