Skip to content

Commit

Permalink
chore: make python test dependencies optional (#815)
Browse files Browse the repository at this point in the history
* Adds an optional [dev] dependency flag to the root pyproject.toml for test dependencies
  • Loading branch information
CollectiveUnicorn committed Jul 29, 2024
1 parent 4bf9124 commit 89ff0a6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
python-version-file: 'pyproject.toml'

- name: Install Python Deps
run: python -m pip install "."
run: python -m pip install ".[dev]"

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: docker run -p 50051:50051 -d --name=repeater ghcr.io/defenseunicorns/leapfrogai/repeater:dev

- name: Install Python Deps
run: pip install "." "src/leapfrogai_api" "src/leapfrogai_sdk"
run: pip install ".[dev]" "src/leapfrogai_api" "src/leapfrogai_sdk"

- name: Run Pytest
run: python -m pytest tests/pytest -v
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ license = {file = "LICENSE"}
dependencies = [ # Dev dependencies needed for all of lfai
"openai",
"pip-tools == 7.3.0",
"pytest",
"pytest-asyncio",
"httpx",
"ruff",
"python-dotenv",
"pytest-asyncio",
"locust",
"requests-toolbelt"
"python-dotenv"
]
requires-python = "~=3.11"

[project.optional-dependencies]
dev = ["locust", "pytest-asyncio", "requests-toolbelt", "pytest"]

[tool.pip-tools]
generate-hashes = true

Expand Down
1 change: 1 addition & 0 deletions src/leapfrogai_api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ install-api:
python -m pip install ../../src/leapfrogai_sdk
@cd ${MAKEFILE_DIR} && \
python -m pip install -e .
python -m pip install "../../.[dev]"

dev-run-api:
@cd ${MAKEFILE_DIR} && \
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ make build-llama-cpp-python
uds zarf package deploy zarf-package-llama-cpp-python-*.tar.zst

# Install the python dependencies
python -m pip install "."
python -m pip install ".[dev]"

# Run the tests!
# NOTE: Each model backend has its own e2e test files
Expand Down
13 changes: 9 additions & 4 deletions tests/load/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ Before running the tests, ensure that your API URL and bearer token are properly

To start the Locust web interface and run the tests:

1. Navigate to the directory containing `loadtest.py`.
1. Install dependencies from the project root.
```bash
pip install ".[dev]"
```

2. Navigate to the directory containing `loadtest.py`.

2. Execute the following command:
3. Execute the following command:
```bash
locust -f loadtest.py --web-port 8089
```

3. Open your web browser and go to `http://0.0.0.0:8089`.
4. Open your web browser and go to `http://0.0.0.0:8089`.

4. Use the Locust web interface to configure and run your tests:
5. Use the Locust web interface to configure and run your tests:
- Set the number of users to simulate
- Set the spawn rate (users per second)
- Choose the host to test against (should match your `API_URL`)
Expand Down

0 comments on commit 89ff0a6

Please sign in to comment.