Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues appearing after deploment of PR #293 #299

Merged
merged 12 commits into from
Jan 4, 2024
Merged
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space

[*.{md,yml,yaml,cff}]
indent_size = 2
5 changes: 4 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ aa673cb40c34a2481d6f864c6d67ffac9a2b6a16

# 231212, Autoformatting using ruff with expanded rule set //AKe
fe13c30f4a7f588a29556af37a3545b5662eb4f2
6899e33d965291455c36c8eff83ed5cc68cd478f
6899e33d965291455c36c8eff83ed5cc68cd478f

# 240104, Autoformatting using Prettier //AKe
e22265e0cacd51c3239a790e3c2c9acf7c34be4a
2 changes: 1 addition & 1 deletion .github/pr_labels.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '1'
version: "1"
invalidStatus: "pending"
labelRule:
values:
Expand Down
79 changes: 78 additions & 1 deletion .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: lint-code
on: [push]
on: [push, pull_request]

# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
# Use ruff to check for code style violations
ruff-check:
Expand Down Expand Up @@ -56,3 +62,74 @@ jobs:
- name: mypy --> Static type checking
# Configured in pyprojet.toml
run: mypy **/*.py

# Use pipreqs to check for missing dependencies
pipreqs-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install pipreqs
run: pip install pipreqs

- name: Install requirements
run: pip install -r requirements.txt

- name: Run pipreqs
run: pipreqs --savepath pipreqs.txt

- name: Compare requirements
run: |
# Extract and sort package names
awk '{print $1}' $1 | sort -u > "$1".compare
awk -F'==' '{print $1}' $2 | sort -u > "$2".compare

# Compare package lists
if cmp -s "$1".compare "$2".compare
then
echo "Requirements are the same"
exit 0
else
echo "Requirements are different"
exit 1
fi

# Use Prettier to check various file formats
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier

- name: Run Prettier --check
run: prettier --check .

# Use editorconfig to check all remaining file formats
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install editorconfig-checker
run: npm install -g editorconfig-checker

- name: editorconfig --> Lint files
run: editorconfig-checker $(git ls-files | grep -v '.py\|.md\|.json\|.yml\|.yaml\|.html')
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ build/
.ipynb_checkpoints/
.*_cache/
*.swp
__pycache__
__pycache__
25 changes: 17 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# .pre-commit-config.yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.7.1'
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.7.1"
hooks:
- id: mypy
additional_dependencies: [
- id: mypy
additional_dependencies:
[
types-Markdown,
types-PyYAML,
types-requests,
types-setuptools,
types-tabulate,
]
]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "3.0.3"
hooks:
- id: prettier
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: "2.7.2"
hooks:
- id: editorconfig-checker
55 changes: 48 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# scilifelab_epps

Collection of EPPs for the Scilifelab Stockholm node.

Table of contents
- [scilifelab\_epps](#scilifelab_epps)

- [scilifelab_epps](#scilifelab_epps)
- [Overview](#overview)
- [Installation](#installation)
- [Development](#development)
Expand All @@ -12,41 +14,78 @@ Table of contents
- [VS Code automation](#vs-code-automation)
- [Git blame suppression](#git-blame-suppression)


## Overview

The repo is installed inside a designated conda environment on a server hosting Illumina Clarity LIMS.

After installation, the scripts in `scripts/` are addded to the `bin` of the Conda environment, from which they can be called by LIMS.

## Installation

Inside the repo, run `pip install .`

## Development

Run `pip install requirements-dev.txt` to install packages used for development and `pip install -e .` to make the installation editable.

### Automated linting

This repo is configured for automated linting. Linter parameters are defined in `pyproject.toml`.

As of now, we use:

- [ruff](https://docs.astral.sh/ruff/) to perform automated formatting and a variety of lint checks.
- Run with `ruff check .` and `ruff format .`
- [mypy](https://mypy.readthedocs.io/en/stable/) for static type checking and to prevent contradictory type annotation.
- Run with `mypy **/*.py`
- [pipreqs](https://github.com/bndr/pipreqs) to check that the requirement files are up-to-date with the code.

- This is run with a custom Bash script in GitHub Actions which will only compare the list of package names.

```
# Extract and sort package names
awk '{print $1}' $1 | sort -u > "$1".compare
awk -F'==' '{print $1}' $2 | sort -u > "$2".compare

