diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8905c13..58819c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,7 +66,7 @@ jobs: python -m pip install ".[test]" - name: Set development API_URL for non-main branches if: github.ref != 'refs/heads/main' - run: echo "API_URL=https://api.rouast.com/vitallens-dev" >> $GITHUB_ENV + run: echo "API_URL=https://api.rouast.com/vitallens-dev" | Out-File -FilePath $env:GITHUB_ENV -Append - name: Lint with flake8 run: | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics diff --git a/tests/test_vitallens.py b/tests/test_vitallens.py index 2b5531a..f1ceb85 100644 --- a/tests/test_vitallens.py +++ b/tests/test_vitallens.py @@ -90,7 +90,7 @@ def create_mock_api_response( "ppg_waveform": {"data": np.random.rand(video.shape[0]).tolist(), "unit": "unitless", "confidence": np.ones(video.shape[0]).tolist(), "note": "Note"}, "respiratory_waveform": {"data": np.random.rand(video.shape[0]).tolist(), "unit": "unitless", "confidence": np.ones(video.shape[0]).tolist(), "note": "Note"}}, "face": {"confidence": np.random.rand(video.shape[0]).tolist(), "note": "Note"}, - "state": {"data": np.zeros((2, 128), dtype=np.float32).tolist(), "note": "Note"}, + "state": {"data": np.zeros((256,), dtype=np.float32).tolist(), "note": "Note"}, "message": "Message"}) @pytest.mark.parametrize("file", [True, False]) @@ -167,7 +167,7 @@ def test_VitalLens_API_valid_response(request, process_signals, n_frames): live = np.asarray(response_body["face"]["confidence"]) assert live.shape == (n_frames,) state = np.asarray(response_body["state"]["data"]) - assert state.shape == (2, 128) + assert state.shape == (256,) def test_VitalLens_API_wrong_api_key(request): config = load_config("vitallens.yaml") @@ -194,4 +194,4 @@ def test_VitalLens_API_no_parseable_video(request): headers = {"x-api-key": api_key} payload = {"video": "not_parseable"} response = requests.post(API_URL, headers=headers, json=payload) - assert response.status_code == 400 + assert response.status_code == 422 diff --git a/vitallens/methods/vitallens.py b/vitallens/methods/vitallens.py index 41a4d27..805f1c9 100644 --- a/vitallens/methods/vitallens.py +++ b/vitallens/methods/vitallens.py @@ -255,7 +255,11 @@ def process_api_batch( elif response.status_code == 429: raise VitalLensAPIQuotaExceededError() elif response.status_code == 400: - raise VitalLensAPIError("Error occurred in the API. Message: {}".format(response_body['message'])) + raise VitalLensAPIError("Parameters missing: {}".format(response_body['message'])) + elif response.status_code == 422: + raise VitalLensAPIError("Issue with provided parameters: {}".format(response_body['message'])) + elif response.status_code == 500: + raise VitalLensAPIError("Error occurred in the API: {}".format(response_body['message'])) else: raise Exception("Error {}: {}".format(response.status_code, response_body['message'])) # Parse response