Skip to content
forked from pydata/xarray

Commit

Permalink
Merge branch 'main' into groupby-refactor-init
Browse files Browse the repository at this point in the history
* main:
  pass kwargs through from save_mfdataset to to_netcdf (pydata#6686)
  Docs: indexing.rst finetuning (pydata#6685)
  use micromamba instead of mamba (pydata#6674)
  install the development version of `matplotlib` into the upstream-dev CI (pydata#6675)
  Add whatsnew section for v2022.06.0
  release notes for 2022.06.0rc0
  release notes for the pre-release (pydata#6676)
  more testpypi workflow fixes (pydata#6673)
  thin: add examples (pydata#6663)
  Update multidimensional-coords.ipynb (pydata#6672)
  try to finally fix the TestPyPI workflow (pydata#6671)
  pin setuptools in the modify script (pydata#6669)
  fix the python version for the TestPyPI workflow (pydata#6668)
  upload wheels from `main` to TestPyPI (pydata#6660)
  Set keep_attrs for flox (pydata#6667)
  • Loading branch information
dcherian committed Jun 12, 2022
2 parents cac2249 + 89b1fac commit 6bd276c
Show file tree
Hide file tree
Showing 16 changed files with 413 additions and 95 deletions.
75 changes: 47 additions & 28 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,29 @@ jobs:
run:
shell: bash -l {0}

env:
CONDA_ENV_FILE: ci/requirements/environment.yml
PYTHON_VERSION: "3.10"

steps:
- uses: actions/checkout@v3
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.9"

- name: Install conda dependencies
- name: set environment variables
run: |
mamba env update -f ci/requirements/environment.yml
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@de032af7fb3675649f3d4bbdda85178ba412ee41
with:
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
extra-specs: |
python=${{env.PYTHON_VERSION}}
cache-env: true
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"

- name: Install xarray
run: |
python -m pip install --no-deps -e .
Expand All @@ -76,23 +83,27 @@ jobs:
defaults:
run:
shell: bash -l {0}
env:
CONDA_ENV_FILE: ci/requirements/environment.yml
PYTHON_VERSION: "3.10"

steps:
- uses: actions/checkout@v3
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.9"

- name: Install conda dependencies
- name: set environment variables
run: |
mamba env update -f ci/requirements/environment.yml
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@de032af7fb3675649f3d4bbdda85178ba412ee41
with:
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
extra-specs: |
python=${{env.PYTHON_VERSION}}
cache-env: true
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
- name: Install xarray
run: |
python -m pip install --no-deps -e .
Expand All @@ -118,20 +129,28 @@ jobs:
run:
shell: bash -l {0}

strategy:
matrix:
environment-file: ["bare-minimum", "min-all-deps"]
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- uses: conda-incubator/setup-miniconda@v2

- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@de032af7fb3675649f3d4bbdda85178ba412ee41
with:
environment-name: xarray-tests
environment-file: false
extra-specs: |
python=3.10
pyyaml
conda
python-dateutil
channels: conda-forge
channel-priority: strict
mamba-version: "*"
auto-update-conda: false
python-version: "3.9"

- name: minimum versions policy
run: |
mamba install -y pyyaml conda python-dateutil
python ci/min_deps_check.py ci/requirements/bare-minimum.yml
python ci/min_deps_check.py ci/requirements/min-all-deps.yml
python ci/min_deps_check.py ci/requirements/${{ matrix.environment-file }}.yml
26 changes: 8 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if [[ ${{ matrix.os }} == windows* ]] ;
then
echo "CONDA_ENV_FILE=ci/requirements/environment-windows.yml" >> $GITHUB_ENV
Expand All @@ -83,25 +85,13 @@ jobs:
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Cache conda
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-py${{ matrix.python-version }}-${{ hashFiles('ci/requirements/**.yml') }}-${{ matrix.env }}

- uses: conda-incubator/setup-miniconda@v2
- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@de032af7fb3675649f3d4bbdda85178ba412ee41
with:
channels: conda-forge
channel-priority: strict
mamba-version: "*"
activate-environment: xarray-tests
auto-update-conda: false
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: true

- name: Install conda dependencies
run: |
mamba env update -f $CONDA_ENV_FILE
environment-file: ${{ env.CONDA_ENV_FILE }}
environment-name: xarray-tests
cache-env: true
cache-env-key: "${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"

# We only want to install this on one run, because otherwise we'll have
# duplicate annotations.
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/configure-testpypi-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import argparse
import copy
import pathlib

import tomli
import tomli_w


def split_path(path, sep="/"):
if isinstance(path, str):
return [part for part in path.split(sep) if part]
else:
return path


def extract(mapping, path, sep="/"):
parts = split_path(path, sep=sep)
cur = mapping
for part in parts:
cur = cur[part]

return cur


def update(mapping, path, value, sep="/"):
new = copy.deepcopy(mapping)

parts = split_path(path, sep=sep)
parent = extract(new, parts[:-1])
parent[parts[-1]] = value

return new


parser = argparse.ArgumentParser()
parser.add_argument("path", type=pathlib.Path)
args = parser.parse_args()

content = args.path.read_text()
decoded = tomli.loads(content)
with_local_scheme = update(
decoded, "tool.setuptools_scm.local_scheme", "no-local-version", sep="."
)
# work around a bug in setuptools / setuptools-scm
with_setuptools_pin = copy.deepcopy(with_local_scheme)
requires = extract(with_setuptools_pin, "build-system.requires", sep=".")
requires[0] = "setuptools>=42,<60"

new_content = tomli_w.dumps(with_setuptools_pin)
args.path.write_text(new_content)
87 changes: 87 additions & 0 deletions .github/workflows/testpypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build and Upload xarray to PyPI
on:
push:
branches:
- 'main'

# no need for concurrency limits

jobs:
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'pydata/xarray'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build setuptools setuptools-scm wheel twine check-manifest
python -m pip install tomli tomli_w
- name: Disable local versions
run: |
python .github/workflows/configure-testpypi-version.py pyproject.toml
git update-index --assume-unchanged pyproject.toml
cat pyproject.toml
- name: Build tarball and wheels
run: |
git clean -xdf
python -m build --sdist --wheel .
- name: Check built artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/xarray-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- uses: actions/upload-artifact@v3
with:
name: releases
path: dist

test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: "3.10"
- uses: actions/download-artifact@v3
with:
name: releases
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Verify the built dist/wheel is valid
if: github.event_name == 'push'
run: |
python -m pip install --upgrade pip
python -m pip install dist/xarray*.whl
python -m xarray.util.print_versions
- name: Publish package to TestPyPI
if: github.event_name == 'push'
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
16 changes: 7 additions & 9 deletions .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ jobs:
- uses: actions/checkout@v3
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: ${{ matrix.python-version }}
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@de032af7fb3675649f3d4bbdda85178ba412ee41
with:
environment-file: ci/requirements/environment.yml
environment-name: xarray-tests
extra-specs: |
python=${{ matrix.python-version }}
- name: Install upstream versions
run: |
mamba env update -f ci/requirements/environment.yml
bash ci/install-upstream-wheels.sh
- name: Install xarray
run: |
Expand Down
11 changes: 4 additions & 7 deletions ci/install-upstream-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@ conda uninstall -y --force \
flox \
h5netcdf \
xarray
# new matplotlib dependency
python -m pip install --upgrade contourpy
# to limit the runtime of Upstream CI
python -m pip install pytest-timeout
python -m pip install \
-i https://pypi.anaconda.org/scipy-wheels-nightly/simple \
--no-deps \
--pre \
--upgrade \
numpy \
scipy \
matplotlib \
pandas
python -m pip install \
-f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com \
--no-deps \
--pre \
--upgrade \
matplotlib
python -m pip install \
--no-deps \
--upgrade \
Expand All @@ -50,3 +46,4 @@ python -m pip install \
git+https://github.com/SciTools/nc-time-axis \
git+https://github.com/dcherian/flox \
git+https://github.com/h5netcdf/h5netcdf
python -m pip install pytest-timeout
4 changes: 2 additions & 2 deletions ci/requirements/bare-minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:
- pytest-cov
- pytest-env
- pytest-xdist
- numpy=1.18
- numpy=1.19
- packaging=20.0
- pandas=1.1
- pandas=1.2
4 changes: 2 additions & 2 deletions doc/examples/multidimensional-coords.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"# define a label for each bin corresponding to the central latitude\n",
"lat_center = np.arange(1, 90, 2)\n",
"# group according to those bins and take the mean\n",
"Tair_lat_mean = ds.Tair.groupby_bins(\"xc\", lat_bins, labels=lat_center).mean(\n",
"Tair_lat_mean = ds.Tair.groupby_bins(\"yc\", lat_bins, labels=lat_center).mean(\n",
" dim=xr.ALL_DIMS\n",
")\n",
"# plot the result\n",
Expand All @@ -186,7 +186,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The resulting coordinate for the `groupby_bins` operation got the `_bins` suffix appended: `xc_bins`. This help us distinguish it from the original multidimensional variable `xc`.\n",
"The resulting coordinate for the `groupby_bins` operation got the `_bins` suffix appended: `yc_bins`. This help us distinguish it from the original multidimensional variable `yc`.\n",
"\n",
"**Note**: This group-by-latitude approach does not take into account the finite-size geometry of grid cells. It simply bins each value according to the coordinates at the cell center. Xarray has no understanding of grid cells and their geometry. More precise geographic regridding for xarray data is available via the [xesmf](https://xesmf.readthedocs.io) package."
]
Expand Down
9 changes: 9 additions & 0 deletions doc/getting-started-guide/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ installed, take a look at the ``[options.extras_require]`` section in
:start-at: [options.extras_require]
:end-before: [options.package_data]

Development versions
--------------------
To install the most recent development version, install from github::

$ python -m pip install git+https://github.com/pydata/xarray.git

or from TestPyPI::

$ python -m pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple --pre xarray

Testing
-------
Expand Down
Loading

0 comments on commit 6bd276c

Please sign in to comment.