Skip to content

Commit

Permalink
Merge branch 'master' into fix-lazy-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal authored Oct 10, 2023
2 parents 4f92344 + 3e8a82b commit 36f0a0c
Show file tree
Hide file tree
Showing 39 changed files with 333 additions and 272 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/actions-versions-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
persist-credentials: false
- name: Run GitHub Actions Version Updater
uses: saadmk11/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: Bumpversion Patch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
with:
persist-credentials: false
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cache-cleaner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3.6.0
uses: actions/checkout@v4.1.0

- name: Cleanup
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- 'python'
steps:
- name: Checkout repository
uses: actions/checkout@v3.6.0
uses: actions/checkout@v4.1.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@codeql-bundle-20230524
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3.6.0
uses: actions/checkout@v4.1.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3.0.8
uses: actions/dependency-review-action@v3.1.0
16 changes: 9 additions & 7 deletions .github/workflows/label_on_approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,23 @@ jobs:
comment_approved:
name: Comment Concerning Approved Tag
if: |
(github.event_name == 'pull_request_target') ||
(github.event_name == 'pull_request_target') &&
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
steps:
- name: Find comment
uses: peter-evans/find-comment@v2
uses: peter-evans/find-comment@v2.4.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This Pull Request is coming from a fork and must be manually tagged `approved` in order to perform additional testing
- name: Create comment
if: |
(steps.fc.outputs.comment-id == '') ||
(!contains(github.event.pull_request.labels.*.name, 'approved'))
uses: peter-evans/create-or-update-comment@v3
(steps.fc.outputs.comment-id == '') &&
(!contains(github.event.pull_request.labels.*.name, 'approved')) &&
(github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand All @@ -63,12 +64,13 @@ jobs:
- name: Update comment
if: |
contains(github.event.pull_request.labels.*.name, 'approved')
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v3.0.2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Pull Request is approved!
> **Note**
> This Pull Request is approved!
reactions: |
hooray
edit-mode: append
19 changes: 10 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ on:
env:
XCLIM_TESTDATA_BRANCH: v2023.9.12

concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on master.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
lint:
name: Black (Python${{ matrix.python-version }})
Expand All @@ -35,11 +40,7 @@ jobs:
python-version:
- "3.8"
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/[email protected]
- uses: actions/[email protected]
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
with:
Expand All @@ -63,7 +64,7 @@ jobs:
- tox-env: "py39"
python-version: "3.9"
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Set up Python${{ matrix.python-version }}
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -103,7 +104,7 @@ jobs:
python-version: "3.11"
markers: -m 'not slow and not requires_internet'
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Install Eigen3
if: contains(matrix.tox-env, 'sbck')
run: |
Expand Down Expand Up @@ -140,9 +141,9 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/[email protected].3
uses: mamba-org/[email protected].4
with:
cache-downloads: true
cache-environment: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-mastodon.template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
New #xclim release: v{{ .version }} 🎉
New #xclim release: {{ .version }} 🎉

Latest source code available at: https://github.com/Ouranosinc/xclim/releases/tag/{{ .version }}
Check out the docs for more information: https://xclim.readthedocs.io/en/stable/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-mastodon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ on:
type: boolean

jobs:
build:
toot:
runs-on: ubuntu-latest
environment: production
steps:

- name: Checkout
uses: actions/checkout@v3.6.0
uses: actions/checkout@v4.1.0

- name: Current Version
if: ${{ !github.event.inputs.version-tag }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Set up Python3
uses: actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Set up Python3
uses: actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testdata_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Check Latest xclim-testdata Tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
- name: Find xclim-testdata Tag and CI Testing Branch
run: |
XCLIM_TESTDATA_TAG="$( \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3.6.0
- uses: actions/checkout@v4.1.0
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/[email protected].3
uses: mamba-org/[email protected].4
with:
cache-downloads: true
cache-environment: true
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.14.0
hooks:
- id: pyupgrade
args: ['--py38-plus']
Expand Down Expand Up @@ -33,7 +33,7 @@ repos:
- id: yamllint
args: ['--config-file=.yamllint.yaml']
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
Expand Down Expand Up @@ -71,9 +71,9 @@ repos:
hooks:
- id: blackdoc
exclude: '(xclim/indices/__init__.py|docs/installation.rst)'
additional_dependencies: ['black==23.7.0']
additional_dependencies: ['black==23.9.1']
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
rev: 0.27.0
hooks:
- id: check-github-workflows
- id: check-readthedocs
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ New features and enhancements
* `xclim` now has a dedicated console command for prefetching testing data from `xclim-testdata` with branch options (e.g.: `$ xclim prefetch_testing_data --branch some_development_branch`). This command can be used to download the testing data to a local cache, which can then be used to run the testing suite without internet access or in "offline" mode. For more information, see the contributing documentation section for `Updating Testing Data`. (:issue:`1468`, :pull:`1473`).
* The testing suite now offers a means of running tests in "offline" mode (using `pytest-socket <https://github.com/miketheman/pytest-socket>`_ to block external connections). This requires a local copy of `xclim-testdata` to be present in the user's home cache directory and for certain `pytest` options and markers to be set when invoked. For more information, see the contributing documentation section for `Running Tests in Offline Mode`. (:issue:`1468`, :pull:`1473`).
* The `SKIP_NOTEBOOKS` flag to speed up docs builds is now documented. See the contributing documentation section `Get Started!` for details. (:issue:`1470`, :pull:`1476`).
* Refactored the indicators page with the addition of a search bar.

Bug fixes
^^^^^^^^^
* Fixed an error in the `pytest` configuration that prevented copying of testing data to thread-safe caches of workers under certain conditions (this should always occur). (:pull:`1473`).
* Coincidentally, this also fixes an error that caused `pytest` to error-out when invoked without an active internet connection. Running `pytest` without network access is now supported (requires cached testing data). (:issue:`1468`).
* Calling a ``sdba.map_blocks``-wrapped function with data chunked along the reduced dimensions will raise an error. This forbids chunking the trained dataset along the distribution dimensions, for example. (:issue:`1481`, :pull:`1482`).
* Optimization of indicators ``huglin_index`` and ``biologically_effective_degree_days`` when used with dask and flox. As a side effect, the indice functions (i.e. under ``xc.indices``) no longer mask incomplete periods. The indicators' output is unchanged under the default "check_missing" setting (:issue:`1494`, :pull:`1495`).
* Fixed ``xclim.indices.run_length.lazy_indexing`` which would sometimes trigger the loading of auxiliary coordinates. (:issue:`1483`, :pull:`1484`).

Breaking changes
Expand All @@ -36,6 +38,8 @@ Internal changes
* Changes to the ``.zenodo.json`` file no longer are marked as CI-related changes. (:pull:`1479`).
* GitHub deployment workflows now employs use of deployment environments for workflow security and uses the `Trusted Publisher <https://docs.pypi.org/trusted-publishers/using-a-publisher/>`_ feature to sign and publish the `xclim` wheel and source distributions. (:pull:`1469`).
* Mastodon publishing now uses `chuhlomin/render-template <https://github.com/chuhlomin/render-template>`_ and a standard formatting markdown document to format Mastodon toots. (:pull:`1469`).
* GitHub testing workflows now use `Concurrency` instead of the styfle/cancel-workflow-action to cancel redundant workflows. (:pull:`1487`).
* The `pkg_resources` library has been replaced for the `packaging` library when version comparisons have been performed, and a few warning messages have been silenced in the testing suite. (:issue:`1489`, :pull:`1490`).
* New ``xclim.testing.helpers.assert_lazy`` context manager to assert the laziness of code blocks. (:pull:`1484`).

v0.45.0 (2023-09-05)
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url

webbrowser.open(f"file://{pathname2url(os.path.abspath(sys.argv[1]))}")
webbrowser.open(sys.argv[1])
endef
export BROWSER_PYSCRIPT

Expand Down Expand Up @@ -93,7 +93,11 @@ linkcheck: autodoc-custom-index ## run checks over all external links found thro
docs: autodoc-custom-index ## generate Sphinx HTML documentation, including API docs, but without indexes for for indices and indicators
$(MAKE) -C docs html
ifndef READTHEDOCS
$(BROWSER) docs/_build/html/index.html
## Start http server and show in browser.
## We want to have the cli command run in the foreground, so it's easy to kill.
## And we wait 2 sec for the server to start before opening the browser.
\{ sleep 2; $(BROWSER) http://localhost:54345 \} &
python -m http.server 54345 --directory docs/_build/html/
endif

servedocs: docs ## compile the docs watching for changes
Expand Down
95 changes: 95 additions & 0 deletions docs/_static/indsearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* Array of indicator objects */
let indicators = [];

/* MiniSearch object defining search mechanism */
let miniSearch = new MiniSearch({
fields: ['title', 'abstract', 'variables', 'keywords'], // fields to index for full-text search
storeFields: ['title', 'abstract', 'vars', 'realm', 'module', 'name', 'keywords'], // fields to return with search results
searchOptions: {
boost: {'title': 3, 'variables': 2},
fuzzy: 0.1,
prefix: true,
},
extractField: (doc, field) => {
if (field === 'variables') {
return Object.keys(doc['vars']).join(' ');
}
return MiniSearch.getDefault('extractField')(doc, field);
}
});

// Populate search object with complete list of indicators
fetch('indicators.json')
.then(data => data.json())
.then(data => {
indicators = Object.entries(data).map(([k, v]) => {
return {id: k.toLowerCase(), ...v}
});
miniSearch.addAll(indicators);
indFilter();
});


// Populate list of variables
//function getVariables() {
// fetch('variables.json')
// .then((res) => {
// return res.json();
// })
//}
//const variables = getVariables();


function makeKeywordLabel(ind) {
/* Print list of keywords only if there is at least one. */
if (ind.keywords[0].length > 0) {
const keywords = ind.keywords.map(v => `<code class="keywordlabel">${v.trim()}</code>`).join('');
return `<div class="keywords">Keywords: ${keywords}</div>`;
}
else {
return "";
}
}


function makeVariableList(ind) {
/* Print list of variables and include mouse-hover tooltip with variable description. */
return Object.entries(ind.vars).map((kv) => {
const tooltip = `<button class="indVarname" title="${kv[1]}" alt="${kv[1]}">${kv[0]}</button>`;
return tooltip
}).join('');
}

function indTemplate(ind) {
// const varlist = Object.entries(ind.vars).map((kv) => `<code class="indVarname">${kv[0]}</code>`).join('');
const varlist = makeVariableList(ind);
return `
<div class="indElem" id="${ind.id}">
<div class="indHeader">
<b class="indTitle">${ind.title}</b>
<a class="reference_internal indName" href="api.html#xclim.indicators.${ind.module}.${ind.name}" title="${ind.name}">
<code>${ind.module}.${ind.name}</code>
</a>
</div>
<div class="indVars">Uses: ${varlist}</div>
<div class="indDesc"><p>${ind.abstract}</p></div>
${makeKeywordLabel(ind)}
<div class="indID">Yaml ID: <code>${ind.id}</code></div>
</div>
`;
}

function indFilter() {
const input = document.getElementById("queryInput").value;
let inds = [];
if (input === "") {
inds = indicators;
} else {
inds = miniSearch.search(input);
}

const newTable = inds.map(indTemplate).join('');
const tableElem = document.getElementById("indTable");
tableElem.innerHTML = newTable;
return newTable;
}
Loading

0 comments on commit 36f0a0c

Please sign in to comment.