Skip to content
forked from pydata/xarray

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix/4107
Browse files Browse the repository at this point in the history
* upstream/master: (46 commits)
  pin netCDF4=1.5.3 in min-all-deps (pydata#4982)
  fix matplotlib errors for single level discrete colormaps (pydata#4256)
  Adapt exception handling in CFTimeIndex.__sub__ and __rsub__ (pydata#5006)
  Update options.py (pydata#5000)
  Adjust tests to use updated pandas syntax for offsets (pydata#4537)
  add a combine_attrs parameter to Dataset.merge (pydata#4895)
  Support for dask.graph_manipulation (pydata#4965)
  raise on passing axis to Dataset.reduce methods (pydata#4940)
  Whatsnew for 0.17.1 (pydata#4963)
  Refinements to how-to-release (pydata#4964)
  DOC: add example for reindex (pydata#4956)
  DOC: rm np import (pydata#4949)
  Add 0.17.0 release notes (pydata#4953)
  document update as inplace (pydata#4932)
  bump the dependencies (pydata#4942)
  Upstream CI: limit runtime (pydata#4946)
  typing for numpy 1.20 (pydata#4878)
  Use definition of DTypeLike from Numpy if found (pydata#4941)
  autoupdate mypy (pydata#4943)
  Add DataArrayCoarsen.reduce and DatasetCoarsen.reduce methods (pydata#4939)
  ...
  • Loading branch information
dcherian committed Mar 8, 2021
2 parents fc9be4e + 7905c51 commit 3f04332
Show file tree
Hide file tree
Showing 89 changed files with 2,039 additions and 550 deletions.
1 change: 1 addition & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref-names: $Format:%D$
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# reduce the number of merge conflicts
doc/whats-new.rst merge=union
# allow installing from git archives
.git_archival.txt export-subst
29 changes: 0 additions & 29 deletions .github/actions/detect-ci-trigger/action.yaml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/actions/detect-ci-trigger/script.sh

This file was deleted.

48 changes: 46 additions & 2 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: ./.github/actions/detect-ci-trigger
- uses: xarray-contrib/ci-trigger@v1
id: detect-trigger
with:
keyword: "[skip-ci]"
Expand Down Expand Up @@ -157,6 +157,50 @@ jobs:
run: |
python -m pytest --doctest-modules xarray --ignore xarray/tests
typing:
name: Type checking (mypy)
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}

steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- uses: conda-incubator/setup-miniconda@v2
with:
channels: conda-forge
channel-priority: strict
mamba-version: "*"
activate-environment: xarray-tests
auto-update-conda: false
python-version: "3.8"

- name: Install conda dependencies
run: |
mamba env update -f ci/requirements/environment.yml
- name: Install mypy
run: |
mamba install --file ci/requirements/mypy_only
- name: Install xarray
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
conda info -a
conda list
python xarray/util/print_versions.py
- name: Run mypy
run: |
python -m mypy xarray
min-version-policy:
name: Minimum Version Policy
runs-on: "ubuntu-latest"
Expand Down Expand Up @@ -184,6 +228,6 @@ jobs:

- name: minimum versions policy
run: |
mamba install -y pyyaml conda
mamba install -y pyyaml conda python-dateutil
python ci/min_deps_check.py ci/requirements/py37-bare-minimum.yml
python ci/min_deps_check.py ci/requirements/py37-min-all-deps.yml
44 changes: 44 additions & 0 deletions .github/workflows/ci-pre-commit-autoupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "pre-commit autoupdate CI"

on:
schedule:
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC
workflow_dispatch:


jobs:
autoupdate:
name: 'pre-commit autoupdate'
runs-on: ubuntu-latest
if: github.repository == 'pydata/xarray'
steps:
- name: checkout
uses: actions/checkout@v2
- name: Cache pip and pre-commit
uses: actions/cache@v2
with:
path: |
~/.cache/pre-commit
~/.cache/pip
key: ${{ runner.os }}-pre-commit-autoupdate
- name: setup python
uses: actions/setup-python@v2
- name: upgrade pip
run: python -m pip install --upgrade pip
- name: install dependencies
run: python -m pip install --upgrade pre-commit pyyaml packaging
- name: version info
run: python -m pip list
- name: autoupdate
uses: technote-space/create-pr-action@837dbe469b39f08d416889369a52e2a993625c84
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXECUTE_COMMANDS: |
python -m pre_commit autoupdate
python .github/workflows/sync_linter_versions.py .pre-commit-config.yaml ci/requirements/mypy_only
COMMIT_MESSAGE: 'pre-commit: autoupdate hook versions'
COMMIT_NAME: 'github-actions[bot]'
COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
PR_TITLE: 'pre-commit: autoupdate hook versions'
PR_BRANCH_PREFIX: 'pre-commit/'
PR_BRANCH_NAME: 'autoupdate-${PR_ID}'
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: ./.github/actions/detect-ci-trigger
- uses: xarray-contrib/ci-trigger@v1
id: detect-trigger
with:
keyword: "[skip-ci]"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/parse_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def extract_short_test_summary_info(lines):
)
up_to_section_content = itertools.islice(up_to_start_of_section, 1, None)
section_content = itertools.takewhile(
lambda l: l.startswith("FAILED"), up_to_section_content
lambda l: l.startswith("FAILED") or l.startswith("ERROR"), up_to_section_content
)
content = "\n".join(section_content)

Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/sync_linter_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python
import argparse
import itertools
import pathlib
import re

import yaml
from packaging import version
from packaging.requirements import Requirement

operator_re = re.compile("=+")


def extract_versions(config):
repos = config.get("repos")
if repos is None:
raise ValueError("invalid pre-commit configuration")

extracted_versions = (
((hook["id"], version.parse(repo["rev"])) for hook in repo["hooks"])
for repo in repos
)
return dict(itertools.chain.from_iterable(extracted_versions))


def update_requirement(line, new_versions):
# convert to pep-508 compatible
preprocessed = operator_re.sub("==", line)
requirement = Requirement(preprocessed)

specifier, *_ = requirement.specifier
old_version = specifier.version
new_version = new_versions.get(requirement.name, old_version)

new_line = f"{requirement.name}={new_version}"

return new_line


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--dry", action="store_true")
parser.add_argument(
metavar="pre-commit-config", dest="pre_commit_config", type=pathlib.Path
)
parser.add_argument("requirements", type=pathlib.Path)
args = parser.parse_args()

with args.pre_commit_config.open() as f:
config = yaml.safe_load(f)

versions = extract_versions(config)
mypy_version = versions["mypy"]

requirements_text = args.requirements.read_text()
requirements = requirements_text.split("\n")
new_requirements = [
update_requirement(line, versions)
if line and not line.startswith("# ")
else line
for line in requirements
]
new_requirements_text = "\n".join(new_requirements)

if args.dry:
separator = "\n" + "—" * 80 + "\n"
print(
"contents of the old requirements file:",
requirements_text,
"contents of the new requirements file:",
new_requirements_text,
sep=separator,
end=separator,
)
else:
args.requirements.write_text(new_requirements_text)
4 changes: 2 additions & 2 deletions .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: ./.github/actions/detect-ci-trigger
- uses: xarray-contrib/ci-trigger@v1
id: detect-trigger
with:
keyword: "[test-upstream]"
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
id: status
run: |
set -euo pipefail
python -m pytest -rf | tee output-${{ matrix.python-version }}-log || (
python -m pytest --timeout=60 -rf | tee output-${{ matrix.python-version }}-log || (
echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
)
- name: Upload artifacts
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ repos:
# - id: velin
# args: ["--write", "--compact"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.800
# version must correspond to the one in .github/workflows/ci-additional.yaml
rev: v0.812
hooks:
- id: mypy
exclude: "properties|asv_bench"
Expand Down
Loading

0 comments on commit 3f04332

Please sign in to comment.