Skip to content

Commit

Permalink
Merge branch 'UXARRAY:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyuchen1030 authored May 20, 2024
2 parents d0684c9 + 93cf4d9 commit 5f854dd
Show file tree
Hide file tree
Showing 97 changed files with 10,953 additions and 2,819 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/release_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Date of intended release:
## Release progress checklist

- [ ] CI tests are passing
- [ ] update version number in `meta.yaml`
- [ ] a new tag and release has been made on GitHub
- [ ] feedstock PR has been merged
- [ ] release on pypi action has been triggered and run successfully
Expand Down
54 changes: 36 additions & 18 deletions .github/workflows/asv-benchmarking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
benchmark:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
env:
CONDA_ENV_FILE: ./ci/asv.yml
ASV_DIR: ./benchmarks
Expand All @@ -18,36 +21,51 @@ jobs:
uses: actions/checkout@v4
with:
repository: UXARRAY/uxarray
ref: main
fetch-depth: 0

- name: Fetch all tags and branches for uxarray
run: |
git fetch --all --tags
- name: Checkout uxarray-asv
uses: actions/checkout@v4
with:
repository: uxarray/uxarray-asv
repository: UXARRAY/uxarray-asv
persist-credentials: false
fetch-depth: 0
ref: main
path: uxarray-asv
- name: Set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Set up conda environment
id: env-setup
continue-on-error: true
uses: mamba-org/setup-micromamba@v1
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: ./ci/asv.yml
cache-environment: true
cache-environment-key: "benchmark-${{runner.os}}-${{runner.arch}}-${{env.TODAY}}"
miniforge-version: "24.1.2-0"
activate-environment: asv

