Skip to content

Commit

Permalink
Update cookiecutter, restructure library (#126)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Updates the cookiecutter to the latest commit.
* The `ruff` linter has been adjusted to render the `flake8-alphabetize`
dependency redundant (and removed).
* Several `noqa` and `fixme` statements have been added to pass
additional linting checks for now.

### Does this PR introduce a breaking change?

Yes. 
* The structure of the package is slightly modified from a flat layout
to a src layout.
(https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/)
* `CHANGES.rst` is now `CHANGELOG.rst`.
(https://keepachangelog.com/en/1.1.0/#frequently-asked-questions)
* Bumping a release version will trigger changes in the `CHANGELOG.rst`
file. (Ouranosinc/cookiecutter-pypackage#41)

### Other information:

~This does not yet integrate changes from
Ouranosinc/cookiecutter-pypackage#50 (but it
should before merging)~

We should perform a release after this and then see about proposing the
package to `conda-forge`!
  • Loading branch information
Zeitsperre authored Jul 4, 2024
2 parents a7d276b + c5cfe0d commit 3d46287
Show file tree
Hide file tree
Showing 43 changed files with 771 additions and 329 deletions.
5 changes: 3 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"template": "https://github.com/Ouranosinc/cookiecutter-pypackage",
"commit": "f391bbd6ee14ab2478c64a1f78b74bd9903cae81",
"commit": "3b3598ae9524e7eb495bcba91093fac3369e753a",
"checkout": null,
"context": {
"cookiecutter": {
"full_name": "Sebastien Langlois",
"email": "[email protected]",
"github_username": "sebastienlanglois",
"github_username": "hydrologie",
"project_name": "xdatasets",
"project_slug": "xdatasets",
"project_short_description": "Easy access to Earth observation datasets with xarray.",
Expand All @@ -22,6 +22,7 @@
"create_author_file": "y",
"open_source_license": "MIT license",
"generated_with_cruft": "y",
"__gh_slug": "https://github.com/hydrologie/xdatasets",
"_template": "https://github.com/Ouranosinc/cookiecutter-pypackage"
}
},
Expand Down
3 changes: 0 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ exclude =
docs,
tests
ignore =
AZ100,
AZ200,
AZ300,
C,
D,
E,
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- This PR fixes #xyz
- [ ] (If applicable) Documentation has been added / updated (for bug fixes / features).
- [ ] (If applicable) Tests have been added.
- [ ] CHANGES.rst has been updated (with summary of main changes).
- [ ] CHANGELOG.rst has been updated (with summary of main changes).
- [ ] Link to issue (:issue:`number`) and pull request (:pull:`number`) has been added.

### What kind of change does this PR introduce?
Expand Down
8 changes: 3 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
directory: /.github/workflows/
schedule:
interval: daily
time: '12:00'
interval: monthly
open-pull-requests-limit: 10

- package-ecosystem: pip
directory: /
schedule:
interval: daily
time: '12:00'
interval: monthly
open-pull-requests-limit: 10
13 changes: 8 additions & 5 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- .pre-commit-config.yaml
- .yamllint.yaml
- AUTHORS.rst
- CHANGES.rst
- CHANGELOG.rst
- CONTRIBUTING.rst
- docs/notebooks/**.ipynb
- docs/*.py
Expand Down Expand Up @@ -51,10 +51,13 @@ jobs:
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/[email protected]
- name: Checkout Repository (no persist-credentials)
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- uses: actions/[email protected]
fetch-depth: 0
- name: Set up Python3
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"
- name: Config Commit Bot
Expand All @@ -68,7 +71,7 @@ jobs:
- name: Current Version
run: |
bump-my-version show current_version
CURRENT_VERSION="$(grep -E '__version__' xdatasets/__init__.py | cut -d ' ' -f3)"
CURRENT_VERSION="$(grep -E '__version__' src/xdatasets/__init__.py | cut -d ' ' -f3)"
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
- name: Conditional Bump Version
run: |
Expand All @@ -81,7 +84,7 @@ jobs:
fi
bump-my-version show-bump
- name: Push Changes
uses: ad-m/[email protected]
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # v0.8.0
with:
force: false
github_token: ${{ secrets.BUMP_VERSION_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cache-cleaner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
github.com:443
objects.githubusercontent.com:443
- uses: actions/[email protected]
- name: Checkout Repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Cleanup
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
api.github.com:443
github.com:443
- name: 'Checkout Repository'
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: 'Dependency Review'
uses: actions/dependency-review-action@0659a74c94536054bfa5aeb92241f70d680cc78e
- name: Dependency Review
uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2
3 changes: 2 additions & 1 deletion .github/workflows/first-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
allowed-endpoints: >
api.github.com:443
- uses: actions/[email protected]
- name: Verify Pull Request Opener
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
// Get a list of all issues created by the PR opener
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
allowed-endpoints: >
api.github.com:443
- uses: actions/[email protected]
- name: Label Pull Request
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 23 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
paths-ignore:
- .cruft.json
- CHANGES.rst
- CHANGELOG.rst
- README.rst
- pyproject.toml
- tests/test_xdatasets.py
Expand All @@ -30,9 +30,14 @@ jobs:
python-version:
- "3.x"
steps:
- uses: actions/[email protected]
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
Expand Down Expand Up @@ -62,7 +67,12 @@ jobs:
- tox-env: "py312"
python-version: "3.12"
steps:
- uses: actions/[email protected]
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Install NetCDF
run: |
sudo apt-get -y update
Expand All @@ -75,7 +85,7 @@ jobs:
cache: true
version: ${{ env.ESMF_VERSION }}
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
Expand All @@ -102,9 +112,14 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/[email protected]
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
uses: mamba-org/setup-micromamba@422500192359a097648154e8db4e39bdb6c6eed7 # v1.8.1
with:
cache-downloads: true
environment-file: environment-dev.yml
Expand All @@ -123,7 +138,7 @@ jobs:
- name: Test with pytest
run: |
python -m pytest --cov xdatasets
- name: Report coverage
- name: Report Coverage
run: |
python -m pip install coveralls
python -m coveralls
Expand All @@ -140,10 +155,6 @@ jobs:
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Coveralls Finished
run: |
python -m pip install --upgrade coveralls
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ jobs:
github.com:443
pypi.org:443
upload.pypi.org:443
- uses: actions/[email protected]
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python3
uses: actions/[email protected]
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"
- name: Install packaging libraries
Expand All @@ -39,4 +40,4 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
11 changes: 6 additions & 5 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ jobs:
tuf-repo-cdn.sigstore.dev:443
www.bestpractices.dev:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false

- name: Run analysis
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534
- name: Run Analysis
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -70,8 +71,8 @@ jobs:

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: Upload artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
- name: Upload Artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: SARIF file
path: results.sarif
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/[email protected]
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 # 2.0.5
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -51,9 +51,10 @@ jobs:
github.com:443
pypi.org:443
test.pypi.org:443
- uses: actions/[email protected]
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python3
uses: actions/[email protected]
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: "3.x"
- name: Install packaging libraries
Expand All @@ -63,7 +64,7 @@ jobs:
run: |
python -m flit build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/[email protected]
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
6 changes: 3 additions & 3 deletions .github/workflows/workflow-warning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ jobs:
egress-policy: block
allowed-endpoints: >
api.github.com:443
- name: Find comment
- name: Find Comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: |
This Pull Request modifies GitHub workflows and is coming from a fork.
- name: Create comment
- name: Create Comment
if: |
(steps.fc.outputs.comment-id == '') &&
(!contains(github.event.pull_request.labels.*.name, 'approved')) &&
Expand All @@ -54,7 +54,7 @@ jobs:
> This Pull Request modifies GitHub Workflows and is coming from a fork.
**It is very important for the reviewer to ensure that the workflow changes are appropriate.**
edit-mode: replace
- name: Update comment
- name: Update Comment
if: |
contains(github.event.pull_request.labels.*.name, 'approved')
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# Dask worker cache
dask-worker-space/

# IPython
profile_default/
ipython_config.py
Expand Down
Empty file removed .nojekyll
Empty file.
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ repos:
rev: v0.5.0
hooks:
- id: ruff
args: [ '--fix' ]
# - id: ruff-format
- repo: https://github.com/pycqa/flake8
rev: 7.1.0
hooks:
- id: flake8
additional_dependencies: [ 'flake8-alphabetize', 'flake8-rst-docstrings' ]
additional_dependencies: [ 'flake8-rst-docstrings' ]
args: ['--config=.flake8']
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
Expand All @@ -64,7 +66,7 @@ repos:
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==24.4.0' ]
additional_dependencies: [ 'black==24.4.2' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
Expand Down Expand Up @@ -94,6 +96,6 @@ ci:
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: quarterly
autoupdate_schedule: monthly
skip: []
submodules: false
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build:
python: "mambaforge-22.9"
jobs:
pre_build:
- sphinx-apidoc -o docs/apidoc --private --module-first xdatasets
- sphinx-apidoc -o docs/apidoc --private --module-first src/xdatasets
# - sphinx-build -M gettext docs docs/_build

conda:
Expand Down
Loading

0 comments on commit 3d46287

Please sign in to comment.