Skip to content

Commit f1bc272

Browse files
authored
Merge pull request #13 from meta-llama/ci-cd, github action and linter
Unit, integration tests and CI/CD Implementation
2 parents e57369b + da7aac1 commit f1bc272

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3883
-1477
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
OPENAI_API_KEY=your_openai_api_key_here
22
OPENROUTER_API_KEY=your_openrouter_api_key_here
3-
CEREBRAS_API_KEY=your_cerebras_api_key_here
3+
CEREBRAS_API_KEY=your_cerebras_api_key_here
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI with Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.10', '3.11']
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[dev]"
28+
pip install pytest-cov codecov
29+
30+
- name: Lint code
31+
run: |
32+
black --check src tests
33+
isort --check-only --profile black src tests
34+
35+
- name: Run tests with coverage
36+
run: |
37+
pytest --cov=src/llama_prompt_ops --cov-report=xml tests/
38+
39+
- name: Upload coverage to Codecov
40+
uses: codecov/codecov-action@v3
41+
with:
42+
file: ./coverage.xml
43+
fail_ci_if_error: false

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.10'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install pre-commit
24+
25+
- name: Run pre-commit
26+
run: |
27+
pre-commit run --all-files
28+
29+
test:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
python-version: ['3.10', '3.11']
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Set up Python ${{ matrix.python-version }}
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -e ".[dev]"
47+
48+
- name: Run tests
49+
env:
50+
PROMPT_OPS_TEST_ENV: "1"
51+
run: |
52+
pytest tests/

