uv migration

This commit is contained in:
Dan Davison
2025-07-29 14:41:39 -04:00
parent 3b7a704c5e
commit 4102f9aeca
11 changed files with 107 additions and 132 deletions

View File

@@ -8,40 +8,32 @@ This document provides guidelines for contributing to `temporal-ai-agent`. All s
We use `black` for code formatting and `isort` for import sorting to maintain a consistent codebase.
- **Format code:**
```bash
poetry run poe format
```
Or manually:
```bash
poetry run black .
poetry run isort .
uv run black .
uv run isort .
```
Please format your code before committing.
### Linting & Type Checking
We use `mypy` for static type checking and other linters configured via `poe the poet`.
- **Run linters and type checks:**
We use `mypy` for static type checking.
- **Run type checks:**
```bash
poetry run poe lint
```
Or manually for type checking:
```bash
poetry run mypy --check-untyped-defs --namespace-packages .
uv run mypy --check-untyped-defs --namespace-packages .
```
Ensure all linting and type checks pass before submitting a pull request.
## Testing
Comprehensive testing is crucial for this project. We use `pytest` and Temporal's testing framework.
- **Install test dependencies** (if not already done with `poetry install --with dev`):
- **Install test dependencies:**
```bash
poetry install --with dev
uv sync
```
- **Run all tests:**
```bash
poetry run pytest
uv run pytest
```
- **Run tests with time-skipping (recommended for faster execution, especially in CI):**
```bash
poetry run pytest --workflow-environment=time-skipping
uv run pytest --workflow-environment=time-skipping
```
For detailed information on test categories, running specific tests, test environments, coverage, and troubleshooting, please refer to:
@@ -73,7 +65,7 @@ When you're ready to submit your changes:
1. Push your branch to the remote repository.
2. Open a Pull Request (PR) against the `main` branch.
3. **Describe your changes:** Clearly explain what you changed and why. Reference any related issues.
4. **Ensure tests pass:** All CI checks, including tests and linters, must pass. The command `poetry run pytest --workflow-environment=time-skipping` is a good one to run locally.
4. **Ensure tests pass:** All CI checks, including tests and linters, must pass. The command `uv run pytest --workflow-environment=time-skipping` is a good one to run locally.
5. **Request review:** Request a review from one or more maintainers.
## Reporting Bugs

View File

@@ -22,8 +22,6 @@ We've provided a Makefile to simplify the setup and running of the application.
```bash
# Initial setup
make setup # Creates virtual environment and installs dependencies
make setup-venv # Creates virtual environment only
make install # Installs all dependencies
# Running the application
make run-worker # Starts the Temporal worker
@@ -159,24 +157,22 @@ Default urls:
**Python Backend**
Requires [Poetry](https://python-poetry.org/) to manage dependencies.
Requires [`uv`](https://docs.astral.sh/uv/) to manage dependencies.
1. `python -m venv venv`
1. Install uv: `curl -LsSf https://astral.sh/uv/install.sh | sh`
2. `source venv/bin/activate`
3. `poetry install`
2. `uv sync`
Run the following commands in separate terminal windows:
1. Start the Temporal worker:
```bash
poetry run python scripts/run_worker.py
uv run python scripts/run_worker.py
```
2. Start the API server:
```bash
poetry run uvicorn api.main:app --reload
uv run uvicorn api.main:app --reload
```
Access the API at `/docs` to see the available endpoints.
@@ -261,7 +257,7 @@ NOTE: This goal was developed for an on-stage demo and has failure (and its reso
Required to search and book trains!
```bash
poetry run python thirdparty/train_api.py
uv run python thirdparty/train_api.py
# example url
# http://localhost:8080/api/search?from=london&to=liverpool&outbound_time=2025-04-18T09:00:00&inbound_time=2025-04-20T09:00:00
@@ -273,7 +269,7 @@ poetry run python thirdparty/train_api.py
These are Python activities that fail (raise NotImplemented) to show how Temporal handles a failure. You can run these activities with.
```bash
poetry run python scripts/run_legacy_worker.py
uv run python scripts/run_legacy_worker.py
```
The activity will fail and be retried infinitely. To rescue the activity (and its corresponding workflows), kill the worker and run the .NET one in the section below.
@@ -328,8 +324,8 @@ For more details, check out [adding goals and tools guide](./adding-goals-and-to
[ ] Select an LLM and add your API key to `.env` <br />
[ ] (Optional) set your starting goal and goal category in `.env` <br />
[ ] (Optional) configure your Temporal Cloud settings in `.env` <br />
[ ] `poetry run python scripts/run_worker.py` <br />
[ ] `poetry run uvicorn api.main:app --reload` <br />
[ ] `uv run python scripts/run_worker.py` <br />
[ ] `uv run uvicorn api.main:app --reload` <br />
[ ] `cd frontend`, `npm install`, `npx vite` <br />
[ ] Access the UI at `http://localhost:5173` <br />

View File

@@ -6,17 +6,17 @@ This guide provides instructions for running the comprehensive test suite for th
1. **Install dependencies**:
```bash
poetry install --with dev
uv sync
```
2. **Run all tests**:
```bash
poetry run pytest
uv run pytest
```
3. **Run with time-skipping for faster execution**:
```bash
poetry run pytest --workflow-environment=time-skipping
uv run pytest --workflow-environment=time-skipping
```
## Test Categories
@@ -39,33 +39,33 @@ This guide provides instructions for running the comprehensive test suite for th
```bash
# Run only activity tests
poetry run pytest tests/test_tool_activities.py -v
uv run pytest tests/test_tool_activities.py -v
# Run only workflow tests
poetry run pytest tests/test_agent_goal_workflow.py -v
uv run pytest tests/test_agent_goal_workflow.py -v
# Run a specific test
poetry run pytest tests/test_tool_activities.py::TestToolActivities::test_sanitize_json_response -v
uv run pytest tests/test_tool_activities.py::TestToolActivities::test_sanitize_json_response -v
# Run tests matching a pattern
poetry run pytest -k "validation" -v
uv run pytest -k "validation" -v
```
## Test Environment Options
### Local Environment (Default)
```bash
poetry run pytest --workflow-environment=local
uv run pytest --workflow-environment=local
```
### Time-Skipping Environment (Recommended for CI)
```bash
poetry run pytest --workflow-environment=time-skipping
uv run pytest --workflow-environment=time-skipping
```
### External Temporal Server
```bash
poetry run pytest --workflow-environment=localhost:7233
uv run pytest --workflow-environment=localhost:7233
```
## Environment Variables
@@ -122,7 +122,7 @@ tests/test_tool_activities.py::TestToolActivities::test_get_wf_env_vars_default_
### Common Issues
1. **Module not found errors**: Run `poetry install --with dev`
1. **Module not found errors**: Run `uv sync`
2. **Async warnings**: These are expected with pytest-asyncio and can be ignored
3. **Test timeouts**: Use `--workflow-environment=time-skipping` for faster execution
4. **Import errors**: Check that you're running tests from the project root directory
@@ -131,19 +131,19 @@ tests/test_tool_activities.py::TestToolActivities::test_get_wf_env_vars_default_
Enable verbose logging:
```bash
poetry run pytest --log-cli-level=DEBUG -s
uv run pytest --log-cli-level=DEBUG -s
```
Run with coverage:
```bash
poetry run pytest --cov=workflows --cov=activities
uv run pytest --cov=workflows --cov=activities
```
## Continuous Integration
For CI environments, use:
```bash
poetry run pytest --workflow-environment=time-skipping --tb=short
uv run pytest --workflow-environment=time-skipping --tb=short
```
## Additional Resources