Skip to content

FourMInfo/julia-workshop

 
 

Repository files navigation

Julia workshop for the UCL Festival of Digital Research & Scholarship 2024

This repository contains the material for the UCL Festival of Digital Research & Scholarship 2024.

Running the notebook

Locally

Note

This is our recommended option, as you will more easily be able to keep playing with the notebook afterwards.

Clone this repository (make sure to install Git) and then enter inside the new directory by running the following commands in a terminal (we recommend using PowerShell if on Windows):

git clone https://github.com/UCL-ARC/julia-workshop
cd julia-workshop

After installing Julia, start it with

julia --project=.

and then inside the Julia REPL you can run Pluto, the interactive notebook environment we will be using, with

# Necessary only the first time, to instantiate the environment
using Pkg
Pkg.instantiate()

# Run the notebook
using Pluto
Pluto.run()

This should open a tab in your default browser showing the Pluto interface. From there find the Open a notebook section and click on the Enter path or URL... field. Select notebook.jl from the drop-down and then click the Open button to open the example notebook we will be using.

Note

The notebook will initially be opened in Safe preview mode which allows you to view and edit the notebook content but not run any code, or view the rendered outputs. This is a security measure to prevent malicious notebooks being run automatically that may try to steal data. To exit from Safe preview mode either click the Safe preview ⓘ information button at the bottom of the interface and click run this notebook or click on the Run notebook code link in the top-right of the interface.

Using a Docker container

We also provide a Docker image (built for linux/amd64 and linux/arm64) for running the notebook, which you can pull with

docker pull ghcr.io/ucl-arc/julia-workshop:main

The interactive notebook environment we will be using, Pluto, can then be run on MacOS or Linux with

docker run -p 1234:1234 -ti ghcr.io/ucl-arc/julia-workshop:main julia -e 'using Pluto; Pluto.run(; host="0.0.0.0", port=1234)'

or if using PowerShell on Windows with

docker run -p 1234:1234 -ti ghcr.io/ucl-arc/julia-workshop:main julia -e 'using Pluto; Pluto.run(; host=""""0.0.0.0"""", port=1234)'

This will launch Pluto within the container, and if successful you should see a message similar to

[ Info: Loading...
┌ Info:
└ Go to http://0.0.0.0:1234/?secret=hgY7as1X in your browser to start writing ~ have fun!

where hgY7as1X in the URL will be replaced with another random alphanumeric string. The Pluto notebook environment is accessed as a web app, so you should open a browser window and navigate to the URL indicated in the message to open the Pluto interface. If you get Unable to connect message or similar when trying to open the URL, you may need to replace the 0.0.0.0 component with localhost, so for the example above you would navigate to http://localhost:1234/?secret=hgY7as1X.

Once you have the Pluto interface open in your browser, you will need to load the notebook saved at /root/notebook.jl. To open the notebook, find the Open a notebook section in the Pluto interface, click on the Enter path or URL... field and select root/ and then notebook.jl from the drop-down file navigator and finally click the Open button to open the example notebook we will be using.

GitHub Codespaces

You can also take advantage of the ability of GitHub Codespaces to run custom web apps. Go go the Codespaces page of this repository, click on the green button on the top right "Create codespace on main" and wait a few seconds for the codespace to start. In the bottom panel, go to the "Terminal" tab (other tabs should be "Problems", "Output", "Debug console", "Ports") and when you see the message (this can take a few seconds to appear after the codespace started, hold on)

[ Info: Loading...
┌ Info:
└ Go to http://localhost:1234/ in your browser to start writing ~ have fun!

go to the "Ports" tab, right click on the "Pluto server (1234)" port and click on "Open in browser" (alternatively, click on the globe-shaped button under the "Forwarded Addresses" column). This will open the Pluto landing page in a new tab in your browser and from there you can open the existing notebook saved at notebook.jl.

If you want to make your app accessible to others (please remember to make sure there's no sensitive or private data in it!), navigate to the "Ports" tab, right click on the "Pluto server (1234)" port and then "Port visibility" -> "Public".

The .devcontainer has been adapted from Zero-setup R workshops with GitHub Codespaces repository presented at rstudio::conf 2022.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Julia 98.0%
  • Dockerfile 1.3%
  • Shell 0.7%