Skip to content

Commit

Permalink
Merge pull request #23 from danielfromearth/develop
Browse files Browse the repository at this point in the history
update `main`
  • Loading branch information
danielfromearth authored Oct 4, 2023
2 parents d8f5e5a + 6396d6b commit b31c45b
Show file tree
Hide file tree
Showing 8 changed files with 694 additions and 99 deletions.
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GitHub Issue: #NUM _(replace NUM with GitHub issue number)_

### Description

A short description of the changes in this PR.

### Local test steps

_Summarize testing and verification you've done. This includes unit tests or testing with specific data_

### Overview of integration done

_Explain how this change was integration tested. Provide screenshots or logs if appropriate. An example of this would be a local Harmony deployment._

## PR Acceptance Checklist
* [ ] Unit tests added/updated and passing.
* [ ] Integration testing
* [ ] `CHANGELOG.md` updated
* [ ] Documentation updated (if needed).
27 changes: 2 additions & 25 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,5 @@ on:
- issues/**

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.3.2

- name: Install stitchee
run: poetry install

- name: Lint
run: |
poetry run ruff concatenator
- name: Test with pytest
run: |
poetry run pytest tests/test_group_handling.py
# TODO: expand tests to include full concatenation runs, i.e., don't just run test_group_handling.py
build_and_test:
uses: ./.github/workflows/run_tests.yml
42 changes: 24 additions & 18 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ on:
workflow_dispatch:

jobs:
build-linux:
name: Lint and Test
runs-on: ubuntu-latest
run_tests:
uses: ./.github/workflows/run_tests.yml

bump_version:
needs: run_tests
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Retrieve repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

Expand Down Expand Up @@ -70,25 +76,25 @@ jobs:
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
env:
CURRENT_VERSION: ${{ steps.get-version.outputs.current_version }}
# True if the version already has a 'rc' pre-release identifier
BUMP_RC: ${{ contains(steps.get-version.outputs.current_version, 'rc') }}
# True if the version already has a 'alpha' pre-release identifier
BUMP_A: ${{ contains(steps.get-version.outputs.current_version, 'a') }}
# True if the version already has a 'beta' pre-release identifier
BUMP_B: ${{ contains(steps.get-version.outputs.current_version, 'b') }}
# Remove rc* from end of version string
# The ${string%%substring} syntax below deletes the longest match of $substring from back of $string.
run: |
poetry version ${CURRENT_VERSION%%rc*}
if [ "$BUMP_RC" = true ]; then
poetry version ${CURRENT_VERSION%%rc*}
elif [ "$BUMP_B" = true ]; then
poetry version ${CURRENT_VERSION%%b*}
elif [ "$BUMP_A" = true ]; then
poetry version ${CURRENT_VERSION%%a*}
fi
echo "software_version=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV
echo "venue=ops" >> $GITHUB_ENV
- name: Install stitchee
run: poetry install

- name: Lint
run: |
poetry run ruff concatenator
- name: Test with pytest
run: |
poetry run pytest tests/test_group_handling.py
# TODO: expand tests to include full concatenation runs, i.e., don't just run test_group_handling.py

# - name: Commit Version Bump
# # If building develop, a release branch, or main then we commit the version bump back to the repo
# if: |
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This workflow will install Python dependencies, run tests,
# and report test results and code coverage as artifacts. It will
# be called by the workflow that run tests against new PRs and as
# a first step in the workflow that publishes new Docker images.

name: A reusable workflow to build and run the unit test suite

on:
workflow_call:
workflow_dispatch:

jobs:
build_and_test:
runs-on: ubuntu-latest

steps:
- name: Retrieve repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Set up Poetry
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.3.2

- name: Install package
run: poetry install

- name: Run linting
run: |
poetry run ruff concatenator
- name: Run tests with coverage
run: |
poetry run coverage run -m pytest tests/test_group_handling.py >& test_results.txt
# TODO: expand tests to include full concatenation runs, i.e., don't just run test_group_handling.py

- name: Generate coverage report
if: ${{ always() }}
run: |
poetry run coverage report -m >& coverage_report.txt
poetry run coverage html --dir htmlcov
- name: Archive test results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: test result
path: test_results.txt

- name: Archive code coverage report (plain text)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: code coverage report (plain text)
path: coverage_report.txt

- name: Archive code coverage report (HTML)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: code coverage report (HTML)
path: htmlcov/*
10 changes: 9 additions & 1 deletion concatenator/stitchee.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def stitchee(
write_tmp_flat_concatenated: bool = False,
keep_tmp_files: bool = True,
concat_dim: str = "",
concat_kwargs: dict | None = None,
logger: Logger = default_logger,
) -> str:
"""Concatenate netCDF data files along an existing dimension.
Expand Down Expand Up @@ -89,8 +90,15 @@ def stitchee(
# coords='minimal',
# compat='override')

if concat_kwargs is None:
concat_kwargs = {}

combined_ds = xr.concat(
xrdataset_list, dim=GROUP_DELIM + concat_dim, data_vars="minimal", coords="minimal"
xrdataset_list,
dim=GROUP_DELIM + concat_dim,
data_vars="minimal",
coords="minimal",
**concat_kwargs,
)

benchmark_log["concatenating"] = time.time() - start_time
Expand Down
Loading

0 comments on commit b31c45b

Please sign in to comment.