Skip to content

Commit 494f190

Browse files
committed
first version of the Python-based new template
0 parents  commit 494f190

File tree

7 files changed

+451
-0
lines changed

7 files changed

+451
-0
lines changed

.github/workflows/build_n_publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Computo Build and Publish for Python
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: main
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v2
16+
17+
- name: Set up quarto
18+
uses: quarto-dev/quarto-actions/setup@v2
19+
with:
20+
tinytex: true
21+
version: pre-release
22+
23+
- name: Install Computo extension for Quarto
24+
run: |
25+
quarto add --no-prompt computorg/computo-quarto-extension
26+
27+
- name: Install Python and Dependencies
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.10'
31+
cache: 'pip'
32+
- run: pip install -r requirements.txt
33+
34+
- name: Render and Publish
35+
uses: quarto-dev/quarto-actions/publish@v2
36+
with:
37+
target: gh-pages
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*_files/
2+
template-computo-python.html
3+
logo_text_white.pdf
4+
template-computo-python.pdf
5+
template-computo-python.ipynb
6+
template-computo-python.tex
7+
_extensions/
8+
/.quarto/
9+
/.joblib
10+
/_extensions/

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
# Template for contribution to Computo for Python users
3+
4+
[![build output](https://github.com/computorg/template-computo-python/workflows/build/badge.svg)](https://computorg.github.io/template-computo-python/)
5+
6+
Documentation and sample of a simple `Python`-based submission for the [Computo journal](https://computorg.github.io), using our Quarto-based template and `venv` for handling dependencies.
7+
8+
Shows how to automatically setup and build the HTML and PDF outputs, ready to submit to our peer-review platform.
9+
10+
Additional details can be found [in the template manuscript](https://computo.sfds.asso.fr/template-computo-python).
11+
12+
## Process overview
13+
14+
Submissions to [Computo](https://computorg.github.io) require both scientific content (typically equations, codes and figures, data) and a proof that this content is reproducible. This is achieved by means of i) a notebook system, ii) a virtual environment fixing the dependencies and iii) continuous integration (plus, if needed, an external website to store large data files such a [Zenodo](https://zenodo.org/) or [OSF](https://osf.io/) ).
15+
16+
A Computo submission is thus a git(hub) repository like this one containing
17+
18+
- the source files of the notebook (a quarto .qmd file + a BibTeX .bib file + some statics files, _e.g._ figures or small .csv data tables)
19+
- configuration files to set up the dependencies in a virtual environment
20+
- configuration files to set up the continuous integration rendering the final documents
21+
22+
In this template, we focus on `R` users and detail a solution based on
23+
24+
- The `Jupyter` kernel of Quarto for rendering the document,
25+
- The `venv` Python built system for setting the virtual environment,
26+
- Github actions for handling the continuous integration.
27+
28+
## Step-by-step procedure
29+
30+
### Step 0: setup a git repository
31+
32+
Use this repository as a template via the "use this template" button on the top of this page.
33+
34+
**Note**: _You can use Gitlab for submitting for Computo. We hope giving more support in the future._
35+
36+
### Step 1. setup Quarto and Computo extension on your system
37+
38+
You need [quarto](https://quarto.org/) installed on your computer, as well as the [Computo extension](https://github.com/computorg/computo-quarto-extension) to prepare your document.
39+
The latter can be installed as follows:
40+
41+
```.bash
42+
quarto add computorg/computo-quarto-extension
43+
```
44+
45+
### Step 2. write your contribution
46+
47+
Write your notebook as usual, [as demonstrated in the `template-computo-python.qmd` sample](https://computorg.github.io/template-computo-python/).
48+
49+
**Note**: _Make sure that you are able to build your manuscript as a standard notebook on your system before proceeding to the next step._
50+
51+
### Step 3: setup dependencies with `venv`
52+
53+
Use the [`venv` package manager](https://cewing.github.io/training.python_web/html/presentations/venv_intro.html) to setup a reproducible environment handling your `Python` dependencies.
54+
55+
### Step 4: proof reproducibility
56+
57+
Put everything together and check that your work is indeed reproducible. To this end, you need to rely on a github action, whose default is pre-configured and found here: [.github/workflows/build_n_publish.yml](https://github.com/computorg/template-computo-R/blob/main/.github/workflows/build_n_publish.yml)
58+
59+
This action will
60+
61+
1. Check out repository on the ubuntu-latest machine
62+
2. Install quarto and dependencies, including the Computo extension for Quarto
63+
4. Install Python dependencies with `pip` and `venv`, using your `requirements.txt` file
64+
5. Render your .qmd file and Publish the results on a gh-page (both HTML and PDF)
65+
66+
**Note**: _Gitlab CI can be used to obtained similar results._
67+
68+
### Step 5. submit
69+
70+
Once step 4 is successful, you should end up with an HTML version published as a gh-page, as well as a PDF version (see "Other format" at the end of the table of content of the rendered HTML). This PDF version can be submitted to the [Computo submission platform](https://computo.scholasticahq.com/):
71+
72+
<div id="scholastica-submission-button" style="margin-top: 10px; margin-bottom: 10px;"><a href="https://computo.scholasticahq.com/for-authors" style="outline: none; border: none;"><img style="outline: none; border: none;" src="https://s3.amazonaws.com/docs.scholastica/law-review-submission-button/submit_via_scholastica.png" alt="Submit to Computo"></a></div>

_quarto.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project:
2+
title: "template-computo-R"
3+
4+
5+

references.bib

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@Preamble{ " \newcommand{\noop}[1]{} " }
2+
3+
@Manual{R-reticulate,
4+
title = {reticulate: Interface to Python},
5+
author = {Kevin Ushey and JJ Allaire and Yuan Tang},
6+
year = {2020},
7+
note = {R package version 1.18},
8+
url = {https://github.com/rstudio/reticulate},
9+
}
10+
11+
@article{computo,
12+
title = {Computo: reproducible computational/algorithmic contributions in statistics and machine learning},
13+
author = {{Computo Team}},
14+
year = {2020},
15+
}
16+
17+
@Manual{R-base,
18+
title = {R: A Language and Environment for Statistical Computing},
19+
author = {{R Core Team}},
20+
organization = {R Foundation for Statistical Computing},
21+
address = {Vienna, Austria},
22+
year = {2020},
23+
url = {https://www.R-project.org/},
24+
}
25+

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jupyter
2+
matplotlib
3+
numpy

0 commit comments

Comments
 (0)