- name: Get date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: retry environment set up if failed
if: steps.env-setup.outcome == 'failure'
uses: mamba-org/setup-micromamba@v1
- name: Cache environment
uses: actions/cache@v4
with:
download-micromamba: false
environment-file: ./ci/asv.yml
cache-environment: true
cache-environment-key: "benchmark-${{runner.os}}-${{runner.arch}}-${{env.TODAY}}"
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('./ci/asv.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0
id: cache

- name: Update environment
run:
conda env update -n asv -f ./ci/asv.yml
if: steps.cache.outputs.cache-hit != 'true'

- name: Conda list
run: |
conda info
conda list
- name: Copy existing results
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ jobs:
python -m pytest test -v --cov=./uxarray --cov-report=xml
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
if: github.repository == 'UXARRAY/uxarray'
uses: codecov/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
flags: unittests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
- uses: pre-commit/[email protected]
6 changes: 3 additions & 3 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@v5.1.0
with:
python-version: '3.x'
- name: Install dependencies
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@v5.1.0
with:
python-version: '3.x'
- name: Install dependencies
Expand All @@ -50,7 +50,7 @@ jobs:
python -m twine check dist/*
- name: Publish package to PyPI
uses: pypa/[email protected].11
uses: pypa/[email protected].14
with:
skip-existing: true
verbose: true
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ repos:
hooks:
- id: check-yaml # Checks the syntax of .yaml files.
args: [--allow-multiple-documents]
exclude: 'meta.yaml' # Exclude this because it gives an error for '%' in Line 1 and couldn't fix yet
- id: end-of-file-fixer # Makes sure files end with a newline.
- id: trailing-whitespace # Checks for any tabs or spaces after the last non-whitespace character on the line.
- id: check-docstring-first # Checks that code comes after the docstrings.

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.5
rev: v0.4.1
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
types_or: [ python, pyi, jupyter ]

# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
18 changes: 18 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include LICENSE
include README.md

recursive-include uxarray *.py
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
exclude .gitignore
exclude .pre-commit-config.yaml
exclude .readthedocs.yml

include *.md
include *.toml
include *.txt
prune test*
prune ci*
prune .github*
prune docs*
prune benchmarks*
2 changes: 2 additions & 0 deletions benchmarks/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
// defaults to 10 min
"install_timeout": 600,

"benchmark_timeout": 360,

// the base URL to show a commit for the project.
"show_commit_url": "https://github.com/UXARRAY/uxarray/commit/",

Expand Down
32 changes: 32 additions & 0 deletions benchmarks/face_bounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
from pathlib import Path

import uxarray as ux

current_path = Path(os.path.dirname(os.path.realpath(__file__))).parents[0]

grid_quad_hex = current_path / "test" / "meshfiles" / "ugrid" / "quad-hexagon" / "grid.nc"
grid_geoflow = current_path / "test" / "meshfiles" / "ugrid" / "geoflow-small" / "grid.nc"
grid_scrip = current_path / "test" / "meshfiles" / "scrip" / "outCSne8" / "outCSne8.nc"
grid_mpas= current_path / "test" / "meshfiles" / "mpas" / "QU" / "oQU480.231010.nc"



class FaceBounds:

params = [grid_quad_hex, grid_geoflow, grid_scrip, grid_mpas]


def setup(self, grid_path):
self.uxgrid = ux.open_grid(grid_path)

def teardown(self, n):
del self.uxgrid

def time_face_bounds(self, grid_path):
"""Time to obtain ``Grid.face_bounds``"""
self.uxgrid.bounds

def peakmem_face_bounds(self, grid_path):
"""Peak memory usage obtain ``Grid.face_bounds."""
face_bounds = self.uxgrid.bounds
99 changes: 99 additions & 0 deletions benchmarks/mpas_ocean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import os
import urllib.request
from pathlib import Path

import uxarray as ux

current_path = Path(os.path.dirname(os.path.realpath(__file__)))

data_var = 'bottomDepth'

grid_filename_480 = "oQU480.grid.nc"
data_filename_480 = "oQU480.data.nc"

grid_filename_120 = "oQU120.grid.nc"
data_filename_120 = "oQU120.data.nc"

filenames = [grid_filename_480, data_filename_480, grid_filename_120, data_filename_120]

for filename in filenames:
if not os.path.isfile(current_path / filename):
# downloads the files from Cookbook repo, if they haven't been downloaded locally yet
url = f"https://github.com/ProjectPythia/unstructured-grid-viz-cookbook/raw/main/meshfiles/{filename}"
_, headers = urllib.request.urlretrieve(url, filename=current_path / filename)


file_path_dict = {"480km": [current_path / grid_filename_480, current_path / data_filename_480],
"120km": [current_path / grid_filename_120, current_path / data_filename_120]}


class Gradient:

param_names = ['resolution']
params = ['480km', '120km']


def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
del self.uxds

def time_gradient(self, resolution):
self.uxds[data_var].gradient()

def peakmem_gradient(self, resolution):
grad = self.uxds[data_var].gradient()

class Integrate:

param_names = ['resolution']
params = ['480km', '120km']


def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
del self.uxds

def time_integrate(self, resolution):
self.uxds[data_var].integrate()

def peakmem_integrate(self, resolution):
integral = self.uxds[data_var].integrate()

class GeoDataFrame:

param_names = ['resolution', 'exclude_antimeridian']
params = [['480km', '120km'],
[True, False]]


def setup(self, resolution, exclude_antimeridian):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution, exclude_antimeridian):
del self.uxds

def time_to_geodataframe(self, resolution, exclude_antimeridian):
self.uxds[data_var].to_geodataframe(exclude_antimeridian=exclude_antimeridian)

def peakmem_to_geodataframe(self, resolution, exclude_antimeridian):
gdf = self.uxds[data_var].to_geodataframe(exclude_antimeridian=exclude_antimeridian)


class ConnectivityConstruction:

param_names = ['resolution']
params = ['480km', '120km']


def setup(self, resolution):
self.uxds = ux.open_dataset(file_path_dict[resolution][0], file_path_dict[resolution][1])

def teardown(self, resolution):
del self.uxds

def time_n_nodes_per_face(self, resolution):
self.uxds.uxgrid.n_nodes_per_face
5 changes: 3 additions & 2 deletions ci/asv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ dependencies:
- gmpy2
- holoviews
- matplotlib-base
- matplotlib-inline
- netcdf4
- numba
- numpy
- pandas<2.1.0
- pathlib
- pre_commit
- pyarrow<13.0.0 # pin due to CI faliures on macOS & ubuntu
- pyarrow
- pytest
- pytest-cov
- requests
Expand All @@ -27,5 +28,5 @@ dependencies:
- pip:
- antimeridian
- pyfma
- asv
- asv<0.6.2
- -e ../
3 changes: 2 additions & 1 deletion ci/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- dask
- netcdf4
- numba
- numpy<=1.24
- numpy
- pathlib
- pre_commit
- pytest
Expand All @@ -24,6 +24,7 @@ dependencies:
- sphinx-design
- nbsphinx
- matplotlib-base
- matplotlib-inline
- shapely
- hvplot
- holoviews
Expand Down
3 changes: 2 additions & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ dependencies:
- gmpy2
- holoviews
- matplotlib-base
- matplotlib-inline
- netcdf4
- numba
- numpy
- pandas<2.1.0
- pathlib
- pre_commit
- pyarrow<13.0.0 # pin due to CI faliures on macOS & ubuntu
- pyarrow
- pytest
- pytest-cov
- requests
Expand Down
Binary file added docs/_static/examples/grids/cam_se.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/lat_lon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_static/images/icons/contrib.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_static/images/icons/guide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ high-level understanding of UXarray's future function development milestones and
Please let us know if you have any feedback!

.. toctree::
:maxdepth: 2
:hidden:
:maxdepth: 1

user_api/index.rst
internal_api/index.rst
Loading

0 comments on commit 5f854dd

Please sign in to comment.