Skip to content

Commit

Permalink
Add further pre-commit hooks to match
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonWilde committed Oct 18, 2023
1 parent ee9c13d commit 0cf1f10
Show file tree
Hide file tree
Showing 34 changed files with 266 additions and 591 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Please check the type of change your PR introduces:
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Documentation content changes
- [ ] Other (please describe):
- [ ] Other (please describe):

## Other information

Any other information that is important to this PR such as screenshots of how the component looks before and after the change.
Any other information that is important to this PR such as screenshots of how the component looks before and after the change.
4 changes: 2 additions & 2 deletions .github/cloc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LINES_OF_CODE=${TOKENS[4]}
# To make the estimate of commented lines more accurate, we have to
# subtract any copyright header which is included in each file.
# For Fly-Pie, this header has the length of five lines.
# All dumb comments like those /////////// or those // ------------
# All dumb comments like those /////////// or those // ------------
# are also subtracted. As cloc does not count inline comments,
# the overall estimate should be rather conservative.
# Change the lines below according to your project.
Expand Down Expand Up @@ -67,4 +67,4 @@ if [[ $* == *--percentage* ]]
then
awk -v a=$COMMENT_LINES -v b=$LINES_OF_CODE \
'BEGIN {printf "%.1f\n", 100*a/(a+b)}'
fi
fi
2 changes: 1 addition & 1 deletion .github/workflows/black_and_isort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
with:
jupyter: true
- name: Run isort
uses: isort/isort-action@v1
uses: isort/isort-action@v1
4 changes: 2 additions & 2 deletions .github/workflows/build_mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build MkDocs

on:
on:
push:
branches: [main]

Expand Down Expand Up @@ -47,4 +47,4 @@ jobs:
- name: Deploy MkDocs
run: |
source .venv/bin/activate
mkdocs gh-deploy --force --clean --verbose
mkdocs gh-deploy --force --clean --verbose
6 changes: 3 additions & 3 deletions .github/workflows/dynamic_badges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ jobs:
minColorRange: 0
maxColorRange: ${{ env.COLLECTED }}
update-badges:

name: Update CLOC Badges

runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -105,4 +105,4 @@ jobs:
message: ${{ env.COMMENT_PERCENTAGE }}%
valColorRange: ${{ env.COMMENT_PERCENTAGE }}
maxColorRange: 40
minColorRange: 0
minColorRange: 0
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ site/
.tox/
.pytest_cache/
coverage.xml
coverage-badge.svg
coverage-badge.svg
18 changes: 18 additions & 0 deletions .poetry-sync-db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"nbqa": {
"repo": "https://github.com/nbQA-dev/nbQA",
"rev": "${rev}"
},
"nbstripout": {
"repo": "https://github.com/kynan/nbstripout",
"rev": "${rev}"
},
"black": {
"repo": "https://github.com/psf/black-pre-commit-mirror",
"rev": "${rev}"
},
"pre-commit-hooks": {
"repo": "https://github.com/pre-commit/pre-commit-hooks",
"rev": "v${rev}"
}
}
20 changes: 17 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,29 @@ repos:
hooks:
- id: sync_with_poetry
name: sync poetry versions
- repo: https://github.com/psf/black
rev: 23.10.0
args: [--db, .poetry-sync-db.json]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-isort
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
https://www.contributor-covenant.org/faq
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Please see the GDS [Git style guide in the 'How to store source code' page of th

If you open a GitHub pull request on this repo, please update `CHANGELOG` to reflect your contribution.

Add your entry under `Unreleased` as:
Add your entry under `Unreleased` as:
- `Breaking changes`
- `New features`
- `Fixes`
Expand Down
2 changes: 1 addition & 1 deletion LEVELS_OF_RAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ _Meeting all of the above requirements, plus:_
[9]: ../implementing_RAP/code-review.md
[10]: ../training_resources/python/python-functions.md#documentation
[11]: ../training_resources/python/logging-and-error-handling.md
[12]: ../training_resources/python/virtual-environments/conda.md
[12]: ../training_resources/python/virtual-environments/conda.md
13 changes: 7 additions & 6 deletions OPEN_CODE_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Open Code Checklist
To ensure that the code we publish is appropraite, clear and reusable we require a set way of working when pushing code to private and public repoistories. It is difficult to set any precise but generic standards and so we ask that the following checklist is considered with mandatroy items filled out.

To ensure that the code we publish is appropraite, clear and reusable we require a set way of working when pushing code to private and public repoistories. It is difficult to set any precise but generic standards and so we ask that the following checklist is considered with mandatroy items filled out.

## When publishing your code you need to make sure:

### you’re clear about who owns the code and how others can use it

- [x] Does your code have an appropriate licence and copyright notice? (**Mandatory**)
Expand All @@ -12,10 +13,10 @@ To ensure that the code we publish is appropraite, clear and reusable we require
- [x] Who has responsibility for ongoing support and communications for the code? (**Optional** Best practice to assign, else state the code is not maintained and when the last update was)
- [x] Has a responsible disclosure process for security issues been defined? (**Mandatory** - could use github issues)
- [x] Who will address identified issues and security concerns? (**Mandatory**. - assign monitoring of above disclosure process)
- [x] Has semantic versioning been used? (**Optional**)
- [x] Has semantic versioning been used? (**Optional**)
- [x] Have [contribution guidelines](https://github.com/alphagov/govuk-frontend/blob/master/CONTRIBUTING.md) or [PR style guides](https://github.com/alphagov/styleguides/blob/master/pull-requests.md) been included? (**Optional**)
- [x] Are package dependencies and libaries documented with versions? (**Optional**)
- [x] Has the code been linked to any published outputs so others can easily link to the code? (**Optional**)
- [x] Has the code been linked to any published outputs so others can easily link to the code? (**Optional**)

### You do not release information that should remain closed

Expand All @@ -28,11 +29,11 @@ To ensure that the code we publish is appropraite, clear and reusable we require
- [x] Are any credentials contained in the source code? (**Mandatory** - check in both current version and git history)
- [x] Are any secret keys contained in the source code? (**Mandatory** - check in both current version and git history)
- [x] Are any SQL server addresses or connection strings in the source code? (**Mandatory** - check in both current version and git history)
- [x] Are the commit messages informative? (**Optional**)
- [x] Are the commit messages informative? (**Optional**)
- [x] Do the commit messages include any sensitive information (e.g. names)? (**Mandatory**)
- [x] Does the git history contain any sensitive information (e.g. at one time real data or credentials were in the code but have since been removed) (**Mandatory**)
- [x] Have notebook outputs been removed/checked for sensitive information? (**Mandatory** - check but some appropriate outputs maybe useful: [Example]( https://github.com/best-practice-and-impact/govcookiecutter/blob/main/%7B%7B%20cookiecutter.repo_name%20%7D%7D/.pre-commit-config.yaml))
- [x] Is configuration written as code and separated from analytical code? (**Optional**)
- [x] Is configuration written as code and separated from analytical code? (**Optional**)
- [x] have you checked any screenshots or figures in your outputs and documentation for information that shouldn't be released? (**Mandatory**)

### You store it in a repository managed by your department (to make licensing/copyright clear)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ If you intend on contributing or working with the codebase directly, or if you w
3. Install [`poetry`](https://python-poetry.org/docs/#installation) and either:
- Skip to step four (and have `poetry` control the installation's virtual environment in their [proprietary way](https://python-poetry.org/docs/managing-environments/))
- Change `poetry`'s configuration to manage your own virtual environments:

```bash
poetry config virtualenvs.create false
poetry config virtualenvs.in-project false
Expand All @@ -86,13 +86,13 @@ If you intend on contributing or working with the codebase directly, or if you w
4. Install the project dependencies with `poetry install` (add optional flags: `--with dev` when developing and [testing](tests/) the package, `--with aux` to work with the [auxiliary notebooks](auxiliary/), `--with docs` to work with the [documentation](docs/))
5. You can then interact with the package in one of two ways:
- Via the [CLI](src/nhssynth/cli/) module, which is accessed using the `nhssynth` command, e.g.

```bash
poetry run nhssynth ...
```

*Note that you can omit the `poetry run` part and just type `nhssynth` if you followed the optional steps above to manage and activate your own virtual environment, or if you have executed `poetry shell` beforehand.*

- Through directly importing parts of the package to use in an existing project (`from nhssynth.modules... import ...`).

### Usage
Expand Down
5 changes: 3 additions & 2 deletions auxiliary/MIMIC_preproc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import time\n",
"from random import randrange, seed\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"from tqdm import tqdm"
]
},
Expand Down
13 changes: 7 additions & 6 deletions auxiliary/col_comparisons.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
"metadata": {},
"outputs": [],
"source": [
"from nhssynth.modules.dataloader.metatransformer import MetaTransformer\n",
"from nhssynth.modules.dataloader.metadata import MetaData\n",
"from nhssynth.modules.model.models import DPVAE, VAE\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd"
"import pandas as pd\n",
"from pandas import DataFrame\n",
"\n",
"from nhssynth.modules.dataloader.metadata import MetaData\n",
"from nhssynth.modules.dataloader.metatransformer import MetaTransformer\n",
"from nhssynth.modules.model.models import DPVAE, VAE"
]
},
{
Expand Down Expand Up @@ -175,8 +177,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
10 changes: 5 additions & 5 deletions auxiliary/generate_SUPPORT.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from datetime import datetime\n",
"\n",
"import numpy as np\n",
"from pycox.datasets import support\n",
"from datetime import datetime"
"import pandas as pd\n",
"from pycox.datasets import support"
]
},
{
Expand Down Expand Up @@ -174,8 +175,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
10 changes: 5 additions & 5 deletions auxiliary/mwe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"metadata": {},
"outputs": [],
"source": [
"from nhssynth.modules.dataloader.metatransformer import MetaTransformer\n",
"import pandas as pd\n",
"\n",
"from nhssynth.modules.dataloader.metadata import MetaData\n",
"from nhssynth.modules.model.models import DPVAE\n",
"import pandas as pd"
"from nhssynth.modules.dataloader.metatransformer import MetaTransformer\n",
"from nhssynth.modules.model.models import DPVAE"
]
},
{
Expand Down Expand Up @@ -150,8 +151,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
Loading

0 comments on commit 0cf1f10

Please sign in to comment.