diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml new file mode 100644 index 00000000000..fa2c33d2f0f --- /dev/null +++ b/.github/workflows/code-check.yml @@ -0,0 +1,29 @@ +name: Python code checks + +on: + workflow_call: + +jobs: + check-code: + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[dev]" + + - name: Run pre-commit checks + uses: pre-commit/action@v2.0.3 + with: + extra_args: --all-files + + - name: Type check with mypy + run: | + mypy src diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1ba287b4e67..96b735156e7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,11 +5,38 @@ on: - cron: '0 3 * * *' # 3 am UTC every day jobs: code-check: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ".[dev]" + + - name: Run pre-commit checks + uses: pre-commit/action@v2.0.3 + with: + extra_args: --all-files + + - name: Type check with mypy + run: | + mypy src + + tests: runs-on: ${{ matrix.os }} strategy: + fail-fast: false # finish all jobs even if one fails + max-parallel: 2 matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: [3.7, 3.8, 3.9, 3.10] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - name: Check out code uses: actions/checkout@v2 @@ -22,16 +49,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install ".[dev]" - - - name: Run pre-commit checks - uses: pre-commit/action@v2.0.3 - with: - extra_args: --all-files - - - name: Type check with mypy - run: | - mypy src + python -m pip install ".[dev]" - name: Test with pytest run: | @@ -45,6 +63,7 @@ jobs: firebolt-password: ${{ secrets.FIREBOLT_PASSWORD }} api-endpoint: "api.dev.firebolt.io" region: "us-east-1" + db_suffix: ${{ format('{0}_{1}', matrix.os, matrix.python-version) }} - name: Run integration tests env: diff --git a/src/firebolt/client/resource_manager_hooks.py b/src/firebolt/client/resource_manager_hooks.py index 2e718342422..f2afdde336e 100644 --- a/src/firebolt/client/resource_manager_hooks.py +++ b/src/firebolt/client/resource_manager_hooks.py @@ -1,3 +1,4 @@ +from json import JSONDecodeError from logging import getLogger from httpx import HTTPStatusError, Request, RequestError, Response @@ -34,7 +35,10 @@ def raise_on_4xx_5xx(response: Response) -> None: raise exc except HTTPStatusError as exc: response.read() # without this, you can get a ResponseNotRead error - parsed_response = exc.response.json() + try: + parsed_response = exc.response.json() + except JSONDecodeError: + parsed_response = {"_raw": exc.response.text} debug_message = ( f"Error response {exc.response.status_code} " f"while requesting {exc.request.url!r}. "