Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 30 additions & 11 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines 7 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to reuse here .github/workflows/code-check.yml ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how github let's you reuse jobs because you need to specify specific branch/commit when reusing, and you can't just say use the same commit as the calling job. This makes it harder to test jobs on specific branches. That's why I think it's better to avoid reusing jobs when possible

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
Expand All @@ -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: |
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/firebolt/client/resource_manager_hooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from json import JSONDecodeError
from logging import getLogger

from httpx import HTTPStatusError, Request, RequestError, Response
Expand Down Expand Up @@ -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}. "
Expand Down