Skip to content

Migrate from hatch to uv for developing/contributing #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/workflows/test-lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }} # Explicitly define which commit to checkout
persist-credentials: false # Don't persist credentials for subsequent actions
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.7.6"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --no-cache-dir hatch
run: uv sync --locked --extra dev --extra anthropic --extra litellm --extra llamaapi --extra ollama
- name: Run Unit tests
id: tests
run: hatch test tests --cover
run: uvx pytest --cov --cov-config=pyproject.toml
continue-on-error: false
lint:
name: Lint
Expand All @@ -81,17 +84,20 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.7.6"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install dependencies
run: |
pip install --no-cache-dir hatch

run: uv sync --locked --extra dev
- name: Run lint
id: lint
run: hatch run test-lint
run: |
uvx ruff check
continue-on-error: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__*
.pytest_cache
.ruff_cache
*.bak
CONTEXT.md
23 changes: 8 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
repos:
- repo: local
hooks:
- id: hatch-format
- id: uv-format
name: Format code
entry: hatch fmt --formatter
entry: python scripts/format.py
language: system
pass_filenames: false
types: [python]
stages: [pre-commit]
- id: hatch-lint
- id: uv-lint
name: Lint code
entry: hatch run test-lint
entry: python scripts/lint.py
language: system
pass_filenames: false
types: [python]
stages: [pre-commit]
- id: hatch-test-lint
name: Type linting
entry: hatch run test-lint
language: system
pass_filenames: false
types: [ python ]
stages: [ pre-commit ]
- id: hatch-test
- id: uv-test
name: Unit tests
entry: hatch test
entry: python scripts/test.py
language: system
pass_filenames: false
types: [python]
stages: [pre-commit]
- id: commitizen-check
name: Check commit message
entry: hatch run cz check --commit-msg-file
entry: cz check --commit-msg-file
language: system
stages: [commit-msg]
stages: [commit-msg]
81 changes: 51 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,85 @@ documentation, we greatly value feedback and contributions from our community.
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
information to effectively respond to your bug report or contribution.


## Reporting Bugs/Feature Requests

We welcome you to use the [Bug Reports](../../issues/new?template=bug_report.yml) file to report bugs or [Feature Requests](../../issues/new?template=feature_request.yml) to suggest features.

For a list of known bugs and feature requests:

- Check [Bug Reports](../../issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) for currently tracked issues
- See [Feature Requests](../../issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement) for requested enhancements

When filing an issue, please check for already tracked items

Please try to include as much information as you can. Details like these are incredibly useful:

* A reproducible test case or series of steps
* The version of our code being used (commit ID)
* Any modifications you've made relevant to the bug
* Anything unusual about your environment or deployment

- A reproducible test case or series of steps
- The version of our code being used (commit ID)
- Any modifications you've made relevant to the bug
- Anything unusual about your environment or deployment

## Development Environment

