From 2903a426db45e60a07cec89440c68cf74251fc55 Mon Sep 17 00:00:00 2001 From: oskarhurst <48417811+oskarhurst@users.noreply.github.com> Date: Mon, 2 Jun 2025 11:33:09 -0700 Subject: [PATCH 1/2] gridded_data speed up and test publish --- .github/workflows/publish-to-test-pypi.yml | 11 +++++++++-- src/hecdss/gridded_data.py | 13 +++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 2bb4382..d45ed64 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,4 +1,4 @@ -name: Deployment +name: Test Deployment # The deployment workflow should only run when changes are merged into the `main` branch. # Since a branch protection rule prevents directly pushing to `main` this workflow will @@ -11,6 +11,11 @@ on: # Allow the workflow to be manually triggered from the Actions tab. workflow_dispatch: + inputs: + tag_name: + description: 'If you want to run a release, type an existing or new tag (eg. v1.2.0)' + required: false + default: '' jobs: # Build and test the distribution before deploying to the various platforms. This allows @@ -142,7 +147,9 @@ jobs: runs-on: ubuntu-latest # Require a tag push to publish a release distribution. - if: startsWith(github.ref, 'refs/tags/') + if: > + startsWith(github.ref, 'refs/tags/') + || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '') # The distribution will only be published if the tests have passed. needs: diff --git a/src/hecdss/gridded_data.py b/src/hecdss/gridded_data.py index e6a7af8..eb87341 100644 --- a/src/hecdss/gridded_data.py +++ b/src/hecdss/gridded_data.py @@ -1,6 +1,7 @@ # import pandas as pd import numpy as np import math +import time NULL_INT = -3.4028234663852886e+38 @@ -114,12 +115,12 @@ def range_limit_table(self, minval, maxval, range_, bins, datasize, data): self.rangeLimitTable[i] = minval + step * i self.rangeLimitTable[bins - 1] = maxval - # Exceedance - for idx in range(datasize): - for jdx in range(bins): - if data[idx] >= self.rangeLimitTable[jdx]: - self.numberEqualOrExceedingRangeLimit[jdx] += 1 + sorted_data = np.sort(data) + n = len(sorted_data) + for jdx in range(bins): + idx = np.searchsorted(sorted_data, self.rangeLimitTable[jdx], side="left") + self.numberEqualOrExceedingRangeLimit[jdx] = n - idx def update_grid_info(self): """ @@ -135,7 +136,7 @@ def update_grid_info(self): self.data = np.nan_to_num(self.data, nan=NULL_INT) self.numberOfRanges = math.floor(1 + 3.322 * math.log10(n) + 1) - flat_data = self.data.flatten() + flat_data = self.data.ravel() self.range_limit_table(self.minDataValue, self.maxDataValue, bin_range, self.numberOfRanges, n, flat_data) @staticmethod From 1f83691c9592e36f57fede4342034e5233d64429 Mon Sep 17 00:00:00 2001 From: oskarhurst <48417811+oskarhurst@users.noreply.github.com> Date: Thu, 3 Jul 2025 12:10:56 -0700 Subject: [PATCH 2/2] update release --- .github/workflows/publish-to-test-pypi.yml | 18 ++++----- .github/workflows/update-version.yml | 45 ++++++++++++++++++++++ src/hecdss/gridded_data.py | 1 - 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/update-version.yml diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index d45ed64..75f5d88 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,4 +1,4 @@ -name: Test Deployment +name: Deployment # The deployment workflow should only run when changes are merged into the `main` branch. # Since a branch protection rule prevents directly pushing to `main` this workflow will @@ -7,15 +7,9 @@ on: push: branches: - main - - feature/grid # Allow the workflow to be manually triggered from the Actions tab. workflow_dispatch: - inputs: - tag_name: - description: 'If you want to run a release, type an existing or new tag (eg. v1.2.0)' - required: false - default: '' jobs: # Build and test the distribution before deploying to the various platforms. This allows @@ -147,9 +141,9 @@ jobs: runs-on: ubuntu-latest # Require a tag push to publish a release distribution. - if: > - startsWith(github.ref, 'refs/tags/') - || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '') +# if: > +# startsWith(github.ref, 'refs/tags/') +# || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '') # The distribution will only be published if the tests have passed. needs: @@ -180,7 +174,9 @@ jobs: runs-on: ubuntu-latest # GitHub releases are only uploaded for release (tagged) distributions. - needs: [deploy-release] + needs: + - deploy-release + - build permissions: contents: write # IMPORTANT: mandatory for making GitHub Releases diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 0000000..e467d21 --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,45 @@ +name: update-version + +# The deployment workflow should only run when changes are merged into the `main` branch. +# Since a branch protection rule prevents directly pushing to `main` this workflow will +# only run on a successful merge request. +on: + # Allow the workflow to be manually triggered from the Actions tab. + workflow_dispatch: + inputs: + tag_name: + description: 'If you want to update the version and release, type an existing or new version tag (eg. 1.2.0)' + required: false + default: '' + +jobs: + + update-version: + name: Update Version + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '' }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Update version in pyproject.toml + run: | + sed -i "s/^version = .*/version = \"${{ github.event.inputs.tag_name }}\"/" pyproject.toml + + - name: Update version in setup.cfg + run: | + sed -i "s/^version = .*/version = ${{ github.event.inputs.tag_name }}/" setup.cfg + + - name: Commit and push version update + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add pyproject.toml setup.cfg + git commit -m "chore: update version to ${{ github.event.inputs.tag_name }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/src/hecdss/gridded_data.py b/src/hecdss/gridded_data.py index eb87341..f75b82e 100644 --- a/src/hecdss/gridded_data.py +++ b/src/hecdss/gridded_data.py @@ -1,7 +1,6 @@ # import pandas as pd import numpy as np import math -import time NULL_INT = -3.4028234663852886e+38