# Compare package lists
if cmp -s "$1".compare "$2".compare
then
echo "Requirements are the same"
exit 0
else
echo "Requirements are different"
exit 1
fi
```

- [prettier](https://prettier.io/) to format common languages.
- Run with `prettier .`
- [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) to enforce `.editorconfig` rules for all files not covered by the tools above.
- Run with
```
editorconfig-checker $(git ls-files | grep -v '.py\|.md\|.json\|.yml\|.yaml\|.html')
```

#### [GitHub Actions](https://docs.github.com/en/actions)
Configured in `.github/workflows/lint-code.yml`. Will test all pushed commits, but not change code or prevent merges.

Configured in `.github/workflows/lint-code.yml`. Will test all commits in pushes or pull requests, but not change code or prevent merges.

#### [Pre-commit](https://pre-commit.com/)

Will prevent local commits that fail linting checks. Configured in `.pre-commit-config.yml`.

To set up pre-commit checking:
1) Run `pip install pre-commit`
2) Navigate to the repo root
3) Run `pre-commit install`

1. Run `pip install pre-commit`
2. Navigate to the repo root
3. Run `pre-commit install`

This can be disabled with `pre-commit uninstall`

#### VS Code automation

To enable automated linting in VS Code, go the the user `settings.json` and include the following lines:

```
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
Expand All @@ -56,13 +95,15 @@ To enable automated linting in VS Code, go the the user `settings.json` and incl
This will run the `ruff`-mediated linting with the same parameters as the `GitHub Actions` and `pre-commit` every time VS Code is used to format the code in the repository.

To run formatting on save, include the lines:

```
"[python]": {
"editor.formatOnSave": true,
}
```

### Git blame suppression

When a non-invasive tool is used to tidy up a lot of code, it is useful to supress the Git blame for that particular commit, so the original author can still be traced.

To do this, add the hash of the commit containing the changes to `.git-blame-ignore-revs`, headed by an explanatory comment.
To do this, add the hash of the commit containing the changes to `.git-blame-ignore-revs`, headed by an explanatory comment.
8 changes: 4 additions & 4 deletions data/QC_criteria.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
}
},
"Finished library (by user)": {
"MiSeq":{
"MiSeq": {
"default": {
"default": {
"Concentration": 2,
Expand All @@ -208,7 +208,7 @@
"Concentration": 2,
"Volume (ul)": 110
},
"XP clustering":{
"XP clustering": {
"Concentration": 1.5,
"Volume (ul)": 25
}
Expand All @@ -218,7 +218,7 @@
"Concentration": 2,
"Volume (ul)": 160
},
"XP clustering":{
"XP clustering": {
"Concentration": 1.5,
"Volume (ul)": 30
}
Expand All @@ -228,7 +228,7 @@
"Concentration": 2,
"Volume (ul)": 320
},
"XP clustering":{
"XP clustering": {
"Concentration": 1.5,
"Volume (ul)": 35
}
Expand Down
17,667 changes: 17,666 additions & 1 deletion data/SMARTSEQ3_indexes.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ruff
mypy
pipreqs
pre-commit
ruff
types-PyYAML
types-requests
types-tabulate
types-Markdown
types-setuptools
types-setuptools
19 changes: 15 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
CouchDB
flowcell_parser @ git+https://github.com/SciLifeLab/flowcell_parser
genologics
couchdb
markdown
tabulate
google_api_python_client
httplib2
interop
Markdown
numpy
pandas
oauth2client
pandas
protobuf
psycopg2
PyYAML
Requests
scilifelab_parsers @ git+https://github.com/SciLifeLab/scilifelab_parsers
setuptools
tabulate