diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..2ab4232 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,113 @@ +name: test.yaml +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + container: + image: python + + steps: + - name: Check out git repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fix + run: git config --global --add safe.directory '*' + + - name: Install dependencies + run: pip3 install poetry flake8 black && poetry config virtualenvs.create ${USE_VENV} && poetry install +# +# - name: flake8 +# run: flake8 --max-line-length=120 . + + - name: black + run: black --preview --check . + + test_fields: + needs: + - lint + + runs-on: ubuntu-latest + + container: + image: python:3.8 + + steps: + - name: Check out git repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fix + run: git config --global --add safe.directory '*' + + - name: Install dependencies + run: pip3 install poetry pytest-asyncio && poetry config virtualenvs.create false && poetry install + + - name: Test + env: + FMA_APIKEY: ${{ secrets.FMA_APIKEY }} + run: pytest tests/test_fields.py --tb=short + + test_flymyai_client: + needs: + - lint + + runs-on: ubuntu-latest + + container: + image: python:3.8 + + steps: + - name: Check out git repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fix + run: git config --global --add safe.directory '*' + + - name: Install dependencies + run: pip3 install poetry pytest-asyncio && poetry config virtualenvs.create false && poetry install + + - name: Test + env: + FMA_APIKEY: ${{ secrets.FMA_APIKEY }} + run: pytest tests/test_flymyai_client.py --tb=short + + test_stream: + needs: + - lint + + runs-on: ubuntu-latest + + container: + image: python:3.8 + + steps: + - name: Check out git repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fix + run: git config --global --add safe.directory '*' + + - name: Install dependencies + run: pip3 install poetry pytest-asyncio && poetry config virtualenvs.create false && poetry install + + - name: Test + env: + FMA_APIKEY: ${{ secrets.FMA_APIKEY }} + run: pytest tests/test_stream.py --tb=short + diff --git a/.gitignore b/.gitignore index e8067d2..520ab1f 100644 --- a/.gitignore +++ b/.gitignore @@ -131,7 +131,6 @@ dmypy.json .pyre/ # media files *.csv -*.png *.jpg *.rar *.jpeg @@ -142,5 +141,4 @@ dmypy.json .dir .idea/* poetry.lock -tests/fixtures*/ venv* diff --git a/tests/fixtures/Untitled.png b/tests/fixtures/Untitled.png new file mode 100644 index 0000000..1ffb149 Binary files /dev/null and b/tests/fixtures/Untitled.png differ diff --git a/tests/fixtures/test_fields.json b/tests/fixtures/test_fields.json new file mode 100644 index 0000000..482a076 --- /dev/null +++ b/tests/fixtures/test_fields.json @@ -0,0 +1,6 @@ +{ + "binary_field_path": "tests/fixtures/Untitled.png", + "simple_field_inputs": [ + "123", 2, 2.0, [222, 22.0] + ] +} \ No newline at end of file diff --git a/tests/fixtures/test_flymyai_client.json b/tests/fixtures/test_flymyai_client.json new file mode 100644 index 0000000..dbe4e3b --- /dev/null +++ b/tests/fixtures/test_flymyai_client.json @@ -0,0 +1,11 @@ +{ + "client_auth_fixture": { + "model": "flymyai/perf_cpn-1", + "apikey_environ": "FMA_APIKEY" + }, + "address_fixture": "https://dev-api.flymy.ai", + "fake_payload_fixture": { + "prompt": "2w432442" + }, + "binary_file_paths": {} +} \ No newline at end of file diff --git a/tests/fixtures/test_stream.json b/tests/fixtures/test_stream.json new file mode 100644 index 0000000..76f6f8c --- /dev/null +++ b/tests/fixtures/test_stream.json @@ -0,0 +1,18 @@ +{ + "address_fixture": "https://dev-api.flymy.ai", + "stream_payload": { + "prompt": "You discover the last library in the world, hidden in a forgotten city. What secrets does it hold, and why is it protected by ancient guardians?", + "best_of": 1, + "max_tokens": 128, + "stop": "\"<|im_end|>\", \"<|user|>\"", + "temperature": 0.7, + "top_k": 10, + "top_p": 0.9, + "stream": true + }, + "auth": { + "model": "flymyai/vllm_stream", + "apikey_environ": "FMA_APIKEY" + }, + "output_field": "output" +} \ No newline at end of file