Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NLeSC/guide into remove-testing-cha…
Browse files Browse the repository at this point in the history
…pter
  • Loading branch information
bouweandela committed Nov 8, 2023
2 parents 817bc8b + 0d1d86c commit 744abce
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 352 deletions.
4 changes: 0 additions & 4 deletions _sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* [Version Control](/best_practices/version_control.md)
* [Code Quality](/best_practices/code_quality.md)
* [Code Review](/best_practices/code_review.md)
* [Communication](/best_practices/communication.md)
* [Releases](/best_practices/releases.md)
* [Documentation](/best_practices/documentation.md)
* [Standards](/best_practices/standards.md)
Expand All @@ -18,6 +17,3 @@
* [C and C++](/best_practices/language_guides/ccpp.md)
* [Fortran](/best_practices/language_guides/fortran.md)
* [Contributing to this Guide](/CONTRIBUTING.md)
* NLeSC specific
* [Access to (Dutch) e-Infrastructure](/nlesc_specific/e-infrastructure/e-infrastructure.md)
* [DAS-5](/nlesc_specific/e-infrastructure/das5.md)
47 changes: 0 additions & 47 deletions best_practices/communication.md

This file was deleted.

4 changes: 2 additions & 2 deletions best_practices/language_guides/bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Here we list the most commonly used Bash tools that are built to manipulate
The nice thing about these tools is that you can combine them by streaming the
output of one tool to become the input of the next tool.
Have a look at the
[tutorial](https://swcarpentry.github.io/shell-novice/04-pipefilter/index.html)
[tutorial](https://swcarpentry.github.io/shell-novice/04-pipefilter.html)
for an introduction.
This can be done by creating
[pipelines](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Pipelines)
Expand Down Expand Up @@ -164,7 +164,7 @@ This will bring you all the advantages of a fully-fledged programming language
recommended programming language at the Netherlands eScience Center.
If you do not mind having an extra dependency and would like to use the features
and commands available in the shell from Python, the
[sh](https://amoffat.github.io/sh/) library is a nice option.
[sh](https://sh.readthedocs.io) library is a nice option.

Disclaimer: if you are an experienced Bash developer, there might be situations
where using a Bash script solves your problem faster or in a more portable way
Expand Down
29 changes: 15 additions & 14 deletions best_practices/language_guides/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Installation of packages that are not using `wheel`, but have a lot of non-Pytho
The disadvantage of Conda is that the package needs to have a Conda build recipe.
Many Conda build recipes already exist, but they are less common than the `setuptools` configuration that generally all Python packages have.

There are two main distributions of Conda: [Anaconda](https://docs.anaconda.com/anaconda/install/) and [Miniconda](https://docs.conda.io/projects/continuumio-conda/en/latest/user-guide/install/index.html). Anaconda is large and contains a lot of common packages, like numpy and matplotlib, whereas Miniconda is very lightweight and only contains Python. If you need more, the `conda` command acts as a package manager for Python packages.
There are two main "official" distributions of Conda: [Anaconda](https://docs.anaconda.com/anaconda/install/) and [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/) (and variants of the latter like miniforge, explained below).
Anaconda is large and contains a lot of common packages, like numpy and matplotlib, whereas Miniconda is very lightweight and only contains Python. If you need more, the `conda` command acts as a package manager for Python packages.
If installation with the `conda` command is too slow for your purposes, it is recommended that you use [`mamba`](https://github.com/mamba-org/mamba) instead.

For environments where you do not have admin rights (e.g. DAS-6) either Anaconda or Miniconda is highly recommended since the installation is very straightforward.
Expand All @@ -76,8 +77,8 @@ A possible downside of Anaconda is the fact that this is offered by a commercial
Do note that since 2020, [Anaconda has started to ask money from large institutes](https://www.anaconda.com/blog/anaconda-commercial-edition-faq) for downloading packages from their [main channel (called the `default` channel)](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/channels.html#what-is-a-conda-channel) through `conda`.
This does not apply to universities and most research institutes, but could apply to some government institutes that also perform research and definitely applies to large for-profit companies.
Be aware of this when choosing the distribution channel for your package.
An alternative installer that avoids this problem altogether because it only installs packages from `conda-forge` by default is [miniforge](https://github.com/conda-forge/miniforge).
There is also a mambaforge version that uses the faster `mamba` by default.
An alternative, community-driven Conda distribution that avoids this problem altogether because it only installs packages from `conda-forge` by default is [miniforge](https://github.com/conda-forge/miniforge).
Miniforge includes both the faster `mamba` as well as the traditional `conda`.

## Building and packaging code

Expand Down Expand Up @@ -107,7 +108,8 @@ pip install -e .
```
The `-e` flag will install your package in editable mode, i.e. it will create a symlink to your package in the installation location instead of copying the package. This is convenient when developing, because any changes you make to the source code will immediately be available for use in the installed version.

Set up continuous integration to test your installation setup. Use `pyroma` (can be run as part of `prospector`) as a linter for your installation configuration.
Set up continuous integration to test your installation setup.
You can use `pyroma` as a linter for your installation configuration.

### Packaging and distributing your package
For packaging your code, you can either use `pip` or `conda`. Neither of them is [better than the other](https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/) -- they are different; use the one which is more suitable for your project. `pip` may be more suitable for distributing pure python packages, and it provides some support for binary dependencies using [`wheels`](http://pythonwheels.com). `conda` may be more suitable when you have external dependencies which cannot be packaged in a wheel.
Expand Down Expand Up @@ -140,19 +142,18 @@ At the Netherlands eScience Center, some popular editors or IDEs are:

The style guide for Python code is [PEP8](http://www.python.org/dev/peps/pep-0008/) and for docstrings it is [PEP257](https://www.python.org/dev/peps/pep-0257/). We highly recommend following these conventions, as they are widely agreed upon to improve readability. To make following them significantly easier, we recommend using a linter.

Many linters exists for Python, [`prospector`](https://github.com/landscapeio/prospector) is a tool for running a suite of linters, it supports, among others:
Many linters exists for Python.
The most popular one is currently [Ruff](https://github.com/astral-sh/ruff).
Although it is new (see the website for the complete function parity comparison with alternatives), it works well and has an active community.
An alternative is [`prospector`](https://github.com/landscapeio/prospector), a tool for running a suite of linters, including, among others [pycodestyle](https://github.com/PyCQA/pycodestyle), [pydocstyle](https://github.com/PyCQA/pydocstyle), [pyflakes](https://pypi.python.org/pypi/pyflakes), [pylint](https://www.pylint.org/), [mccabe](https://github.com/PyCQA/mccabe) and [pyroma](https://github.com/regebro/pyroma).
Some of these tools have seen decreasing community support recently, but it is still a good alternative, having been a defining community default for years.

* [pycodestyle](https://github.com/PyCQA/pycodestyle)
* [pydocstyle](https://github.com/PyCQA/pydocstyle)
* [pyflakes](https://pypi.python.org/pypi/pyflakes)
* [pylint](https://www.pylint.org/)
* [mccabe](https://github.com/PyCQA/mccabe)
* [pyroma](https://github.com/regebro/pyroma)

Make sure to set strictness to `veryhigh` for best results. `prospector` has its own configuration file, like the [.prospector.yml default in the Python template](https://github.com/NLeSC/python-template/blob/main/%7B%7Bcookiecutter.directory_name%7D%7D/.prospector.yml), but also supports configuration files for any of the linters that it runs. Most of the above tools can be integrated in text editors and IDEs for convenience.
Most of the above tools can be integrated in text editors and IDEs for convenience.

Autoformatting tools like [`yapf`](https://github.com/google/yapf) and [`black`](https://black.readthedocs.io/en/stable/index.html) can automatically format code for optimal readability. `yapf` is configurable to suit your (team's) preferences, whereas `black` enforces the style chosen by the `black` authors. The [`isort`](http://timothycrosley.github.io/isort/) package automatically formats and groups all imports in a standard, readable way.

Ruff can do autoformatting as well and can function as a drop-in replacement of `black` and `isort`.


## Testing

Expand Down Expand Up @@ -291,7 +292,7 @@ It is good practice to restart the kernel and run the notebook from start to fin

### Database Interface

* [psycopg](http://initd.org/psycopg/) is an [PostgreSQL](http://www.postgresql.org) adapter
* [psycopg](https://www.psycopg.org/) is a [PostgreSQL](http://www.postgresql.org) adapter
* [cx_Oracle](http://cx-oracle.sourceforge.net) enables access to [Oracle](https://www.oracle.com/database/index.html) databases
* [monetdb.sql](https://www.monetdb.org/Documentation/SQLreference/Programming/Python)
is [monetdb](https://www.monetdb.org) Python client
Expand Down
14 changes: 7 additions & 7 deletions best_practices/language_guides/r.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What is R?

*Page maintainer: unmaintained*
*Page maintainer: Malte Lüken* [@maltelueken](https://github.com/maltelueken)


R is a functional programming language and software environment for statistical computing and graphics: https://www.r-project.org/.
Expand All @@ -11,7 +11,7 @@ R is particularly popular in the social, health, and biological sciences where i
One of the strengths of R is the large number of available open source statistical packages, often developed by domain experts. For example, R-package [Seewave](http://rug.mnhn.fr/seewave/) is specialised in sound analyses. Packages are typically released on CRAN [The Comprehensive R Archive Network](http://cran.r-project.org).

A few remarks for readers familiar with Python:
* Compared with Python, R does not need a notebook to program interactively. In [RStudio](https://www.rstudio.com/), an IDE that is installed separately, the user can run sections of the code by selecting them and pressing Ctrl+Enter. Consequently the user can quickly transition from working with scripts to working interactively using the Ctrl+Enter.
* Compared with Python, R does not need a notebook to program interactively. In [RStudio](https://posit.co/products/open-source/rstudio/), an IDE that is installed separately, the user can run sections of the code by selecting them and pressing Ctrl+Enter. Consequently the user can quickly transition from working with scripts to working interactively using the Ctrl+Enter.
* Numbering in R starts with 1 and not with 0.

### Recommended sources of information
Expand All @@ -30,7 +30,7 @@ To install R check detailed description at [CRAN website](http://cran.r-project.
#### IDE
R programs can be written in any text editor. R code can be run from the command line or interactively within R environment, that can be started with `R` command in the shell. To quit R environment type `q()`.

[RStudio](http://www.rstudio.com/products/RStudio/) is a free powerful integrated development environment (IDE) for R. It features editor with code completion, command line environment, file manager, package manager and history lookup among others. You will have to install RStudio in addition to installing R. Please note that updating RStudio does not automatically update R and the other way around.
[RStudio](https://posit.co/products/open-source/rstudio/) is a free powerful integrated development environment (IDE) for R. It features editor with code completion, command line environment, file manager, package manager and history lookup among others. You will have to install RStudio in addition to installing R. Please note that updating RStudio does not automatically update R and the other way around.

Within RStudio you can work on ad-hoc code or create a project. Compared with Python an R project is a bit like a virtual environment as it preserves the workspace and installed packages for that project. Creating a project is needed to build an R package. A project is created via the menu at the top of the screen.

Expand Down Expand Up @@ -71,7 +71,7 @@ However, externally contributed plotting packages may offer easier syntax or con
In summary, it is good to familiarize yourself with both the basic plotting functions as well as the contributed graphics packages. In theory, the basic plot functions can do everything that ggplot2 can do, it is mostly a matter of how much you like either syntax and how much freedom you need to tailor the visualisation to your use case.

## Building interactive web applications with shiny
Thanks to [shiny.app](http://shiny.rstudio.com) it is possible to make interactive web application in R without the need to write javascript or html.
Thanks to [shiny.app](https://shiny.posit.co/) it is possible to make interactive web application in R without the need to write javascript or html.

## Building reports with knitr
[knitr](https://yihui.name/knitr/) is an R package designed to build dynamic reports in R. It's possible to generate on the fly new pdf or html documents with results of computations embedded inside.
Expand Down Expand Up @@ -116,8 +116,8 @@ R function documentation offers plenty of space to document the functionality, i

# Available templates
* https://rapporter.github.io/rapport/
* http://shiny.rstudio.com/articles/templates.html
* http://rmarkdown.rstudio.com/developer_document_templates.html
* https://shiny.posit.co/r/articles/build/templates/
* https://bookdown.org/yihui/rmarkdown/document-templates.html

# Testing, Checking, Debugging and Profiling

Expand All @@ -130,7 +130,7 @@ See also [checking](http://r-pkgs.had.co.nz/check.html) and [testing](http://r-p
[Continuous integration](https://the-turing-way.netlify.app/reproducible-research/ci) should be done with an online service.

### Debugging and Profiling
Debugging is possible in RStudio, see [link](https://support.rstudio.com/hc/en-us/articles/205612627-Debugging-with-RStudio). For profiling tips see [link](http://adv-r.had.co.nz/Profiling.html)
Debugging is possible in RStudio, see [link](https://support.posit.co/hc/en-us/articles/205612627-Debugging-with-RStudio). For profiling tips see [link](http://adv-r.had.co.nz/Profiling.html)


# Not in this tutorial yet:
Expand Down
6 changes: 3 additions & 3 deletions lychee.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lychee configuration file
# See https://github.com/lycheeverse/lychee/blob/master/lychee.example.toml
exclude_all_private = true
exclude_mail = true
progress = false
verbose = true
include_mail = false
no_progress = true
verbose = "info"
Loading

0 comments on commit 744abce

Please sign in to comment.