From 658583bfef124d7efe369a79251ba9f303bda2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Zar=C4=99bski?= Date: Wed, 11 Jun 2025 08:22:47 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=9A=20Set=20pytest=20cache=20direc?= =?UTF-8?q?tory=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/test_client_macos_nightlies.yml | 2 +- .github/workflows/test_client_ubuntu.yml | 32 ++++++++++++++---- .../test_client_ubuntu_nightlies.yml | 2 +- .github/workflows/test_multiple_python.yml | 2 +- simvue/api/request.py | 33 +++++++++++-------- tests/functional/test_run_class.py | 2 ++ 6 files changed, 51 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test_client_macos_nightlies.yml b/.github/workflows/test_client_macos_nightlies.yml index 6d387598..4e14e734 100644 --- a/.github/workflows/test_client_macos_nightlies.yml +++ b/.github/workflows/test_client_macos_nightlies.yml @@ -35,4 +35,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache diff --git a/.github/workflows/test_client_ubuntu.yml b/.github/workflows/test_client_ubuntu.yml index a20de2dd..0c8df64f 100644 --- a/.github/workflows/test_client_ubuntu.yml +++ b/.github/workflows/test_client_ubuntu.yml @@ -39,7 +39,10 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/unit/ -x -m online -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/unit/ -x + -m online -c /dev/null -p no:warnings + -n 0 -v -o cache_dir=.pytest-cache offline_unit_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -61,7 +64,10 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/unit/ -x -m offline -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/unit/ -x + -m offline -c /dev/null -p no:warnings + -n 0 -v -o cache_dir=.pytest-cache online_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -83,7 +89,10 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/functional/ -x -m online -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/functional/ -x + -m online -c /dev/null -p no:warnings + -n 0 -v -o cache_dir=.pytest-cache offline_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -105,7 +114,10 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/functional/ -x -m offline -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/functional/ -x + -m offline -c /dev/null -p no:warnings + -n 0 -v -o cache_dir=.pytest-cache other_unit_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -127,7 +139,11 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/unit/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/unit/ -x + -m 'not offline' -m 'not online' + -m 'not scenario' -c /dev/null + -p no:warnings -n 0 -v -o cache_dir=.pytest-cache other_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -149,4 +165,8 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }} - run: python -m pytest tests/functional/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null -p no:warnings -n 0 -v + run: >- + python -m pytest tests/functional/ -x + -m 'not offline' -m 'not online' + -m 'not scenario' -c /dev/null + -p no:warnings -n 0 -v -o cache_dir=.pytest-cache diff --git a/.github/workflows/test_client_ubuntu_nightlies.yml b/.github/workflows/test_client_ubuntu_nightlies.yml index 2c022814..15b7c815 100644 --- a/.github/workflows/test_client_ubuntu_nightlies.yml +++ b/.github/workflows/test_client_ubuntu_nightlies.yml @@ -38,4 +38,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache diff --git a/.github/workflows/test_multiple_python.yml b/.github/workflows/test_multiple_python.yml index 0a5aa8d9..d8cf343e 100644 --- a/.github/workflows/test_multiple_python.yml +++ b/.github/workflows/test_multiple_python.yml @@ -40,4 +40,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache diff --git a/simvue/api/request.py b/simvue/api/request.py index 7f5496b1..c8a76a31 100644 --- a/simvue/api/request.py +++ b/simvue/api/request.py @@ -309,17 +309,24 @@ def get_paginated( # else if undefined or greater than the page limit use the limit _request_count: int = min(count or MAX_ENTRIES_PER_PAGE, MAX_ENTRIES_PER_PAGE) - while ( - _response := get( - url=url, - headers=headers, - params=(params or {}) | {"count": _request_count, "start": _offset}, - timeout=timeout, - json=json, + try: + while ( + _response := get( + url=url, + headers=headers, + params=(params or {}) | {"count": _request_count, "start": _offset}, + timeout=timeout, + json=json, + ) + ).json(): + yield _response + _offset += MAX_ENTRIES_PER_PAGE + + if (count and _offset > count) or ( + _response.json().get("count", 0) < _offset + ): + break + except json_module.JSONDecodeError: + raise RuntimeError( + f"[{_response.status_code}] Failed to retrieve content from server: {_response.text}" ) - ).json(): - yield _response - _offset += MAX_ENTRIES_PER_PAGE - - if (count and _offset > count) or (_response.json().get("count", 0) < _offset): - break diff --git a/tests/functional/test_run_class.py b/tests/functional/test_run_class.py index bbc0cb0d..67864dff 100644 --- a/tests/functional/test_run_class.py +++ b/tests/functional/test_run_class.py @@ -1,4 +1,5 @@ import json +import logging import os import pytest import pytest_mock @@ -598,6 +599,7 @@ def test_runs_multiple_series(request: pytest.FixtureRequest) -> None: def test_suppressed_errors( setup_logging: "CountingLogHandler", post_init: bool, request: pytest.FixtureRequest ) -> None: + logging.getLogger("simvue").setLevel(logging.DEBUG) setup_logging.captures = ["Skipping call to"] with sv_run.Run(mode="offline") as run: From 69e33310e660ef2ec028bb5fccff2198ca19d5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Zar=C4=99bski?= Date: Wed, 11 Jun 2025 12:35:47 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=9A=20Use=20GITHUB=5FWORKSPACE=20v?= =?UTF-8?q?ariable=20to=20assign=20pycache=20location=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_client_macos_nightlies.yml | 2 +- .github/workflows/test_client_ubuntu.yml | 12 ++++++------ .github/workflows/test_client_ubuntu_nightlies.yml | 2 +- .github/workflows/test_multiple_python.yml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_client_macos_nightlies.yml b/.github/workflows/test_client_macos_nightlies.yml index 4e14e734..df3dcb2d 100644 --- a/.github/workflows/test_client_macos_nightlies.yml +++ b/.github/workflows/test_client_macos_nightlies.yml @@ -35,4 +35,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache diff --git a/.github/workflows/test_client_ubuntu.yml b/.github/workflows/test_client_ubuntu.yml index 0c8df64f..cd87d224 100644 --- a/.github/workflows/test_client_ubuntu.yml +++ b/.github/workflows/test_client_ubuntu.yml @@ -42,7 +42,7 @@ jobs: run: >- python -m pytest tests/unit/ -x -m online -c /dev/null -p no:warnings - -n 0 -v -o cache_dir=.pytest-cache + -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache offline_unit_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -67,7 +67,7 @@ jobs: run: >- python -m pytest tests/unit/ -x -m offline -c /dev/null -p no:warnings - -n 0 -v -o cache_dir=.pytest-cache + -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache online_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -92,7 +92,7 @@ jobs: run: >- python -m pytest tests/functional/ -x -m online -c /dev/null -p no:warnings - -n 0 -v -o cache_dir=.pytest-cache + -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache offline_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -117,7 +117,7 @@ jobs: run: >- python -m pytest tests/functional/ -x -m offline -c /dev/null -p no:warnings - -n 0 -v -o cache_dir=.pytest-cache + -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache other_unit_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -143,7 +143,7 @@ jobs: python -m pytest tests/unit/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null - -p no:warnings -n 0 -v -o cache_dir=.pytest-cache + -p no:warnings -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache other_functional_tests: runs-on: ubuntu-latest timeout-minutes: 40 @@ -169,4 +169,4 @@ jobs: python -m pytest tests/functional/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null - -p no:warnings -n 0 -v -o cache_dir=.pytest-cache + -p no:warnings -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache diff --git a/.github/workflows/test_client_ubuntu_nightlies.yml b/.github/workflows/test_client_ubuntu_nightlies.yml index 15b7c815..acf4aa5d 100644 --- a/.github/workflows/test_client_ubuntu_nightlies.yml +++ b/.github/workflows/test_client_ubuntu_nightlies.yml @@ -38,4 +38,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache diff --git a/.github/workflows/test_multiple_python.yml b/.github/workflows/test_multiple_python.yml index d8cf343e..65538f51 100644 --- a/.github/workflows/test_multiple_python.yml +++ b/.github/workflows/test_multiple_python.yml @@ -40,4 +40,4 @@ jobs: env: SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }} SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }} - run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=.pytest-cache + run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache