Skip to content

Commit f818cf2

Browse files
authored
Merge 467acc8 into da10c3a
2 parents da10c3a + 467acc8 commit f818cf2

10 files changed

Lines changed: 127 additions & 58 deletions

File tree

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: v1.4.2
2+
_commit: v1.4.3
33
_src_path: gh:lincc-frameworks/python-project-template
44
author_email: lincc-frameworks-team@lists.lsst.org
55
author_name: LINCC Frameworks

.github/workflows/asv-pr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ env:
1212
PYTHON_VERSION: "3.10"
1313
WORKING_DIR: ${{ github.workspace }}/benchmarks
1414

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1519
jobs:
1620

1721
setup-python:

.github/workflows/build-documentation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
pull_request:
1010
branches: [ main ]
1111

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
1216
jobs:
1317
build:
1418

.github/workflows/linting.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ on:
99
pull_request:
1010
branches: [ main ]
1111

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
1216
jobs:
1317
build:
1418
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
python-version: ['3.8', '3.9', '3.10']
18-
1919
steps:
2020
- uses: actions/checkout@v3
21-
- name: Set up Python ${{ matrix.python-version }}
21+
- name: Set up Python
2222
uses: actions/setup-python@v4
2323
with:
24-
python-version: ${{ matrix.python-version }}
24+
python-version: '3.10'
2525
- name: Install dependencies
2626
run: |
2727
sudo apt-get update
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflow runs pre-commit hooks on pull requests to enforce coding style.
2+
# To ensure correct configuration, please refer to:
3+
# https://lincc-ppt.readthedocs.io/en/latest/practices/ci_precommit.html
4+
5+
name: Run pre-commit hooks
6+
7+
on:
8+
pull_request:
9+
10+
jobs:
11+
pre-commit-ci:
12+
runs-on: ubuntu-latest
13+
env:
14+
SKIP: "check-lincc-frameworks-template-version,pytest-check,no-commit-to-branch,validate-pyproject,check-added-large-files,sphinx-build"
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.10'
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
python -m pip install --upgrade pip
27+
pip install .
28+
pip install .[dev]
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
- uses: pre-commit/action@v3.0.0
31+
with:
32+
extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
33+
- uses: pre-commit-ci/lite-action@v1.0.1
34+
if: always()

.pre-commit-config.yaml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
fail_fast: true
12
repos:
23

34
# Compare the local template version to the latest remote template version
@@ -22,22 +23,7 @@ repos:
2223
language: system
2324
entry: jupyter nbconvert --clear-output
2425

25-
# Run unit tests, verify that they pass. Note that coverage is run against
26-
# the ./src directory here because that is what will be committed. In the
27-
# github workflow script, the coverage is run against the installed package
28-
# and uploaded to Codecov by calling pytest like so:
29-
# `python -m pytest --cov=<package_name> --cov-report=xml`
30-
- repo: local
31-
hooks:
32-
- id: pytest-check
33-
name: Run unit tests
34-
description: Run unit tests with pytest.
35-
entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi"
36-
language: system
37-
pass_filenames: false
38-
always_run: true
39-
40-
# prevents committing directly branches named 'main' and 'master'.
26+
# Prevents committing directly branches named 'main' and 'master'.
4127
- repo: https://github.com/pre-commit/pre-commit-hooks
4228
rev: v4.4.0
4329
hooks:
@@ -49,23 +35,24 @@ repos:
4935
description: Prevent the user from committing very large files.
5036
args: ['--maxkb=500']
5137

52-
# verify that pyproject.toml is well formed
38+
# Verify that pyproject.toml is well formed
5339
- repo: https://github.com/abravalheri/validate-pyproject
5440
rev: v0.12.1
5541
hooks:
5642
- id: validate-pyproject
5743
name: Validate pyproject.toml
5844
description: Verify that pyproject.toml adheres to the established schema.
5945

