Skip to content
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

chore: setup workspace for exchange #105

Merged
merged 3 commits into from
Oct 2, 2024
Merged
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
79 changes: 76 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]

jobs:
build:
exchange:
runs-on: ubuntu-latest

steps:
Expand All @@ -19,9 +19,82 @@ jobs:

- name: Ruff
run: |
uvx ruff check
uvx ruff format --check
uvx ruff check packages/exchange
uvx ruff format packages/exchange --check

- name: Run tests
working-directory: ./packages/exchange
run: |
uv run pytest tests -m 'not integration'

goose:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Source Cargo Environment
run: source $HOME/.cargo/env

- name: Ruff
run: |
uvx ruff check src tests
uvx ruff format src tests --check

- name: Run tests
run: |
uv run pytest tests -m 'not integration'


# This runs integration tests of the OpenAI API, using Ollama to host models.
# This lets us test PRs from forks which can't access secrets like API keys.
ollama:
runs-on: ubuntu-latest

strategy:
matrix:
python-version:
# Only test the lastest python version.
- "3.12"
ollama-model:
# For quicker CI, use a smaller, tool-capable model than the default.
- "qwen2.5:0.5b"

steps:
- uses: actions/checkout@v4

- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Source Cargo Environment
run: source $HOME/.cargo/env

- name: Set up Python
run: uv python install ${{ matrix.python-version }}

- name: Install Ollama
run: curl -fsSL https://ollama.com/install.sh | sh

- name: Start Ollama
run: |
# Run the background, in a way that survives to the next step
nohup ollama serve > ollama.log 2>&1 &

# Block using the ready endpoint
time curl --retry 5 --retry-connrefused --retry-delay 1 -sf http://localhost:11434

# Tests use OpenAI which does not have a mechanism to pull models. Run a
# simple prompt to (pull and) test the model first.
- name: Test Ollama model
run: ollama run $OLLAMA_MODEL hello || cat ollama.log
env:
OLLAMA_MODEL: ${{ matrix.ollama-model }}

- name: Run Ollama tests
run: uv run pytest tests -m integration -k ollama
working-directory: ./packages/exchange
env:
OLLAMA_MODEL: ${{ matrix.ollama-model }}
50 changes: 50 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish

# A release on goose will also publish exchange, if it has updated
# This means in some cases we may need to make a bump in goose without other changes to release exchange
on:
release:
types: [published]

jobs:
publish:
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get current version from pyproject.toml
id: get_version
run: |
echo "VERSION=$(grep -m 1 'version =' "pyproject.toml" | awk -F'"' '{print $2}')" >> $GITHUB_ENV

- name: Extract tag version
id: extract_tag
run: |
TAG_VERSION=$(echo "${{ github.event.release.tag_name }}" | sed -E 's/v(.*)/\1/')
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV

- name: Check if tag matches version from pyproject.toml
id: check_tag
run: |
if [ "${{ env.TAG_VERSION }}" != "${{ env.VERSION }}" ]; then
echo "::error::Tag version (${{ env.TAG_VERSION }}) does not match version in pyproject.toml (${{ env.VERSION }})."
exit 1
fi

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v1
with:
version: "latest"

- name: Build Package
run: |
uv build -o dist --package goose-ai
uv build -o dist --package ai-exchange

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
47 changes: 0 additions & 47 deletions .github/workflows/pypi_release.yaml

This file was deleted.

94 changes: 26 additions & 68 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
# Contributing

<p>
<a href="#prerequisites">Prerequisites</a> •
<a href="#developing-and-testing">Developing and testing</a> •
<a href="#building-from-source">Building from source</a> •
<a href="#developing-goose-plugins">Developing goose-plugins</a> •
<a href="#running-ai-exchange-from-source">Running ai-exchange from source</a> •
<a href="#evaluations">Evaluations</a> •
<a href="#conventional-commits">Conventional Commits</a>
</p>

We welcome Pull Requests for general contributions. If you have a larger new feature or any questions on how to develop a fix, we recommend you open an [issue][issues] before starting.

## Prerequisites