This project uses [hatchling](https://hatch.pypa.io/latest/build/#hatchling) as the build backend and [hatch](https://hatch.pypa.io/latest/) for development workflow management.
This project uses [uv_build](https://docs.astral.sh/uv/configuration/build-backend/) as the build backend and [uv](https://github.com/astral-sh/uv) for development workflow management.

### Setting Up Your Development Environment

1. Install development dependencies:
1. Install uv:

```bash
pip install -e ".[dev]" && pip install -e ".[litellm]
pip install uv
```

2. Set up pre-commit hooks:
2. Create a virtual environment and install development dependencies:

```bash
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]" --prerelease=allow
```

3. Set up pre-commit hooks:

```bash
pre-commit install -t pre-commit -t commit-msg
```

This will automatically run formatters and convention commit checks on your code before each commit.

3. Run code formatters manually:
4. Run code formatters manually:

```bash
hatch fmt --formatter
python scripts/format.py
```

4. Run linters:
5. Run linters:

```bash
hatch fmt --linter
python scripts/lint.py
```

5. Run unit tests:
6. Run unit tests:

```bash
hatch test
python scripts/test.py
```

6. Run integration tests:
7. Run integration tests:

```bash
hatch run test-integ
python scripts/test_integ.py
```

8. Build the package:

```bash
uv build
```

### Pre-commit Hooks

We use [pre-commit](https://pre-commit.com/) to automatically run quality checks before each commit. The hook will run `hatch run format`, `hatch run lint`, `hatch run test`, and `hatch run cz check` on when you make a commit, ensuring code consistency.
We use [pre-commit](https://pre-commit.com/) to automatically run quality checks before each commit. The hook will run formatting, linting, and tests when you make a commit, ensuring code consistency.

The pre-commit hook is installed with:

Expand All @@ -81,23 +101,24 @@ pre-commit run --all-files
### Code Formatting and Style Guidelines

We use the following tools to ensure code quality:

1. **ruff** - For formatting and linting
2. **mypy** - For static type checking

These tools are configured in the [pyproject.toml](./pyproject.toml) file. Please ensure your code passes all linting and type checks before submitting a pull request:

```bash
# Run all checks
hatch fmt --formatter
hatch fmt --linter
python scripts/format.py
python scripts/lint.py
```

If you're using an IDE like VS Code or PyCharm, consider configuring it to use these tools automatically.

For additional details on styling, please see our dedicated [Style Guide](./STYLE_GUIDE.md).


## Contributing via Pull Requests

Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:

1. You are working against the latest source on the *main* branch.
Expand All @@ -108,31 +129,31 @@ To send us a pull request, please:

1. Create a branch.
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3. Format your code using `hatch fmt --formatter`.
4. Run linting checks with `hatch fmt --linter`.
5. Ensure local tests pass with `hatch test` and `hatch run test-integ`.
3. Format your code using `python scripts/format.py`.
4. Run linting checks with `python scripts/lint.py`.
5. Ensure local tests pass with `python scripts/test.py` and `python scripts/test_integ.py`.
6. Commit to your branch using clear commit messages following the [Conventional Commits](https://www.conventionalcommits.org) specification.
7. Send us a pull request, answering any default questions in the pull request interface.
8. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.


## Finding contributions to work on

Looking at the existing issues is a great way to find something to contribute to.

You can check:

- Our known bugs list in [Bug Reports](../../issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) for issues that need fixing
- Feature requests in [Feature Requests](../../issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement) for new functionality to implement


## Code of Conduct

This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
opensource-codeofconduct@amazon.com with any additional questions or comments.

<opensource-codeofconduct@amazon.com> with any additional questions or comments.

## Security issue notifications
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.

## Licensing

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ response = agent("Tell me about Agentic AI")
```

Built-in providers:
- [Amazon Bedrock](https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/)
- [Anthropic](https://strandsagents.com/latest/user-guide/concepts/model-providers/anthropic/)
- [LiteLLM](https://strandsagents.com/latest/user-guide/concepts/model-providers/litellm/)
- [LlamaAPI](https://strandsagents.com/latest/user-guide/concepts/model-providers/llamaapi/)
- [Ollama](https://strandsagents.com/latest/user-guide/concepts/model-providers/ollama/)

- [Amazon Bedrock](https://strandsagents.com/latest/user-guide/concepts/model-providers/amazon-bedrock/)
- [Anthropic](https://strandsagents.com/latest/user-guide/concepts/model-providers/anthropic/)
- [LiteLLM](https://strandsagents.com/latest/user-guide/concepts/model-providers/litellm/)
- [LlamaAPI](https://strandsagents.com/latest/user-guide/concepts/model-providers/llamaapi/)
- [Ollama](https://strandsagents.com/latest/user-guide/concepts/model-providers/ollama/)

Custom providers can be implemented using [Custom Providers](https://strandsagents.com/latest/user-guide/concepts/model-providers/custom_model_provider/)

Expand Down Expand Up @@ -181,5 +182,6 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
## ⚠️ Preview Status

Strands Agents is currently in public preview. During this period:

- APIs may change as we refine the SDK
- We welcome feedback and contributions
Loading