From 21650d4d9e25b2ad13c7dfb6a73cb8906272903d Mon Sep 17 00:00:00 2001 From: Feridun Mert Celebi Date: Wed, 3 Jan 2024 11:56:57 -0500 Subject: [PATCH 01/12] v0 of the template --- .github/PULL_REQUEST_TEMPLATE.md | 17 +++++++ .github/workflows/lint.yml | 31 ++++++++++++ .gitignore | 84 ++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 23 +++++++++ .vscode/extensions.json | 5 ++ LICENSE | 21 ++++++++ Makefile | 12 +++++ README.md | 40 +++++++++++++++ envs/dev.yml | 10 ++++ pyproject.toml | 56 +++++++++++++++++++++ 10 files changed, 299 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/lint.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .vscode/extensions.json create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 envs/dev.yml create mode 100644 pyproject.toml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0c78073 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ + + +## PR checklist + +- [ ] Tag the issue(s) or milestones this PR fixes (e.g. `Fixes #123, Resolves #456`). +- [ ] Describe the changes you've made. +- [ ] Describe any tests you have conducted to confirm that your changes behave as expected. +- [ ] If you've added new software dependencies, make sure that those dependencies are included in the appropriate `conda` environments. +- [ ] If you've added new functionality, make sure that the documentation is updated accordingly. +- [ ] If you encountered bugs or features that you won't address, but should be addressed eventually, create new issues for them. diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..22a3462 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: lint + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + pip install pre-commit==3.5.0 ruff==0.1.6 + + - name: Run Ruff + run: ruff check --output-format=github . + + - name: Run Ruff formatter + run: ruff format --check . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eeb440c --- /dev/null +++ b/.gitignore @@ -0,0 +1,84 @@ +# packages installed in editable mode +envs/src/** + +# Snakemake-related folders and files +.snakemake/ +/input/ +/output/ +/demo/output/ +/demo/input/ +/logs + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +.napari_cache + +# Translations +*.mo +*.pot + +# Sphinx documentation +docs/_build/ + +# MkDocs documentation +/site/ + +# PyBuilder +target/ + +# Pycharm and VSCode +.idea/ +venv/ + +# Jupyter notebook checkpoints +.ipynb_checkpoints + +# pyenv +.python-version + +# OS +.DS_Store + +# written by setuptools_scm +**/_version.py + +# Nextflow related folders and files +.nextflow* +work/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c979e1e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +exclude: (examples|demo|dev|input|output) +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-yaml + - id: check-toml + - id: check-json + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: debug-statements + - id: trailing-whitespace + - id: mixed-line-ending + - id: end-of-file-fixer + - id: requirements-txt-fixer + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.6 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..4d920f7 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": ["charliermarsh.ruff"] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..af434fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Arcadia Science + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b7d13df --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: lint +lint: + ruff --exit-zero check . + +.PHONY: format +format: + ruff --fix . + ruff format . + +.PHONY: pre-commit +pre-commit: + pre-commit run --all-files diff --git a/README.md b/README.md new file mode 100644 index 0000000..3dd35a1 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# TODO: Replace with the name of the repo + +Note: Analysis repo names should be prefixed with the year (ie `2024-noveltree-analysis`) + +## Purpose + +## Installation and Setup + +This repository uses conda to manage software environments and installations. You can find operating system-specific instructions for installing miniconda [here](https://docs.conda.io/projects/miniconda/en/latest/). After installing conda and [mamba](https://mamba.readthedocs.io/en/latest/), run the following command to create the pipeline run environment. + +```{bash} +TODO: Replace with the name of your environment +mamba env create -n --file envs/dev.yml +conda activate +``` + +## Data + +TODO: Add details about the description of input / output data and links to Zenodo depositions, if applicable. + +## Overview + +### Description of the folder structure + +### Methods + +TODO: Include a brief, step-wise overview of analyses performed. + +> Example: +> +> 1. Download scripts using `download.ipynb`. +> 2. Preprocess using `./preprocessing.sh -a data/` +> 3. Run Snakemake pipeline `snakemake --snakefile Snakefile` +> 4. Generate figures using `pub/make_figures.ipynb`. + +### Compute Specifications + +## Contributing + +See how we recognize [feedback and contributions to our code](https://github.com/Arcadia-Science/arcadia-software-handbook/blob/main/guides-and-standards/guide-credit-for-contributions.md). diff --git a/envs/dev.yml b/envs/dev.yml new file mode 100644 index 0000000..95245e9 --- /dev/null +++ b/envs/dev.yml @@ -0,0 +1,10 @@ +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - jupyter=1.0.0 + - pip=23.2.1 + - pre-commit=3.5.0 + - python=3.12.0 + - ruff=0.1.6 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..acc7209 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ +[project] +name = "TODO: Tool name" +description = "TODO: Tool description" +version = "0.0.0" +readme = "README.md" +requires-python = ">=3.9" +license = { file = "LICENSE" } + + +[tool.ruff] +# The directories to consider when resolving first- vs. third-party imports +src = ["."] + +line-length = 100 +indent-width = 4 + +# run ruff on jupyter notebooks (this is not enabled by default) +extend-include = ["*.ipynb"] + +[tool.ruff.per-file-ignores] +# ignore star and unused imports +"__init__.py" = ["F403", "F405"] + +[tool.ruff.lint] +select = [ + # flake8-bugbear + "B", + # pycodestyle error + "E", + # pyflakes + "F", + # isort + "I", + # pyupgrade + "UP", + # pycodestyle warning + "W", +] + +# rule codes to ignore +ignore = [] + +# Allows fix for all enabled rules when `--fix` is provided +fixable = ["ALL"] +unfixable = [] + +[tool.ruff.format] +# Like Black, use double quotes, indent with spaces, and respect trailing commas +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" + +[tool.ruff.lint.isort] +order-by-type = true +no-lines-before = ["future", "standard-library"] From 30c897a05e9f510bfdc53cf5d2e494fe6f2abaa9 Mon Sep 17 00:00:00 2001 From: Dennis August Sun Date: Wed, 3 Jan 2024 15:31:40 -0800 Subject: [PATCH 02/12] Documentation suggestions (#1) * making suggestions to the README * more small changes * added some description of the template features * mention formatting * add button * direct conda button to miniconda * Update README.md Co-authored-by: Feridun Mert Celebi Signed-off-by: Dennis August Sun * addressing PR comments --------- Signed-off-by: Dennis August Sun Co-authored-by: Feridun Mert Celebi --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 3dd35a1..73dbc88 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ # TODO: Replace with the name of the repo +[![run with conda](http://img.shields.io/badge/run%20with-conda-3EB049?labelColor=000000&logo=anaconda)](https://docs.conda.io/projects/miniconda/en/latest/) + Note: Analysis repo names should be prefixed with the year (ie `2024-noveltree-analysis`) ## Purpose +TODO: Briefly describe the core analyses performed in the repository and the motivation behind them. + ## Installation and Setup This repository uses conda to manage software environments and installations. You can find operating system-specific instructions for installing miniconda [here](https://docs.conda.io/projects/miniconda/en/latest/). After installing conda and [mamba](https://mamba.readthedocs.io/en/latest/), run the following command to create the pipeline run environment. @@ -14,6 +18,15 @@ mamba env create -n --file envs/dev.yml conda activate ``` +**Tips for Developers** + +You can use the following command to export your current conda environment to a `yml` file. +This command will only export the packages that you have installed directly, not the ones that were installed as dependencies. When you're ready to share, please delete this section. + +```{bash} +conda env export --from-history --no-builds > envs/dev.yml +``` + ## Data TODO: Add details about the description of input / output data and links to Zenodo depositions, if applicable. @@ -35,6 +48,28 @@ TODO: Include a brief, step-wise overview of analyses performed. ### Compute Specifications +TODO: Describe what compute resources were used to run the analysis. For example, you could list the operating system, number of cores, RAM, and storage space. + ## Contributing See how we recognize [feedback and contributions to our code](https://github.com/Arcadia-Science/arcadia-software-handbook/blob/main/guides-and-standards/guide-credit-for-contributions.md). + +--- +## For Developers + +This section contains information for developers who are working off of this template. Please delete this section when you're ready to share your repository. + +### GitHub templates +This template uses GitHub templates to provide checklists when making new pull requests. These templates are stored in the [.github/](./.github/) directory. + +### VSCode +This template includes recommendations to VSCode users for extensions, particularly the `ruff` linter. These recommendations are stored in `.vscode/extensions.json`. When you open the repository in VSCode, you should see a prompt to install the recommended extensions. + +### `.gitignore` +This template uses a `.gitignore` file to prevent certain files from being committed to the repository. + +### `pyproject.toml` +`pyproject.toml` is a configuration file to specify your project's metadata and to set the behavior of other tools such as linters, type checkers etc. You can learn more [here](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) + +### Linting +This template automates linting and formatting using GitHub Actions and the `ruff` linter. When you push changes to your repository, GitHub will automatically run the linter and report any errors, blocking merges until they are resolved. From 2d135c747afc28d80c2afb0905e1f7737fd73876 Mon Sep 17 00:00:00 2001 From: Keith Cheveralls Date: Tue, 5 Mar 2024 10:16:55 -0800 Subject: [PATCH 03/12] Fix typo in makefile (#2) Signed-off-by: Keith Cheveralls --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b7d13df..27ee6a2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: lint lint: - ruff --exit-zero check . + ruff check --exit-zero . .PHONY: format format: From c7f02644bc345b96208d707864de145665f015ae Mon Sep 17 00:00:00 2001 From: Evan Kiefl Date: Mon, 29 Apr 2024 10:53:46 -0700 Subject: [PATCH 04/12] Add note about running `pre-commit install` (#3) * Add note about running `pre-commit install` * Clarify where to edit pull request template - Users of this template will likely see this message for the first time when they open up a PR and not know what to edit. * Update README.md Co-authored-by: Keith Cheveralls Signed-off-by: Evan Kiefl * Explain conda env export flags --------- Signed-off-by: Evan Kiefl Co-authored-by: Keith Cheveralls --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- README.md | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0c78073..6405958 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@