Skip to content

Commit 94c2857

Browse files
authored
Guidelines authors (#39)
* More details for authors. * Update contact email. * Put in separate files the way to handle dependencies with the three languages. * References section to facilitate later embedding in templates. * Add guidelines about how to handle dependencies for Python users. * Updated information about setup env and render ci scripts.
1 parent 1f3b03a commit 94c2857

11 files changed

+592
-62
lines changed
Loading

assets/img/2025-03-20-revised-github-process/workflow.svg

Lines changed: 210 additions & 0 deletions
Loading
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
\documentclass[tikz,dvisvgm,border=10pt]{standalone}
2+
\usetikzlibrary{shapes.geometric,shapes.symbols,shapes.callouts,shapes.multipart,shapes.misc,arrows,positioning,fit,backgrounds,shadows}
3+
4+
\begin{document}
5+
\begin{tikzpicture}[
6+
% Define styles for nodes with enhanced colors
7+
doc/.style={draw, minimum width=5cm, minimum height=2cm, align=center, fill=blue!20, text=blue!80!black, font=\bfseries, rounded corners=3mm, drop shadow},
8+
container/.style={draw=blue!50!black, fill=blue!10, fill opacity=0.15, inner sep=10mm, rounded corners=8mm, thick, dashed},
9+
package/.style={draw, fill=blue!5, fill opacity=0.7, inner sep=3mm, rounded corners, text=blue!60!black, thick},
10+
process/.style={draw, minimum width=2cm, minimum height=1cm, align=center, fill=blue!10, text=blue!60!black, font=\small\sffamily, rounded corners=2mm},
11+
cylnode/.style={draw, cylinder, shape border rotate=90, aspect=0.3, minimum height=1cm, minimum width=2cm, align=center, fill=cyan!30, text=cyan!60!black, font=\small\sffamily},
12+
dashboard/.style={circle, draw, minimum size=1cm, fill=green!20, text=green!60!black, font=\small\sffamily\bfseries},
13+
document/.style={draw, shape=tape, tape bend top=none, minimum width=2cm, minimum height=1cm, align=center, dashed, fill=purple!10, text=purple!70!black, font=\small\sffamily\itshape},
14+
thick_arrow/.style={->, line width=1mm, draw=blue!70!black},
15+
arrow/.style={->, >=stealth, draw=gray!70!black},
16+
title/.style={font=\bfseries\sffamily, align=center, text width=4cm, text=blue!70!black},
17+
label/.style={font=\small\sffamily\itshape, inner sep=2pt, text=purple!80!black},
18+
filename/.style={font=\small\sffamily\itshape, text=orange!70!brown}
19+
]
20+
21+
% Add a background for the entire diagram
22+
\begin{scope}[on background layer]
23+
\fill[rounded corners=10mm, gray!5] (-2,-8) rectangle (16,4.5);
24+
\end{scope}
25+
26+
% Create environment steps first
27+
\node[dashboard] (checkout) at (5,0) {Git};
28+
\node[process, below=0.8cm of checkout] (detect) {Detect\\Dependencies};
29+
\node[process, below=0.8cm of detect] (setup) {Setup Environment\\(Python/R)};
30+
\node[cylnode, below=0.8cm of setup] (cache) {Cache\\Environment};
31+
32+
% Environment connections
33+
\draw[arrow] (checkout) -- (detect);
34+
\draw[arrow] (detect) -- (setup);
35+
\draw[arrow] (setup) -- (cache);
36+
37+
% Custom environment script - with label higher
38+
\node[document] (customenv) at ([xshift=-3cm]setup.west) {setup-env-ci.sh};
39+
\draw[arrow, draw=purple!50!black] (customenv) -- (setup) node[pos=0.35, above=12pt, label] {Customize};
40+
41+
% Environment setup container with title above
42+
\node[title] at (checkout.north) [above=5mm] {Environment Setup \\\textcolor{orange!70!brown}{(global-env.yml)}};
43+
44+
% Use layers to put containers in the background - adjusted fit
45+
\begin{scope}[on background layer]
46+
\node[package, fill=blue!5] (env) [fit=(checkout) (detect) (setup) (cache) (customenv)] {};
47+
\end{scope}
48+
49+
% Create render steps first - explicitly aligned with env.east anchor
50+
\path (env.east) ++(3cm,0) coordinate (render_start);
51+
\node[process, fill=blue!20] (restore) at ([yshift=3cm]render_start) {Restore\\Environment};
52+
\node[process] (quarto) at ([yshift=-0.8cm]restore.south) {Setup Quarto};
53+
\node[process] (compile) at ([yshift=-0.8cm]quarto.south) {Render\\Documents};
54+
\node[process] (artifact) at ([yshift=-0.8cm]compile.south) {Upload as\\Artifact};
55+
\node[process, fill=green!30, text=green!60!black, font=\small\sffamily\bfseries] (deploy) at ([yshift=-0.8cm]artifact.south) {Deploy to\\GitHub Pages};
56+
57+
% Render connections
58+
\draw[arrow] (restore) -- (quarto);
59+
\draw[arrow] (quarto) -- (compile);
60+
\draw[arrow] (compile) -- (artifact);
61+
\draw[arrow] (artifact) -- (deploy);
62+
63+
% Custom render script - with label higher and inverted direction
64+
\node[document] (customrender) at ([xshift=2.5cm]compile.east) {setup-render-ci.sh};
65+
\draw[arrow, draw=purple!50!black] (customrender) -- (compile) node[pos=0.35, above=12pt, label] {Customize};
66+
67+
% Render and deploy container with title above
68+
\node[title] at (restore.north) [above=5mm] {Render \& Deploy \\\textcolor{orange!70!brown}{(publish-render.yml)}};
69+
70+
% Use layers to put containers in the background - adjusted fit
71+
\begin{scope}[on background layer]
72+
\node[package, fill=blue!10] (render) [fit=(restore) (quarto) (compile) (artifact) (deploy) (customrender)] {};
73+
\end{scope}
74+
75+
% Main flow connections
76+
\draw[thick_arrow] (env.east) -- (render.west |- env.east);
77+
78+
% Finally create the main workflow container around everything
79+
\begin{scope}[on background layer]
80+
% Create invisible nodes to capture the title areas
81+
\node[opacity=0] (env_title_anchor) at ([yshift=10mm]checkout.north) {};
82+
\node[opacity=0] (render_title_anchor) at ([yshift=10mm]restore.north) {};
83+
84+
% Make container fit these invisible nodes too, ensuring it goes high enough
85+
\node[container, fit=(env_title_anchor) (render_title_anchor) (env) (render)] (workflow_container) {};
86+
87+
% Place the title well above the container with colored filename
88+
\node[font=\bfseries\Large, text=blue!70!black, align=center] at ([yshift=10mm]workflow_container.north) {Main Workflow \\\textcolor{orange!70!brown}{(build.yml)}};
89+
\end{scope}
90+
91+
\end{tikzpicture}
92+
\end{document}

assets/img/clone-template.png

403 KB
Loading

assets/img/transfer-ownership.001.png

207 KB
Loading

assets/img/transfer-ownership.002.png

176 KB
Loading

assets/img/transfer-ownership.003.png

166 KB
Loading

site/_handle_dependencies_R.qmd

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
For the R community, Computo relies on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package manager to setup a reproducible environment that handles `R` dependencies. Setting up **renv** for use within your repository requires the following steps. First, you need to initialize your repository to work with **renv**. This is done by running:
2+
3+
```r
4+
# Initialize your repo to work with renv
5+
renv::init()
6+
```
7+
8+
The purpose of this function is to create a `renv.lock` file that registers the version of R and quarto along with all the packages and their versions that **renv** finds in your notebook.
9+
10+
Upon cloning one of our template however, the `renv.lock` file already exists. Therefore, when you execute `renv::init()`, you will be provided with the following choices:
11+
12+
```r
13+
> renv::init()
14+
This project already has a lockfile. What would you like to do?
15+
16+
1: Restore the project from the lockfile.
17+
2: Discard the lockfile and re-initialize the project.
18+
3: Activate the project without snapshotting or installing any packages.
19+
4: Abort project initialization.
20+
```
21+
22+
You should choose **Option 2**, which will extend the message box with:
23+
24+
```r
25+
- Linking packages into the project library ... Done!
26+
- Lockfile written to "~/Projects/computo/my-computo-submission/renv.lock".
27+
- renv activated -- please restart the R session.
28+
```
29+
30+
prompting you to restart your R session which you should do right away. If you now inspect the existing `renv.lock` file, you will see the R version you locally run on along with a bunch of packages listed there. This is because `template-computo-R.qmd` includes the **ggplot2** package by default to showcase how you can include plots in your paper. As a result, **renv** registers **ggplot2** along with all its dependencies in the `renv.lock` file.
31+
32+
Now you can write your contribution, using all the packages you need. Install the required dependencies as usual (via `install.packages()` or via the RStudio IDE) or using **renv** built-in `install()` function:
33+
34+
```r
35+
# Install packages you need
36+
renv::install("ggplot2") # or equivalently install.packages("ggplot2")
37+
```
38+
39+
Non-CRAN packages (*e.g.* Github packages) can be used. To install such packages, you need to first install the **remotes** package. Then, if you want to install the development version of *e.g.* the **gt** package hosted by `rstudio` GitHub account (useful for nicely and easily formatting tables btw), you would do:
40+
41+
```r
42+
install.packages("remotes")
43+
remotes::install_github("rstudio/gt")
44+
```
45+
46+
Once you are done, you need to freeze the environment and package versions that are going to be used to run the calculations within your paper. This is achieved via:
47+
48+
```r
49+
# Register environment and package versions
50+
renv::snapshot()
51+
```
52+
53+
::: {.callout-warning title="The `renv.lock` file"}
54+
The `renv.lock` should be versioned with git. Other files that `renv::snapshot()` might produce should be listed under `.gitignore` and therefore not put under versioning.
55+
:::
56+
57+
More details for using **renv** can be found:
58+
59+
- either on the [**renv**](https://rstudio.github.io/renv/articles/renv.html) package website,
60+
- or on the Quarto website at this [dedicated page](https://quarto.org/docs/projects/virtual-environments.html#using-renv).

site/_handle_dependencies_julia.qmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More to come.

site/_handle_dependencies_python.qmd

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
If you are writing a contribution that relies on Python code and Python packages, you can locally install and use those packages any way you like.
2+
3+
We then handle your Python package dependencies in our CI/CD scripts using [micromamba](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html), which requires that you ship a file called `environment.yml` that lists your dependencies. This file should be stored at the root of your repository. Here is the typical content of such a file:
4+
5+
```yml
6+
name: computo
7+
channels:
8+
- conda-forge
9+
dependencies:
10+
- python=3.11
11+
- jupyter
12+
- matplotlib
13+
- pandas
14+
- scipy
15+
- seaborn
16+
- scikit-learn
17+
- numpy=1.24
18+
- numba
19+
```
20+
21+
The `name:` entry
22+
23+
: You can choose a name of your liking. It should be short with no spaces and uniquely refer to the title or content of your contribution.
24+
25+
The `channels:` entry
26+
27+
: In most cases, you should leave it to the value `conda-forge`. Some advanced configurations for which you might want to reference other channels can be found by browsing our list of published papers [here](https://github.com/computorg?q=published&type=all&language=&sort=).
28+
29+
The `dependencies:` entry
30+
31+
: This is where you should list all your dependencies. It is good practice to list `python` itself so you can provide the version you used as done above. Other dependencies written in the outer list will be installed from the listed channel using micromamba. It is recommended to indicate which version was used as done above for **numpy** for instance. If your work relies on packages that have not been made available as conda packages, you can add a `pip` entry to the outer list and add those packages under the `pip:` list as in:
32+
33+
```yml
34+
name: clayton
35+
channels:
36+
- conda-forge
37+
dependencies:
38+
- jupyter
39+
- numpy
40+
- scipy
41+
- matplotlib
42+
- pandas
43+
- seaborn
44+
- pip:
45+
- clayton
46+
```
47+
48+
::: {.callout-note title="Automatic registration of packages"}
49+
Currently and differently from what we provide for R users, we do not have implemented an automatic way of registering environment, packages and their versions. Hence, you are expected to do that manually.
50+
:::
51+
52+
::: {.callout-tip title="`requirements.txt`"}
53+
If your work exclusively depends on packages installed from `pip` and you are used to listing dependencies in a `requirements.txt` file, you can ship this file instead of the `environment.yml` file and our CI/CD scripts should run smoothly.
54+
:::

0 commit comments

Comments
 (0)