.github/workflows/lint.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.10'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install pre-commit
24+
pip install -e ".[dev]"
25+
26+
- name: Run pre-commit on all files
27+
run: |
28+
pre-commit run --all-files
29+
30+
- name: What to do if this action fails
31+
if: ${{ failure() }}
32+
run: |
33+
echo "To fix these issues locally:"
34+
echo "1. Install pre-commit: pip install pre-commit"
35+
echo "2. Set up pre-commit hooks: pre-commit install"
36+
echo "3. Run pre-commit on all files: pre-commit run --all-files"
37+
echo "4. Commit the changes and push again"
38+
39+
black-check:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v3
43+
44+
- name: Set up Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: '3.10'
48+
49+
- name: Install dependencies
50+
run: |
51+
python -m pip install --upgrade pip
52+
pip install black>=25.1.0
53+
54+
- name: Run Black
55+
run: |
56+
black --check src tests
57+
58+
isort-check:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v3
62+
63+
- name: Set up Python
64+
uses: actions/setup-python@v4
65+
with:
66+
python-version: '3.10'
67+
68+
- name: Install dependencies
69+
run: |
70+
python -m pip install --upgrade pip
71+
pip install isort>=6.0.0
72+
73+
- name: Run isort
74+
run: |
75+
isort --check-only --profile black src tests

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
confirm_publish:
9+
description: 'Confirm publishing to PyPI'
10+
required: true
11+
default: 'no'
12+
type: choice
13+
options:
14+
- 'yes'
15+
- 'no'
16+
17+
jobs:
18+
deploy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.10'
29+
cache: 'pip'
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install build twine
35+
36+
- name: Verify version
37+
run: |
38+
# Extract version from pyproject.toml
39+
VERSION=$(grep -m 1 'version =' pyproject.toml | cut -d '"' -f 2)
40+
echo "Package version: $VERSION"
41+
42+
# Check if this version already exists on PyPI
43+
if pip index versions llama-prompt-ops 2>/dev/null | grep -q "$VERSION"; then
44+
echo "Error: Version $VERSION already exists on PyPI"
45+
exit 1
46+
fi
47+
echo "Version check passed: $VERSION is not on PyPI yet"
48+
49+
- name: Build package
50+
run: python -m build
51+
52+
- name: Check package
53+
run: twine check dist/*
54+
55+
- name: Publish to PyPI
56+
if: github.event_name == 'release' || github.event.inputs.confirm_publish == 'yes'
57+
env:
58+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
59+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
60+
run: twine upload dist/*

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/psf/black
11+
rev: 25.1.0
12+
hooks:
13+
- id: black
14+
language_version: python3
15+
16+
- repo: https://github.com/pycqa/isort
17+
rev: 6.0.1
18+
hooks:
19+
- id: isort
20+
args: ["--profile", "black"]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ We use GitHub issues to track public bugs. Please ensure your description is cle
2323
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
2424

2525
## License
26-
By contributing to llama-prompt-ops, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.
26+
By contributing to llama-prompt-ops, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1919
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2020
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2121
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<p align="center">
88
<a href="https://llama.developer.meta.com/?utm_source=llama-prompt-ops&utm_medium=readme&utm_campaign=main"><img src="https://img.shields.io/badge/Llama_API-Join_Waitlist-brightgreen?logo=meta" /></a>
99
<a href="https://llama.developer.meta.com/docs?utm_source=llama-prompt-ops&utm_medium=readme&utm_campaign=main"><img src="https://img.shields.io/badge/Llama_API-Documentation-4BA9FE?logo=meta" /></a>
10-
10+
1111
</p>
1212

1313
<p align="center">
1414
<a href="https://github.com/meta-llama/llama-models/blob/main/models/?utm_source=llama-prompt-ops&utm_medium=readme&utm_campaign=main"><img alt="Llama Model cards" src="https://img.shields.io/badge/Llama_OSS-Model_cards-green?logo=meta" /></a>
1515
<a href="https://www.llama.com/docs/overview/?utm_source=llama-prompt-ops&utm_medium=readme&utm_campaign=main"><img alt="Llama Documentation" src="https://img.shields.io/badge/Llama_OSS-Documentation-4BA9FE?logo=meta" /></a>
1616
<a href="https://huggingface.co/meta-llama"><img alt="Hugging Face meta-llama" src="https://img.shields.io/badge/Hugging_Face-meta--llama-yellow?logo=huggingface" /></a>
17-
17+
1818
</p>
1919
<p align="center">
2020
<a href="https://github.com/meta-llama/synthetic-data-kit"><img alt="Llama Tools Syntethic Data Kit" src="https://img.shields.io/badge/Llama_Tools-synthetic--data--kit-orange?logo=meta" /></a>
@@ -43,12 +43,12 @@ To get started with llama-prompt-ops, you'll need:
4343
## How It Works
4444

4545
```
46-
┌──────────────────────────┐ ┌──────────────────────────┐ ┌────────────────────┐
47-
│ Existing System Prompt │ │ set(query, responses) │ │ YAML Configuration │
48-
└────────────┬─────────────┘ └─────────────┬────────────┘ └───────────┬────────┘
49-
│ │ │
50-
│ │ │
51-
▼ ▼ ▼
46+
┌──────────────────────────┐ ┌──────────────────────────┐ ┌────────────────────┐
47+
│ Existing System Prompt │ │ set(query, responses) │ │ YAML Configuration │
48+
└────────────┬─────────────┘ └─────────────┬────────────┘ └───────────┬────────┘
49+
│ │ │
50+
│ │ │
51+
▼ ▼ ▼
5252
┌────────────────────────────────────────────────────────────────────┐
5353
│ llama-prompt-ops migrate │
5454
└────────────────────────────────────────────────────────────────────┘
@@ -111,7 +111,7 @@ cd my-project
111111

112112
### Step 3: Set Up Your API Key
113113

114-
Add your API key to the `.env` file:
114+
Add your API key to the `.env` file:
115115

116116
```bash
117117
OPENROUTER_API_KEY=your_key_here
@@ -125,7 +125,7 @@ The optimization will take about 5 minutes.
125125
llama-prompt-ops migrate # defaults to config.yaml if --config not specified
126126
```
127127

128-
Done! The optimized prompt will be saved to the `results` directory with performance metrics comparing the original and optimized versions.
128+
Done! The optimized prompt will be saved to the `results` directory with performance metrics comparing the original and optimized versions.
129129

130130
To read more about this use case, we go into more detail in [Basic Tutorial](./docs/basic/readme.md).
131131

configs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# llama-prompt-ops Configuration Files
22

3-
This directory contains example YAML configuration files for the llama-prompt-ops tool. These configuration files define how llama-prompt-ops processes your data, optimizes prompts, and evaluates results.
3+
This directory contains example YAML configuration files for the llama-prompt-ops tool. These configuration files define how llama-prompt-ops processes your data, optimizes prompts, and evaluates results.

0 commit comments

Comments
 (0)