46+
6047
# Automatically sort the imports used in .py files
6148
- repo: https://github.com/pycqa/isort
6249
rev: 5.12.0
6350
hooks:
6451
- id: isort
65-
name: isort (python files in src/ and tests/)
66-
description: Sort and organize imports in .py files.
67-
types: [python]
68-
files: ^(src|tests)/
52+
name: Run isort
53+
description: Sort and organize imports in .py and .pyi files.
54+
types_or: [python, pyi]
55+
6956

7057

7158
# Analyze the src code style and report code that doesn't adhere.
@@ -83,15 +70,16 @@ repos:
8370
"-sn", # Don't display the score
8471
"--rcfile=src/.pylintrc",
8572
]
73+
8674
# Analyze the tests code style and report code that doesn't adhere.
8775
- repo: local
8876
hooks:
8977
- id: pylint
90-
name: pylint (python files in tests/)
78+
name: pylint (python files in tests/ and benchmarks/)
9179
entry: pylint
9280
language: system
9381
types: [python]
94-
files: ^tests/
82+
files: ^(tests|benchmarks)/
9583
args:
9684
[
9785
"-rn", # Only display messages
@@ -100,6 +88,22 @@ repos:
10088
]
10189

10290

91+
92+
93+
# Run unit tests, verify that they pass. Note that coverage is run against
94+
# the ./src directory here because that is what will be committed. In the
95+
# github workflow script, the coverage is run against the installed package
96+
# and uploaded to Codecov by calling pytest like so:
97+
# `python -m pytest --cov=<package_name> --cov-report=xml`
98+
- repo: local
99+
hooks:
100+
- id: pytest-check
101+
name: Run unit tests
102+
description: Run unit tests with pytest.
103+
entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi"
104+
language: system
105+
pass_filenames: false
106+
always_run: true
103107
# Make sure Sphinx can build the documentation while explicitly omitting
104108
# notebooks from the docs, so users don't have to wait through the execution
105109
# of each notebook or each commit. By default, these will be checked in the

docs/guide/contributing.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,38 @@ branches and tickets, but it's nice when it's in the name.
2323
Set up a development environment
2424
-------------------------------------------------------------------------------
2525

26-
Most folks use conda for virtual environments. You may want to as well.
26+
Before installing any dependencies or writing code, it's a great idea to create a
27+
virtual environment. LINCC-Frameworks engineers primarily use `conda` to manage virtual
28+
environments. If you have conda installed locally, you can run the following to
29+
create and activate a new environment.
2730

2831
.. code-block:: bash
2932
30-
$ git clone https://github.com/astronomy-commons/hipscat
31-
$ cd hipscat
32-
$ pip install -e .
33+
>> conda create env -n <env_name> python=3.10
34+
>> conda activate <env_name>
35+
36+
37+
Once you have created a new environment, you can install this project for local
38+
development using the following commands:
39+
40+
.. code-block:: bash
41+
42+
>> pip install -e .'[dev]'
43+
>> pre-commit install
44+
>> conda install pandoc
45+
46+
47+
Notes:
48+
49+
1) The single quotes around ``'[dev]'`` may not be required for your operating system.
50+
2) ``pre-commit install`` will initialize pre-commit for this local repository, so
51+
that a set of tests will be run prior to completing a local commit. For more
52+
information, see the Python Project Template documentation on
53+
`pre-commit <https://lincc-ppt.readthedocs.io/en/latest/practices/precommit.html>`_.
54+
3) Install ``pandoc`` allows you to verify that automatic rendering of Jupyter notebooks
55+
into documentation for ReadTheDocs works as expected. For more information, see
56+
the Python Project Template documentation on
57+
`Sphinx and Python Notebooks <https://lincc-ppt.readthedocs.io/en/latest/practices/sphinx.html#python-notebooks>`_.
3358

3459
.. tip::
3560
Installing on Mac

pyproject.toml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,39 @@ dynamic = ["version"]
1717

1818
requires-python = ">=3.8"
1919
dependencies = [
20+
"astropy",
21+
"fsspec", # Used for abstract filesystems
2022
"healpy",
23+
"numba",
2124
"pandas",
22-
"setuptools_scm",
2325
"pyarrow>=10.0.0",
24-
"astropy",
25-
"typing-extensions>=4.3.0",
26-
"numba",
27-
"fsspec", # Used for abstract filesystems
28-
"ipykernel", # Support for Jupyter notebooks
26+
"setuptools_scm",
27+
"typing-extensions>=4.3.0"
2928
]
3029

3130
# On a mac, install optional dependencies with `pip install '.[dev]'` (include the single quotes)
3231
[project.optional-dependencies]
3332
dev = [
33+
"adlfs", # abfs filesytem support
34+
"asv==0.5.1", # Used to compute performance benchmarks
35+
"ipykernel", # Support for Jupyter notebooks
36+
"ipython", # Also used in building notebooks into Sphinx
37+
"matplotlib", # Used in sample notebook intro_notebook.ipynb
3438
"mypy", # Used for static type checking of files
35-
"pylint", # Used for static linting of files
39+
"myst_parser", # Renders markdown alongside RST
40+
"nbconvert", # Needed for pre-commit check to clear output from Python notebooks
41+
"nbsphinx", # Used to integrate Python notebooks into Sphinx documentation
42+
"numpy", # Used in sample notebook intro_notebook.ipynb
3643
"pre-commit", # Used to run checks before finalizing a git commit
44+
"pylint", # Used for static linting of files
3745
"pytest",
3846
"pytest-cov", # Used to report total code coverage
3947
"pytest-timeout", # Used to test for code efficiency
48+
"s3fs", # s3 filesystem support
4049
"sphinx", # Used to automatically generate documentation
41-
"sphinx-rtd-theme", # Used to render documentation
4250
"sphinx-autoapi", # Used to automatically generate api documentation
43-
# if you add dependencies here while experimenting in a notebook and you
44-
# want that notebook to render in your documentation, please add the
45-
# dependencies to ./docs/requirements.txt as well.
46-
"nbconvert", # Needed for pre-commit check to clear output from Python notebooks
47-
"nbsphinx", # Used to integrate Python notebooks into Sphinx documentation
48-
"ipykernel", # Also used in building notebooks into Sphinx
49-
"ipython", # Also used in building notebooks into Sphinx
50-
"myst_parser", # Renders markdown alongside RST
51-
"asv", # Used to compute performance benchmarks
52-
"adlfs", # abfs filesytem support
53-
"s3fs", # s3 filesystem support
51+
"sphinx-rtd-theme" # Used to render documentation
5452
]
55-
5653
[build-system]
5754
requires = [
5855
"setuptools>=62", # Used to build and package the Python project

src/.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ max-bool-expr=5
290290
max-branches=20
291291

292292
# Maximum number of locals for function / method body.
293-
max-locals=15
293+
max-locals=20
294294

295295
# Maximum number of parents for a class (see R0901).
296296
max-parents=7
@@ -503,7 +503,7 @@ ignore-imports=yes
503503
ignore-signatures=yes
504504

505505
# Minimum lines number of a similarity.
506-
min-similarity-lines=4
506+
min-similarity-lines=6
507507

508508

509509
[SPELLING]

tests/.pylintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ good-names=i,
183183
k,
184184
ex,
185185
Run,
186+
ra,
186187
_
187188

188189
# Good variable names regexes, separated by a comma. If names match any regex,
@@ -277,10 +278,10 @@ exclude-too-few-public-methods=
277278
ignored-parents=
278279

279280
# Maximum number of arguments for function / method.
280-
max-args=5
281+
max-args=10
281282

282283
# Maximum number of attributes for a class (see R0902).
283-
max-attributes=7
284+
max-attributes=20
284285

285286
# Maximum number of boolean expressions in an if statement (see R0916).
286287
max-bool-expr=5

0 commit comments

Comments
 (0)