-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fal_client): handle missing metrics (#253)
* fix(fal_client): handle missing metrics * chore: enable gha tests * don't forget pillow * add FAL_KEY_PROD
- Loading branch information
Showing
6 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Run fal-client tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip wheel | ||
pip install -e 'projects/fal_client[test]' | ||
- name: Run tests | ||
env: | ||
FAL_KEY: ${{ secrets.FAL_KEY_PROD }} | ||
run: | | ||
pytest projects/fal_client/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ dependencies = [ | |
test = [ | ||
"pytest", | ||
"pytest-asyncio", | ||
"pillow", | ||
] | ||
dev = [ | ||
"fal_client[test]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
|
||
from fal_client.client import Queued, InProgress, Completed, _BaseRequestHandle | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"data, result, raised", | ||
[ | ||
( | ||
{"status": "IN_QUEUE", "queue_position": 123}, | ||
Queued(position=123), | ||
False, | ||
), | ||
( | ||
{"status": "IN_PROGRESS", "logs": [{"msg": "foo"}, {"msg": "bar"}]}, | ||
InProgress(logs=[{"msg": "foo"}, {"msg": "bar"}]), | ||
False, | ||
), | ||
( | ||
{"status": "COMPLETED", "logs": [{"msg": "foo"}, {"msg": "bar"}]}, | ||
Completed(logs=[{"msg": "foo"}, {"msg": "bar"}], metrics={}), | ||
False, | ||
), | ||
( | ||
{"status": "COMPLETED", "logs": [{"msg": "foo"}, {"msg": "bar"}], "metrics": {"m1": "v1", "m2": "v2"}}, | ||
Completed(logs=[{"msg": "foo"}, {"msg": "bar"}], metrics={"m1": "v1", "m2": "v2"}), | ||
False, | ||
), | ||
( | ||
{"status": "FOO"}, | ||
ValueError, | ||
True, | ||
) | ||
] | ||
) | ||
def test_parse_status(data, result, raised): | ||
handle = _BaseRequestHandle("foo", "bar", "baz", "qux") | ||
|
||
if raised: | ||
with pytest.raises(result): | ||
handle._parse_status(data) | ||
else: | ||
assert handle._parse_status(data) == result |