Skip to content

Commit f4e7bfe

Browse files
committed
ijulia collab
1 parent ad16f86 commit f4e7bfe

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
layout: post
3+
title: "Collaborating on a Julia Project"
4+
date: 2020-02-09
5+
mathjax: on
6+
widgets: false
7+
---
8+
9+
For personal projects, I tend to skip around a lot and not focus on one thing, so today's post is a break from the [Trebekian.jl](https://github.com/mprat/Trebekian.jl) project from the previous post. Instead, I want to talk a little bit about how to collaborate on a Julia project with other people.
10+
11+
<!--more-->
12+
13+
* TOC
14+
{:toc}
15+
16+
# Why Collaboration
17+
18+
Collaborating on a project is the best way to accelerate development. Different people bring different skills to the table, and with combined brains and powers, the end result becomes easier to achieve.
19+
20+
# Collaboration Software
21+
22+
There are so many blogs and resources out there about collaboration software, specifically focused on task, time, and issue management. While this is all valuable, as a home-hacker-and-tinkerer, I care more about the nuts and bolts of HOW to collaborate and less about how to divvy up tasks. If we're working on a personal project, we're doing it for fun and likely not trying to reach some lofty milestones.
23+
24+
For tinkering, I've settled on the following tools as critical (with helpful input from my [most frequent collaboration partner](https://blog.robindeits.com)).
25+
26+
* `git` for version control - most repositories are hosted on Github. If we need a private repository for some reason we will either (a) set up a private Github repo or (b) set up a private repository on Bitbucket. Gitlab is a strong contender in the space as well, but we both have active Github profiles and it's easier to manage repositories in one place than 3. To be effective at working with others I always make sure I have `git` installed on my machine in whatever environment I'm working with.
27+
* `jupyter notebook` for scripts and tinkering - I've written about [jupyter notebooks](http://jupyter.org/) before, namely on [my first post of this blog]({% post_url 2017-02-19-launching-learning-julia %}). It's a great way to have an interactive shell that can do inline visualizations. It's the bread-and-butter of modern computer science tinkering.
28+
29+
# Install Jupyter Notebook and the Julia Kernel
30+
31+
I was recently setting up a new collaboration environment on a [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) machine, which is basically Linux, so I had to learn how to do all these steps from scratch. Because `jupyter notebook` can run multiple different kernels (i.e. Julia, Python, R, etc.) I wanted to install it globally in my workspace. On Linux (or WSL), you need to install the core, client, and notebook packages:
32+
33+
```
34+
sudo apt install jupyter-core jupyter-client jupyter-notebook
35+
```
36+
37+
Now from a shell you can run `jupyter notebook` and launch the notebook!
38+
39+
Now we need to make sure we can run a Julia kernel through `jupyter notebook`. To do this, we need to install `IJulia` through our Julia package manager.
40+
41+
You have 2 options for this. (a) install it globally on your Julia installation, or (b) install it per-project. I personally installed it globally for my Julia installation because I use it in every project, so it saves me pain and time. Installing `IJulia` hooks up your `jupyter` installation to a Julia kernel, which lets us actually run Julia through `jupyter notebook`.
42+
43+
```
44+
[mprat@DESKTOP-RUH3B2E] [3d-jigsaw (master *=)]$ julia
45+
46+
_
47+
_ _ _(_)_ | Documentation: https://docs.julialang.org
48+
(_) | (_) (_) |
49+
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
50+
| | | | | | |/ _` | |
51+
| | |_| | | | (_| | | Version 1.3.1 (2019-12-30)
52+
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
53+
|__/ |
54+
55+
julia>
56+
57+
(v1.3) pkg> add IJulia
58+
Updating registry at `~/.julia/registries/General`
59+
Updating git-repo `https://github.com/JuliaRegistries/General.git
60+
Resolving package versions...
61+
Updating `~/.julia/environments/v1.3/Project.toml`
62+
[no changes]
63+
Updating `~/.julia/environments/v1.3/Manifest.toml`
64+
[no changes]
65+
66+
(v1.3) pkg>
67+
```
68+
69+
Now to actually build the kernel and have it all work, you should also build it:
70+
71+
```
72+
(v1.3) pkg> build IJulia
73+
```
74+
75+
After this step is done, we can launch `jupyter notebook` from the command-line and have it use the appropriate Julia kernel.
76+
77+
Next up, opening our project!
78+
79+
# Opening A Julia Package to Tinker With
80+
81+
To actually start tinkering with our Julia project, we need to first clone it from whereever we're working from to have a copy of it locally.
82+
83+
```
84+
git clone WHATEVER
85+
```
86+
87+
Next we open `jupyter notebook` from the repo you just cloned. If we've properly set up `IJulia` and `jupyter`, it will launch a `jupyter notebook` and you can open a new or existing notebook to work on.
88+
89+
Next, activate the project's Julia environment from it's `Project.toml` file. From `jupyter notebook` you can do:
90+
91+
```
92+
using Pkg
93+
Pkg.activate(@__DIR__)
94+
Pkg.resolve()
95+
```
96+
97+
What this does is install all the packages from the cloned project's `Manitest.toml` into a local virtual environment of Julia packages. If you are NOT using `jupyter notebook` you can also do this from the Julia package shell:
98+
99+
```
100+
(v1.3) pkg> activate .
101+
102+
Activating environment at `/mnt/c/Users/mprat/Documents/repos/3d-jigsaw/Project.toml`
103+
104+
(3d-jigsaw) pkg> resolve
105+
106+
Resolving package versions...
107+
Updating `/mnt/c/Users/mprat/Documents/repos/3d-jigsaw/Project.toml`
108+
[no changes]
109+
Updating `/mnt/c/Users/mprat/Documents/repos/3d-jigsaw/Manifest.toml`
110+
[no changes]
111+
112+
(3d-jigsaw) pkg>
113+
```
114+
115+
# Tinker!
116+
117+
Now the environment is all set up to tinker! Yay =D

0 commit comments

Comments
 (0)