Goose uses [uv][uv] for dependency management, and formats with [ruff][ruff].
Clone goose and make sure you have installed `uv` to get started. When you use
`uv` below in your local goose directly, it will automatically setup the virtualenv
and install dependencies.

We provide a shortcut to standard commands using [just][just] in our `justfile`.

Goose uses [uv][uv] for dependency management, and formats with [ruff][ruff] - install UV first: https://pypi.org/project/uv/
## Development

## Developing and testing
Now that you have a local environment, you can make edits and run our tests!

Now that you have a local environment, you can make edits and run our tests.
### Run Goose

### Creating plugins
If you've made edits and want to try them out, use

Goose is highly configurable through plugins - it reads in modules that its dependencies install (e.g.`goose-plugins`) and uses those that start with certain prefixes (e.g. `goose.toolkit`) to inject their functionality. For example, you will note that Goose's CLI is actually merged with additional CLI methods that are exported from `goose-plugins`.
```
uv run goose session start
```

If you are building a net new feature, you should try to fit it inside a plugin. Goose and `goose-plugins` both support plugins, but there's an important difference in how contributions to each are reviewed. Use the guidelines below to decide where to contribute:
or other `goose` commands.

**When to Add to Goose**:
If you want to run your local changes but in another directory, you can use the path in
the virtualenv created by uv:

Plugins added directly to Goose are subject to rigorous review. This is because they are part of the core system and need to meet higher standards for stability, performance, and maintainability, often being validated through benchmarking.
```
alias goosedev=`uv run which goose`
```

**When to Add to `goose-plugins`:**
You can then run `goosedev` from another dir and it will use your current changes.

Plugins in `goose-plugins` undergo less detailed reviews and are more modular or experimental. They can prove their value through usage or iteration over time and may be eventually moved over to Goose.
### Run Tests

To see how to add a toolkit, see the [toolkits documentation][adding-toolkit].
To run the test suite against your edges, use `pytest`:

### Running tests
```sh
uv run pytest tests -m "not integration"
```
Expand All @@ -49,58 +48,17 @@ or, as a shortcut,
just test
```

## Building from source

If you want to develop features on `goose`:

1. Clone Goose:
```bash
git clone [email protected]:block-open-source/goose.git ~/Development/goose
```
2. Get `uv` with `brew install uv`
3. Set up your Python virtualenv:
```bash
cd ~/Development/goose
uv sync
uv venv
```
4. Run the `source` command that follows the `uv venv` command to activate the virtualenv.
5. Run Goose:
```bash
uv run goose session start # or any of goose's commands (e.g. goose --help)
```
## Exchange

### Running from source
The lower level generation behind goose is powered by the [`exchange`][ai-exchange] package, also in this repo.

When you build from source you may want to run it from elsewhere.

1. Run `uv sync` as above
2. Run ```export goose_dev=`uv run which goose` ```
3. You can use that from anywhere in your system, for example `cd ~/ && $goose_dev session start`, or from your path if you like (advanced users only) to be running the latest.

## Developing goose-plugins

1. Clone the `goose-plugins` repo:
```bash
git clone [email protected]:block-open-source/goose-plugins.git ~/Development/goose-plugins
```
2. Follow the steps for creating a virtualenv in the `goose` section above
3. Install `goose-plugins` in `goose`. This means any changes to `goose-plugins` in this folder will immediately be reflected in `goose`:
```bash
uv add --editable ~/Development/goose-plugins
```
4. Make your changes in `goose-plugins`, add the toolkit to the `profiles.yaml` file and run `uv run goose session --start` to see them in action.

## Running ai-exchange from source

goose depends heavily on the [`ai-exchange`][ai-exchange] project, you can clone that repo and then work on both by running:
Thanks to `uv` workspaces, any changes you make to `exchange` will be reflected in using your local goose. To run tests
for exchange, head to `packages/exchange` and run tests just like above

```sh
uv add --editable <path/to/cloned/exchange>
uv run pytest tests -m "not integration"
```

then when you run goose with `uv run goose session start` it will be running it all from source.

## Evaluations

Given that so much of Goose involves interactions with LLMs, our unit tests only go so far to confirming things work as intended.
Expand Down
Loading