|
2 | 2 |
|
3 | 3 | ## About this document |
4 | 4 |
|
5 | | -This document, accompanied by the [customized GitHub repository](https://github.com/computorg/template-computo-python/), provides a template for writing contributions to **Computo** [@computo]. We show how `Python` code can be included and how the repository can be set up for triggering GitHub actions for rendering the document, with dependencies handled by `venv` and `pip`. |
| 5 | +This document, accompanied by the [customized GitHub repository](https://github.com/computorg/template-computo-python/), provides a template for writing contributions to **Computo** [@computo]. |
6 | 6 |
|
7 | | -## Setup a GitHub repository for preparing your submission |
8 | | - |
9 | | -You can start by clicking on the **"use this template"** button, on the top of the page of the [github repository associated with this document](https://github.com/computorg/template-computo-python/). Of course, you can set your repository private during the preparation of your manuscript. |
| 7 | +::: {.callout-tip} |
| 8 | +## Note |
| 9 | +This document provides only the key formatting principles. For a detailed, step-by-step guide on preparing your article and submitting it to Computo, please consult the [guidelines for authors](https://computo-journal.org/site/guidelines-authors.html). |
| 10 | +::: |
10 | 11 |
|
11 | 12 | ## Quarto |
12 | 13 |
|
13 | 14 | [Quarto](https://quarto.org/) is a versatile formatting system for authoring documents integrating markdown, LaTeX and code blocks interpreted either via Jupyter or Knitr (thus supporting Python, R and Julia). It relies on the [Pandoc](https://pandoc.org/MANUAL.html) document converter. |
14 | 15 |
|
15 | 16 | ## Requirements |
16 | 17 |
|
17 | | -You need [quarto](https://quarto.org/docs/get-started/) installed on your system and the [Computo extension](https://github.com/computorg/computo-quarto-extension) to prepare your document. For the latter, once quarto is installed, run the following to install the extension in the current directory (it creates an `_extension` directory which is ignored by git thanks to `.gitignore` by default): |
| 18 | +You need [quarto](https://quarto.org/) installed on your system and the [Computo extension](https://github.com/computorg/computo-quarto-extension) to prepare your document. For the latter, once quarto is installed, run the following to install the extension in the current directory (it creates a `_extension` directory which is ignored by git thanks to `.gitignore` by default): |
18 | 19 |
|
19 | 20 | ```.bash |
20 | 21 | quarto add computorg/computo-quarto-extension |
21 | 22 | ``` |
22 | 23 |
|
23 | 24 | [`Python`](https://www.python.org/) and [`Jupyter`](https://jupyter.org/install) must be installed on your computer. |
24 | 25 |
|
25 | | -## Link with your usual tools |
26 | | - |
27 | | -Quarto is expecting a `.qmd` markdown file, but will also works with a standard [Jupyter notebook](https://quarto.org/docs/get-started/hello/jupyter.html) file if you are used to it (it will just require to add the proper YAML metadata^[the same metadata as in the [`template-computo-python.qmd` file](https://github.com/computorg/template-computo-python/blob/main/template-computo-python.qmd) in the first cell, type "Raw", of the notebook]). |
28 | | - |
29 | | -**Note**: _More advanced Jupyter-related functionality like Myst/Jupyter book are not supported in this Quarto setup. The markdown syntax inside the Jupyter notebook should follow the Quarto syntax (c.f. [below](#formatting)). If you are more comfortable with using Myst/Jupyter book, we provide a [specific template](https://github.com/computorg/template-computo-myst) but it will requires more formatting work for Computo editorial team, thus highly encourage authors to use the Quarto templates._ |
30 | | - |
31 | 26 | # Formatting |
32 | 27 |
|
33 | 28 | This section covers basic formatting guidelines for quarto documents. |
34 | 29 |
|
35 | 30 | To render a document, run `quarto render`. By default, both PDF and HTML documents are generated: |
36 | 31 |
|
37 | 32 | ```.bash |
38 | | -quarto render template-computo-python.qmd # renders both HTML and PDF |
| 33 | +quarto render # renders both HTML and PDF |
39 | 34 | ``` |
40 | 35 |
|
41 | 36 | ::: {.callout-tip} |
@@ -196,83 +191,6 @@ Advanced formatting features are possible and documented (including interactive |
196 | 191 |
|
197 | 192 | ::: |
198 | 193 |
|
199 | | -# Finalize your submission |
200 | | - |
201 | | -## Handle `Python` dependencies with `venv` |
202 | | - |
203 | | -To make your work reproducible, you need to fix the packages and environment used to run your analysis. For `Python`, `venv` is one of the possible reliable method, supported by the community. You basically need a couple of commands to setup your environment on your local machine. First, to create a new virtual environment in the directory `my_env` |
204 | | - |
205 | | -``` .bash |
206 | | -python3 -m venv my_env |
207 | | -``` |
208 | | - |
209 | | -and activate it |
210 | | - |
211 | | -``` .bash |
212 | | -source my_env/bin/activate |
213 | | -``` |
214 | | - |
215 | | -Then installed the packages required to perform your analysis. Here, |
216 | | - |
217 | | -``` .bash |
218 | | -python3 -m pip install jupyter matplotlib numpy |
219 | | -``` |
220 | | - |
221 | | -Once you are all set up, you need to save your working environment into a file so that anyone can reproduce your analysis on their side: |
222 | | - |
223 | | -``` .bash |
224 | | -python3 -m pip freeze > requirements.txt |
225 | | -``` |
226 | | - |
227 | | -The corresponding `requirements.txt` file [found in this repository](https://github.com/computorg/template-computo-python/blob/main/requirements.txt) is then |
228 | | - |
229 | | -```{.bash filename="requirements.txt"} |
230 | | -jupyter |
231 | | -matplotlib |
232 | | -numpy |
233 | | -``` |
234 | | - |
235 | | -::: {.callout-important} |
236 | | -`requirements.txt` is the only file that needs to be versioned by git. |
237 | | -::: |
238 | | - |
239 | | -More details for using `venv` and `pip` can be found on the [quarto page dedicated to environments](https://quarto.org/docs/projects/virtual-environments.html#using-venv). |
240 | | - |
241 | | -### What about `conda`? |
242 | | - |
243 | | -For `conda` users, it is also possible to follow the same path with your favorite version of `conda`. There is a [quarto page dedicated to the conda environments](https://quarto.org/docs/projects/virtual-environments.html#using-conda). |
244 | | - |
245 | | -## Continuous integration |
246 | | - |
247 | | -The repository associated with this template is pre-configured to trigger an action on push that performs the following: |
248 | | - |
249 | | -1. Check out the repository on an `ubuntu-latest` machine |
250 | | -2. Install quarto and dependencies, including the Computo extension |
251 | | -3. Install Python (3.10) and dependencies with `venv`, using your `requirements.txt` file |
252 | | -4. Render your .qmd file and Publish the results on a gh-page (both HTML and PDF) |
253 | | - |
254 | | -The file [.github/workflows/build_n_publish.yml](https://github.com/computorg/template-computo-python/blob/main/.github/workflows/build_n_publish.yml) is largely inspired from [this file](https://quarto.org/docs/publishing/github-pages.html#example-jupyter-with-venv). |
255 | | - |
256 | | -Once this is successful, you are ready to submit your manuscript to the [Computo submission platform](https://computo.scholasticahq.com/). |
257 | | - |
258 | | -::: {.callout-warning} |
259 | | -The first time, you possibly need to create the branch for the action to work. This can be done by running the following command from your computer, in your git repository: |
260 | | - |
261 | | -```.bash |
262 | | -quarto publish gh-pages |
263 | | -``` |
264 | | - |
265 | | -Then, set the branch `gh-page` as the source of your github page, and trigger the action to check that everything works fine. |
266 | | -::: |
267 | | - |
268 | | -### What about CI and `conda`? |
269 | | - |
270 | | -[The build and deploy process of our Computo quarto extension](https://github.com/computorg/computo-quarto-extension/blob/main/.github/workflows/build.yml) shows how `miniconda` can be set used in place of `venv`. The main striking difference is the use of a `environment.yml` file in place of `requirements.txt`. |
271 | | - |
272 | | -## Data and large files |
273 | | - |
274 | | -If your submission materials contain files larger than 50MB, **especially data files**, they won’t fit on a git repository as is. For this reason, we encourage you to put your data or any materials you deem necessary on an external “open data” centered repository hub such a [Zenodo](https://zenodo.org/) or [OSF](https://osf.io/). |
275 | | - |
276 | 194 | # References {.unnumbered} |
277 | 195 |
|
278 | 196 | ::: {#refs} |
|
0 commit comments