From a8810f63b449fde42cd7149ab49182f9b7a4a704 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 10:40:56 -0500 Subject: [PATCH 01/13] linting action --- .github/workflows/precommit.yml | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/precommit.yml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..a9dc4f5 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,36 @@ +name: Run pre-commit hooks & push changes + +on: + pull_request: + paths: + - '**.py' + +jobs: + run-hooks: + name: Run Pre-Commit hooks and push changes back + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Install pre-commit + run: | + python -m pip install --upgrade pip + python -m pip install pre-commit + + - name: Run pre-commit hooks + run: | + pre-commit run --all-files + + - name: Commit and push changes if pre-commit made any modifications + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if git status --short | grep -q '\.py$'; then git add '*.py' && git commit -m "precommit: reformat" && git push; fi From 13f9a434247e05eb6bbb5c8c4e29d113e33ab087 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 10:47:37 -0500 Subject: [PATCH 02/13] testing githubbot --- nmdc_api_utilities/collection_search.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nmdc_api_utilities/collection_search.py b/nmdc_api_utilities/collection_search.py index 5e6a103..ee74659 100644 --- a/nmdc_api_utilities/collection_search.py +++ b/nmdc_api_utilities/collection_search.py @@ -207,9 +207,7 @@ def get_record_by_attribute( def get_record_by_id( self, collection_id: str, - max_page_size: int = 100, - fields: str = "", - ) -> list[dict]: + max_page_size: int = 100,fields: str = "",) -> list[dict]: """ Get a collection of data from the NMDC API by id. @@ -242,9 +240,7 @@ def get_record_by_id( logger.error("API request failed", exc_info=True) raise RuntimeError("Failed to get collection by id from NMDC API") from e else: - logging.debug( - f"API request response: {response.json()}\n API Status Code: {response.status_code}" - ) + logging.debug(f"API request response: {response.json()}\n API Status Code: {response.status_code}") results = response.json() return results From eb90a7ff9bb5f0bf7be7e9995e75eeee450a69ae Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 10:58:26 -0500 Subject: [PATCH 03/13] testing githubbot 2 --- nmdc_api_utilities/calibration_search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nmdc_api_utilities/calibration_search.py b/nmdc_api_utilities/calibration_search.py index a4b12a7..9e79ed1 100644 --- a/nmdc_api_utilities/calibration_search.py +++ b/nmdc_api_utilities/calibration_search.py @@ -12,3 +12,4 @@ class CalibrationSearch(CollectionSearch): def __init__(self, env="prod"): super().__init__(collection_name="calibration_set", env=env) + From d00d711397c3ba9592e5e54831a8454397b90bb4 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 11:35:24 -0500 Subject: [PATCH 04/13] updates to not error out --- .github/workflows/precommit.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index a9dc4f5..86378d4 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -27,10 +27,14 @@ jobs: - name: Run pre-commit hooks run: | - pre-commit run --all-files + pre-commit run --all-files || true - name: Commit and push changes if pre-commit made any modifications run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - if git status --short | grep -q '\.py$'; then git add '*.py' && git commit -m "precommit: reformat" && git push; fi + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "precommit: reformat" + git push + fi From 49a35418d697c1e410b46cf69ac8abe50264d7d7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 12 Nov 2025 16:36:02 +0000 Subject: [PATCH 05/13] precommit: reformat --- nmdc_api_utilities/calibration_search.py | 1 - nmdc_api_utilities/collection_search.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nmdc_api_utilities/calibration_search.py b/nmdc_api_utilities/calibration_search.py index 9e79ed1..a4b12a7 100644 --- a/nmdc_api_utilities/calibration_search.py +++ b/nmdc_api_utilities/calibration_search.py @@ -12,4 +12,3 @@ class CalibrationSearch(CollectionSearch): def __init__(self, env="prod"): super().__init__(collection_name="calibration_set", env=env) - diff --git a/nmdc_api_utilities/collection_search.py b/nmdc_api_utilities/collection_search.py index ee74659..5e6a103 100644 --- a/nmdc_api_utilities/collection_search.py +++ b/nmdc_api_utilities/collection_search.py @@ -207,7 +207,9 @@ def get_record_by_attribute( def get_record_by_id( self, collection_id: str, - max_page_size: int = 100,fields: str = "",) -> list[dict]: + max_page_size: int = 100, + fields: str = "", + ) -> list[dict]: """ Get a collection of data from the NMDC API by id. @@ -240,7 +242,9 @@ def get_record_by_id( logger.error("API request failed", exc_info=True) raise RuntimeError("Failed to get collection by id from NMDC API") from e else: - logging.debug(f"API request response: {response.json()}\n API Status Code: {response.status_code}") + logging.debug( + f"API request response: {response.json()}\n API Status Code: {response.status_code}" + ) results = response.json() return results From 958ed385c1819a7e5816d62a3f97bd08dbca5e19 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:02:46 -0500 Subject: [PATCH 06/13] precommit bot interfereing with tests --- .github/workflows/dev_tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dev_tests.yml b/.github/workflows/dev_tests.yml index 46e0362..75c771c 100644 --- a/.github/workflows/dev_tests.yml +++ b/.github/workflows/dev_tests.yml @@ -2,6 +2,10 @@ name: dev tests on: pull_request: + types: + - opened + - reopened + - synchronize workflow_dispatch: schedule: - cron: '0 0 * * *' From 723a735b89fc743b94e9420f4a22803502febb13 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:08:12 -0500 Subject: [PATCH 07/13] testing githubbot 3 --- .github/workflows/dev_tests.yml | 10 ++++------ .github/workflows/prod_tests.yml | 3 +++ nmdc_api_utilities/collection_search.py | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev_tests.yml b/.github/workflows/dev_tests.yml index 75c771c..f526972 100644 --- a/.github/workflows/dev_tests.yml +++ b/.github/workflows/dev_tests.yml @@ -1,16 +1,14 @@ name: dev tests on: - pull_request: - types: - - opened - - reopened - - synchronize + push: + branches: [ main ] + pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: schedule: - cron: '0 0 * * *' - permissions: contents: write issues: write diff --git a/.github/workflows/prod_tests.yml b/.github/workflows/prod_tests.yml index 108cad5..33fce72 100644 --- a/.github/workflows/prod_tests.yml +++ b/.github/workflows/prod_tests.yml @@ -1,7 +1,10 @@ name: prod tests on: + push: + branches: [ main ] pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: schedule: - cron: '0 0 * * *' diff --git a/nmdc_api_utilities/collection_search.py b/nmdc_api_utilities/collection_search.py index 5e6a103..2673661 100644 --- a/nmdc_api_utilities/collection_search.py +++ b/nmdc_api_utilities/collection_search.py @@ -207,8 +207,7 @@ def get_record_by_attribute( def get_record_by_id( self, collection_id: str, - max_page_size: int = 100, - fields: str = "", + max_page_size: int = 100, fields: str = "", ) -> list[dict]: """ Get a collection of data from the NMDC API by id. From 592019160acba25e80daf24d38454d1b83c3f207 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:13:37 -0500 Subject: [PATCH 08/13] add workflow permissions --- .github/workflows/precommit.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 86378d4..35050a1 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -5,6 +5,13 @@ on: paths: - '**.py' + +permissions: + contents: write + issues: write + workflows: write + + jobs: run-hooks: name: Run Pre-Commit hooks and push changes back From 0e1736df24eabbac8994ddbd24fbbba0e861d964 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:16:42 -0500 Subject: [PATCH 09/13] remve invalid perm --- .github/workflows/precommit.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 35050a1..ee0b45f 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -8,8 +8,6 @@ on: permissions: contents: write - issues: write - workflows: write jobs: From f7687aa9c9e6efc75c5e6f225316a42802500093 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:19:16 -0500 Subject: [PATCH 10/13] workflow update --- .github/workflows/documentation.yml | 6 +++++- .github/workflows/precommit.yml | 2 ++ nmdc_api_utilities/collection_search.py | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e00a7ff..5cda01f 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,6 +1,10 @@ name: documentation -on: [push, pull_request, workflow_dispatch] +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: permissions: contents: write diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index ee0b45f..3a87021 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -1,6 +1,8 @@ name: Run pre-commit hooks & push changes on: + push: + branches: [ main ] pull_request: paths: - '**.py' diff --git a/nmdc_api_utilities/collection_search.py b/nmdc_api_utilities/collection_search.py index 2673661..5e6a103 100644 --- a/nmdc_api_utilities/collection_search.py +++ b/nmdc_api_utilities/collection_search.py @@ -207,7 +207,8 @@ def get_record_by_attribute( def get_record_by_id( self, collection_id: str, - max_page_size: int = 100, fields: str = "", + max_page_size: int = 100, + fields: str = "", ) -> list[dict]: """ Get a collection of data from the NMDC API by id. From 8d25ddb9d3fd82c3bae51f1d4927e72f2e95916d Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:20:50 -0500 Subject: [PATCH 11/13] add pr types --- .github/workflows/precommit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 3a87021..eb2ec85 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -4,6 +4,7 @@ on: push: branches: [ main ] pull_request: + types: [opened, synchronize, reopened] paths: - '**.py' From cbc7704e7e1e6850bffac70b0f6146f9bd443c24 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 12:41:36 -0500 Subject: [PATCH 12/13] add deliminator to stop tests at first error --- .github/workflows/dev_tests.yml | 4 ++-- .github/workflows/prod_tests.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev_tests.yml b/.github/workflows/dev_tests.yml index f526972..ad2b7fc 100644 --- a/.github/workflows/dev_tests.yml +++ b/.github/workflows/dev_tests.yml @@ -3,7 +3,7 @@ name: dev tests on: push: branches: [ main ] - pull_request: + pull_request: types: [opened, synchronize, reopened] workflow_dispatch: schedule: @@ -36,7 +36,7 @@ jobs: CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} ENV : "dev" - run: pytest -r nmdc_api_utilities/test/ + run: pytest -x nmdc_api_utilities/test/ - name: Create Issue if: failure() && github.event.pull_request == null && github.event_name == 'schedule' uses: actions/github-script@v6 diff --git a/.github/workflows/prod_tests.yml b/.github/workflows/prod_tests.yml index 33fce72..60726b6 100644 --- a/.github/workflows/prod_tests.yml +++ b/.github/workflows/prod_tests.yml @@ -36,7 +36,7 @@ jobs: CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} ENV : "prod" - run: pytest -r nmdc_api_utilities/test/ + run: pytest -x nmdc_api_utilities/test/ - name: Create Issue if: failure() && github.event.pull_request == null && github.event_name == 'schedule' uses: actions/github-script@v6 From 5d49d4203eaabd5f705da57b4d892005aa4efd48 Mon Sep 17 00:00:00 2001 From: "olivia.hess" Date: Wed, 12 Nov 2025 15:12:53 -0500 Subject: [PATCH 13/13] change so dependencies point to requirements file --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 162d2e7..33d8297 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,5 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Operating System :: OS Independent", ] -dependencies = ["pandas~=2.2.3", "requests~=2.32.3", "matplotlib~=3.10.0"] license-files = ["LICENSE"] +dynamic = ["dependencies"] +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]}