Skip to content

odow/SESO2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SESO2023

This repository contains materials for two workshops:

Both workshops will be interactive. To follow along, you should download these materials and install Julia prior to the workshop.

Getting help

If you have trouble following the instructions below, please open a Github issue, or email o.dowson@gmail.com.

Install Julia

To get started, you first need to install Julia.

If you cannot install locally, see the "Google Colab" instructions below.

Common problems

  • If you use Windows, choose the 64-bit installer
  • If you have a new M1 or M2 mac, choose the (Apple Silicon) version

Alternatives

If you are comfortable using a command line, you may instead want to install juliaup, which is a small CLI for managing and updating your installations of Julia.

Download these materials

Next, you need to download a copy of these materials.

If you have git installed

cd to an appropriate directory, then run

git clone https://github.com/odow/SESO2023

If you don't have git installed

Download this zip file. Once downloaded, unzip it to an appropriate location.

Open Julia

Now open Julia, either by typing julia at a terminal, or by launching the icon from wherever you installed it.

Once open, you should be faced with the Julia REPL that looks like this:

Julia REPL

Install the required packages

Now we need to install some packages.

In the Julia REPL, run the following commands, replacing the path with the location of where you downloaded the materials.

cd("/Users/Oscar/Downloads/SESO2023-main")
import Pkg
Pkg.activate(".")
Pkg.instantiate()
Pkg.build("IJulia")
julia> cd("/Users/Oscar/Downloads/SESO2023-main")

julia> import Pkg

julia> Pkg.activate(".")
  Activating project at `~/Downloads/SESO2023-main`

julia> Pkg.instantiate()
    Updating registry at `~/.julia/registries/General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
    Updating `~/Downloads/SESO2023-main/Project.toml`
... lots of lines omitted ...
Precompiling project...
  233 dependencies successfully precompiled in 274 seconds

julia> Pkg.build("IJulia")
    Building Conda ─ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/8c86e48c0db1564a1d49548d3515ced5d604c408/build.log`
    Building IJulia  `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/47ac8cc196b81001a711f4b2c12c97372338f00c/build.log`

WARNING: it takes a few minutes to download and compile all the packages! The good news is that you only have to run this command once.

Common problems

  • On Mac and Linux, cd("~") may throw an error instead of cding to your home directory:
    julia> cd("~")
    ERROR: IOError: cd("~"): no such file or directory (ENOENT)
    To fix, type the full path to the home directory, or type cd("~, then press the TAB key.

Open a Jupyter notebook

Okay, last step, let's launch a Jupyter notebook. Open a Julia REPL and then run:

import Pkg
cd("/Users/Oscar/Downloads/SESO2023-main")
Pkg.activate(".")
import IJulia
IJulia.notebook(dir = ".")

If all goes well, a browser window will open that looks like this:

jupyer_notebook

To get started on the content portion of the tutorials, double click on the "notebooks" folder, and then 00_getting_started_with_julia.ipynb. Then click "Cell > "Run All".

jupyer_notebook

If things are sucessful, all of the cells should run (some will error on purpose). You're now ready to follow along with the live training.

Common problems

  • Don't start Jupyter via Anaconda! There are some version differences that cause problems.
  • If you encounter install Jupyter via Conda, y/n? [y]:, press the y key

Updating the materials

I will continue to update these materials over time. To update the materials you previous installed:

If you have git installed

git pull the latest changes. All of the packages will remain installed, so the only thing that will change are the Jupyter notebooks.

Common problems

  • If you made changes to a notebook that was updated, git will throw an error saying error: Your local changes to the following files would be overwritten by merge: If the changes can be discarded, do git checkout notebook_name.ipynb and then try git pull again.

If you don't have git installed

Download a new copy of the zip file, and then copy-paste the new notebooks into the old directory. There is no need to re-run the other installation steps.

Google Colab

Open http://colab.research.google.com/ and import one of the colab_xxx notebooks by providing the link to the GitHub repository:

https://github.com/odow/SESO2023

Install Julia

Click "Connect" in the top-right corner.

You will get a warning that the kernel julia-1.9 is not recognized, defaulting to python3. This is because Julia is not officially supported by Google Colab.

To install Julia, create a new code cell at the top of the notebook, and run:

%%shell
set -e
wget -nv https://raw.githubusercontent.com/odow/SESO2023/main/install_colab.sh -O /tmp/install_colab.sh
bash /tmp/install_colab.sh  # Takes ~ 2 minutes

Reload the page to load the notebook with the correct kernel.

Install packages

We also need to install the various packages.

You can either create a new code cell and manually specify the packages that need installing via Pkg.add, for example:

import Pkg; Pkg.add(["JuMP", "HiGHS"])  # Can take ~ 5 minutes

Or you can download the Project.toml file from the GitHub repo and install all the packages in one go. This can take a few minutes to install and compile everything.

import Downloads, Pkg
Downloads.download("https://raw.githubusercontent.com/odow/SESO2023/main/Project.toml", "/tmp/Project.toml")
Pkg.activate("/tmp/Project.toml")
Pkg.instantiate()  # Can take ~ 7 minutes

Common problems

  • Because each notebook runs in a self-contained virtual machine, you need to re-install Julia and all of the packages every time you start Colab. If you use Colab frequently and have a solution to this problem, please let me know.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages