Skip to content

Commit

Permalink
chore: build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelint authored Jul 8, 2024
1 parent c258948 commit 4d9e8ce
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
pull_request:
workflow_call:
secrets:
OPENAI_API_KEY:
required: true
ANTHROPIC_API_KEY:
required: true

jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
# Models should be stored using LFS or downloaded in the pipeline for tests to be run
# - name: Run tests
# run: |
# poetry run pytest

- name: Build
run: |
pip install poetry
poetry build
- uses: actions/upload-artifact@v4
with:
path: ./dist
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish to PyPI

env:
PYPI_PACKAGE_NAME: langchain_llamacpp_chat_model
on:
release:
types:
- created

jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- name: Extract version from tag
id: extract_version
run: |
TAG_NAME=${{ github.event.release.tag_name }}
if [[ $TAG_NAME =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "VERSION=$VERSION" >> $GITHUB_ENV
else
echo "The tag $TAG_NAME is not in the expected format 'v<MAJOR>.<MINOR>.<PATCH>'"
exit 1
fi
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Update version in pyproject.toml
run: |
poetry version ${{ env.VERSION }}
# Models should be stored using LFS or downloaded in the pipeline for tests to be run
# - name: Run tests
# run: |
# poetry run pytest

- name: Build
run: |
poetry build
- uses: actions/upload-artifact@v4
with:
path: ./dist

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bump version to ${{ env.VERSION }}
branch: main

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ __pycache__/
*.pyi
*.pyw
*.pytest_cache

*.tar.gz
*.whl
12 changes: 10 additions & 2 deletions tests/test_functional/models_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
},
]

n_gpu_layers = (
0 # -1 to offload on GPU. Until GPU is supported on Github, must be run on CPU
)


def _model_local_path(model) -> str:
return os.path.join(
Expand All @@ -30,7 +34,11 @@ def _create_models_settings():
for model in models_to_test:
local_path = _model_local_path(model)
models.append(
ModelSettings(model=local_path, model_alias=model["alias"], n_gpu_layers=-1)
ModelSettings(
model=local_path,
model_alias=model["alias"],
n_gpu_layers=n_gpu_layers,
)
)

return models
Expand All @@ -41,7 +49,7 @@ def create_llama(request) -> Llama:

return Llama(
model_path=local_path,
n_gpu_layers=-1,
n_gpu_layers=n_gpu_layers,
)


Expand Down

0 comments on commit 4d9e8ce

Please sign in to comment.