diff --git a/.github/workflows/poetry-build.yml b/.github/workflows/poetry-build.yml deleted file mode 100644 index d039e66..0000000 --- a/.github/workflows/poetry-build.yml +++ /dev/null @@ -1,65 +0,0 @@ -# Builds the `hfppl` poetry environment and tests importing the library -# Adapted from: https://github.com/marketplace/actions/install-poetry-action - -name: Poetry build test - -on: - push: - branches: [ "main" ] - pull_request: - types: [opened, reopened] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - #---------------------------------------------- - # check-out repo and set-up python - #---------------------------------------------- - - name: Check out repository - uses: actions/checkout@v4 - - name: Set up python - id: setup-python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - #---------------------------------------------- - # ----- install & configure poetry ----- - #---------------------------------------------- - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - virtualenvs-path: .venv - installer-parallel: true - #---------------------------------------------- - # load cached venv if cache exists - #---------------------------------------------- - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: .venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - #---------------------------------------------- - # install dependencies if cache does not exist - #---------------------------------------------- - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - #---------------------------------------------- - # install your root project, if required - #---------------------------------------------- - - name: Install project - run: poetry install --no-interaction - #---------------------------------------------- - # test import - #---------------------------------------------- - - name: Test import - run: | - source .venv/bin/activate - python -c "import hfppl" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..999ce20 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,53 @@ +# Builds the `hfppl` poetry environment and runs all tests +# Adapted from: https://github.com/marketplace/actions/install-poetry-action + +name: Codebase tests + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + build: + runs-on: ParallelHoss + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up python + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install Poetry + uses: snok/install-poetry@v1 + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install project + run: poetry install --no-interaction + + - name: Run tests + run: | + eval $(poetry env activate) + pytest -v --cov=hfppl --cov-report=json + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: false + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.json + slug: probcomp/hfppl diff --git a/.gitignore b/.gitignore index a33be2e..575ef12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +coverage.json + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/README.md b/README.md index 3be384f..4c421aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # LLaMPPL + HuggingFace [![docs](https://github.com/probcomp/hfppl/actions/workflows/docs.yml/badge.svg)](https://probcomp.github.io/hfppl) +[![Tests](https://github.com/probcomp/hfppl/actions/workflows/pytest.yml/badge.svg)](https://github.com/probcomp/hfppl/actions/workflows/pytest.yml) +[![codecov](https://codecov.io/gh/probcomp/hfppl/graph/badge.svg?token=414EHUC2P3)](https://codecov.io/gh/probcomp/hfppl) + + LLaMPPL is a research prototype for language model probabilistic programming: specifying language generation tasks by writing probabilistic programs that combine calls to LLMs, symbolic program logic, and probabilistic conditioning. To solve these tasks, LLaMPPL uses a specialized sequential Monte Carlo inference algorithm. This technique, SMC steering, is described in [our recent workshop abstract](https://arxiv.org/abs/2306.03081). diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7694d30 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: auto + threshold: 3% diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..efa46ec --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index d0d980b..b1f5cc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ protobuf = "^5.27.2" nltk = {version = "^3.8.1", optional = true} pre-commit = "^3.7.1" ipykernel = "^6.29.5" -genlm-backend = { git = "https://github.com/chi-collective/genlm-backend.git" } +genlm-backend = "^0.0.1" [tool.poetry.group.vllm] optional = true @@ -31,6 +31,8 @@ vllm = "^0.6.6" [tool.poetry.group.dev.dependencies] pytest = "*" pytest-benchmark = "*" +pytest-cov = "*" +pytest-xdist = "^3.2.0" black = "^23.12.1" pre-commit = "^3.6.0" jupyterlab = "^4.0.9"