Skip to content

Commit

Permalink
Merge branch 'main' into allow-dtype
Browse files Browse the repository at this point in the history
* main:
  Update ci-additional.yaml (#167)
  Refactor before redoing cohorts (#164)
  Fix mypy errors in core.py (#150)
  Add link to numpy_groupies (#160)
  Bump codecov/codecov-action from 3.1.0 to 3.1.1 (#159)
  Use math.prod instead of np.prod (#157)
  Remove None output from _get_expected_groups (#152)
  Fix mypy errors in xarray.py, xrutils.py, cache.py (#144)
  Raise error if multiple by's are used with Ellipsis (#149)
  pre-commit autoupdate (#148)
  Add mypy ignores (#146)
  Get pre commit bot to update (#145)
  Remove duplicate examples headers (#147)
  Add ci additional (#143)
  Bump mamba-org/provision-with-micromamba from 12 to 13 (#141)
  Add ASV benchmark CI workflow (#139)
  Fix func count for dtype O with numpy and numba (#138)
  • Loading branch information
dcherian committed Oct 9, 2022
2 parents a32a40c + a1fb701 commit 08dff04
Show file tree
Hide file tree
Showing 20 changed files with 734 additions and 277 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Benchmark

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
workflow_dispatch:

jobs:
benchmark:
# if: ${{ contains( github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} # Run if the PR has been labelled correctly.
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} # Always run.
name: Linux
runs-on: ubuntu-20.04
env:
ASV_DIR: "./asv_bench"

steps:
# We need the full repo to avoid this issue
# https://github.com/actions/checkout/issues/23
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@v13
with:
environment-file: ci/environment.yml
environment-name: flox-tests
cache-env: true
# extra-specs: |
# python="${{ matrix.python-version }}"

# - name: Setup some dependencies
# shell: bash -l {0}
# run: |
# pip install asv
# sudo apt-get update -y

- name: Run benchmarks
shell: bash -l {0}
id: benchmark
env:
OPENBLAS_NUM_THREADS: 1
MKL_NUM_THREADS: 1
OMP_NUM_THREADS: 1
ASV_FACTOR: 1.5
ASV_SKIP_SLOW: 1
run: |
set -x
# ID this runner
asv machine --yes
echo "Baseline: ${{ github.event.pull_request.base.sha }} (${{ github.event.pull_request.base.label }})"
echo "Contender: ${GITHUB_SHA} (${{ github.event.pull_request.head.label }})"
# Use mamba for env creation
# export CONDA_EXE=$(which mamba)
export CONDA_EXE=$(which conda)
# Run benchmarks for current commit against base
ASV_OPTIONS="--split --show-stderr --factor $ASV_FACTOR"
asv continuous $ASV_OPTIONS ${{ github.event.pull_request.base.sha }} ${GITHUB_SHA} \
| sed "/Traceback \|failed$\|PERFORMANCE DECREASED/ s/^/::error::/" \
| tee benchmarks.log
# Report and export results for subsequent steps
if grep "Traceback \|failed\|PERFORMANCE DECREASED" benchmarks.log > /dev/null ; then
exit 1
fi
working-directory: ${{ env.ASV_DIR }}

- name: Add instructions to artifact
if: always()
run: |
cp benchmarks/README_CI.md benchmarks.log .asv/results/
working-directory: ${{ env.ASV_DIR }}

- uses: actions/upload-artifact@v3
if: always()
with:
name: asv-benchmark-results-${{ runner.os }}
path: ${{ env.ASV_DIR }}/.asv/results
118 changes: 118 additions & 0 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI Additional
on:
push:
branches:
- "main"
pull_request:
branches:
- "*"
workflow_dispatch: # allows you to trigger manually

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
detect-ci-trigger:
name: detect ci trigger
runs-on: ubuntu-latest
if: |
github.repository == 'xarray-contrib/flox'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: xarray-contrib/ci-trigger@v1.1
id: detect-trigger
with:
keyword: "[skip-ci]"

doctest:
name: Doctests
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}

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

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

- name: set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
with:
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: flox-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 flox
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
conda info -a
conda list
- name: Run doctests
run: |
python -m pytest --doctest-modules flox --ignore flox/tests
mypy:
name: Mypy
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
if: needs.detect-ci-trigger.outputs.triggered == 'false'
defaults:
run:
shell: bash -l {0}
env:
CONDA_ENV_FILE: ci/environment.yml
PYTHON_VERSION: "3.10"

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

- name: set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/provision-with-micromamba@34071ca7df4983ccd272ed0d3625818b27b70dcc
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 .
- name: Version info
run: |
conda info -a
conda list
- name: Install mypy
run: |
python -m pip install mypy
- name: Run mypy
run: |
python -m mypy --install-types --non-interactive
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@v12
uses: mamba-org/provision-with-micromamba@v13
with:
environment-file: ci/environment.yml
environment-name: flox-tests
Expand All @@ -49,7 +49,7 @@ jobs:
run: |
pytest -n auto --cov=./ --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v3.1.1
with:
file: ./coverage.xml
flags: unittests
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@v12
uses: mamba-org/provision-with-micromamba@v13
with:
environment-file: ci/${{ matrix.env }}.yml
environment-name: flox-tests
Expand All @@ -101,7 +101,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@v12
uses: mamba-org/provision-with-micromamba@v13
with:
environment-file: ci/upstream-dev-env.yml
environment-name: flox-tests
Expand All @@ -123,7 +123,7 @@ jobs:
repository: 'pydata/xarray'
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set up conda environment
uses: mamba-org/provision-with-micromamba@v12
uses: mamba-org/provision-with-micromamba@v13
with:
environment-file: ci/requirements/environment.yml
environment-name: xarray-tests
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ repos:
- id: check-docstring-first

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 22.8.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It was motivated by

1. Dask Dataframe GroupBy
[blogpost](https://blog.dask.org/2019/10/08/df-groupby)
2. numpy_groupies in Xarray
2. [numpy_groupies](https://github.com/ml31415/numpy-groupies) in Xarray
[issue](https://github.com/pydata/xarray/issues/4473)

(See a
Expand Down
10 changes: 5 additions & 5 deletions asv.conf.json → asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// The URL or local path of the source code repository for the
// project being benchmarked
"repo": ".",
"repo": "..",

// The Python project's subdirectory in your repo. If missing or
// the empty string, the project is assumed to be located at the root
Expand All @@ -37,7 +37,7 @@
// determined from "repo" by looking at the protocol in the URL
// (if remote), or by looking for special directories, such as
// ".git" (if local).
// "dvcs": "git",
"dvcs": "git",

// The tool to use to create environments. May be "conda",
// "virtualenv" or other value depending on the plugins in use.
Expand All @@ -48,10 +48,10 @@

// timeout in seconds for installing any dependencies in environment
// defaults to 10 min
//"install_timeout": 600,
"install_timeout": 600,

// the base URL to show a commit for the project.
"show_commit_url": "http://github.com/dcherian/flox/commit/",
"show_commit_url": "http://github.com/xarray-contrib/flox/commit/",

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
Expand Down Expand Up @@ -114,7 +114,7 @@

// The directory (relative to the current directory) that benchmarks are
// stored in. If not provided, defaults to "benchmarks"
// "benchmark_dir": "benchmarks",
"benchmark_dir": "benchmarks",

// The directory (relative to the current directory) to cache the Python
// environments in. If not provided, defaults to "env"
Expand Down
Loading

0 comments on commit 08dff04

Please sign in to comment.