docs/dev/contribute.md
!!! tip "Formatting change"
We've recently added automated formatting to our code base.
If you are dealing with merge-conflicts when opening a PR or updating your fork,
please first install pre-commit and run pre-commit run --all-files and try again.
{% include-markdown "../../CONTRIBUTING.md" start="<!-- INCLUSION START -->" end="<!-- INCLUSION END -->" %}
Wanna do more and actually contribute code? Great! Please see the following sections for tips and guidelines!
Please install the repository from source, following our usual instructions but add the [dev] option to the pip command (you can just run the command again):
pip install -e '.[dev]'
Then, make sure to set up pre-commit:
# cd to our repo root
pre-commit install
pre-commit will check for formatting and basic syntax errors before your commits.
!!! tip "Autofixes"
Most problems (including formatting) will be automatically fixed.
Therefore, if pre-commit/git commit fails on its first run, simply try running it a second time.
Some more autofixes can be enabled with the `--unsafe-fixes` option from [`ruff`](https://github.com/astral-sh/ruff):
```bash
pipx run ruff check --fix --unsafe-fixes
```
We provide a lot of tests that can be very helpful for rapid development. Run them with
pytest
Some of the tests might be slower than others. You can exclude them with
pytest -m "not slow"
You can run all tests in parallel with pytest-xdist:
pytest -n auto
If you are using VSCode, you might want to add the following two files:
<details> <summary><code>.vscode/launch.json</code></summary>--8<-- "docs/dev/vscode_launch.json"
--8<-- "docs/dev/vscode_settings.json"
We recommend to install pdbpp for some improved debugger features:
pip install pdbpp
Set breakpoints with breakpoint() and then run sweagent with pdb:
pdb -m sweagent <command> -- <more command line arguments> # (1)!
-- before the options passed to sweagent. This is to separate
options passed to pdb from those that are passed to sweagent.When working on a test that fails, you can use
pytest -k name_of_test -s --capture=no --log-cli-level=DEBUG
to see all debug output from the agent.
Simply run
# cd repo root
mkdocs serve
and point your browser to port 8000 or click one of the links in the output.