Skip to content

Commit ff84a44

Browse files
finitearthtimo282mo374z
authored
Added Features: Prompt Creation and Opro + Workflows (#13)
* Feature/workflows (#8) * chore: add codeowners file * chore: add python poetry action and docs workflow * chore: update pre-commit file * chore: update docs * chore: update logo * chore: add cicd pipeline for automated deployment * chore: update poetry version * chore: fix action versioning * chore: add gitattributes to ignore line count in jupyter notebooks * chore: add and update docstrings * chore: fix end of files * chore: update action versions * Update README.md --------- Co-authored-by: mo374z <schlager.mo@t-online.de> * Fix/workflows (#11) * chore: fix workflow execution * chore: fix version check in CICD pipeline * Opro implementation (#7) * update gitignore * initial implementation of opro * formatting of prompt template * added opro test run * opro refinements * fixed sampling error * add docs to opro * fix pre commit issues * fixed end of line * Patch/pre commit config (#10) * fixed pre commit config and removed end of file line breaks in tempaltes * added / * Feature/prompt generation (#12) * added prompt_creation.py * change version --------- Co-authored-by: Timo Heiß <87521684+timo282@users.noreply.github.com> Co-authored-by: mo374z <schlager.mo@t-online.de>
1 parent 9982638 commit ff84a44

File tree

123 files changed

+1568
-19966
lines changed

Some content is hidden

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

123 files changed

+1568
-19966
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[flake8]
22
max-line-length = 120
3+
ignore = F401, W503

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ipynb linguist-documentation

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* @finitearth
2+
* @timo282
3+
* @mo374z
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Setup-Python-Poetry
2+
description: 'Setup Python and Poetry'
3+
4+
inputs:
5+
python-version:
6+
description: 'Python version to use'
7+
required: true
8+
default: '3.11'
9+
poetry-version:
10+
description: 'Poetry version to use'
11+
required: true
12+
default: 'latest'
13+
groups:
14+
required: false
15+
default: 'main'
16+
type: string
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ inputs.python-version }}
25+
- name: Setup Poetry
26+
uses: snok/install-poetry@v1.4.1
27+
with:
28+
python-version: ${{ inputs.python-version }}
29+
virtualenvs-in-project: true
30+
virtualenvs-create: true
31+
- uses: actions/cache@v3
32+
id: cached-poetry-dependencies
33+
with:
34+
path: .venv
35+
key: ${{ runner.os }}-poetry-${{ inputs.poetry-version }}-${{ hashFiles('**/poetry.lock') }}
36+
- name: Install dependencies
37+
run: poetry install --no-interaction --no-root --only ${{ inputs.groups }}
38+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
39+
shell: bash

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
types: [opened, synchronize]
9+
branches:
10+
- main
11+
- dev
12+
workflow_call:
13+
workflow_dispatch:
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: checkout
20+
uses: actions/checkout@v3
21+
- name: Set up Python and Poetry
22+
uses: ./.github/actions/python-poetry
23+
with:
24+
groups: dev
25+
- name: Run pre-commit
26+
uses: pre-commit/action@v3.0.1
27+
# - name: Run tests
28+
# run: poetry run python -m pytest
29+
30+
build:
31+
runs-on: ubuntu-latest
32+
needs: test
33+
34+
steps:
35+
- name: checkout
36+
uses: actions/checkout@v3
37+
38+
- name: Set up Python and Poetry
39+
uses: ./.github/actions/python-poetry
40+
41+
- name: Build wheel
42+
run: poetry build --format wheel
43+
44+
- name: Upload wheel
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: ${{ github.event.repository.name }}
48+
path: dist/

.github/workflows/cicd.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CICD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Run Tests, Pre-Commits, and Build Python package
12+
uses: ./.github/workflows/ci.yml
13+
14+
check-version:
15+
needs: build
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
outputs:
20+
version: ${{ steps.get_version.outputs.VERSION }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Set up Python and Poetry
25+
uses: ./.github/actions/python-poetry
26+
with:
27+
cache: true
28+
29+
- name: Get version from pyproject.toml
30+
id: get_version
31+
run: |
32+
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
33+
34+
- name: Get latest release version
35+
id: get_latest_release
36+
run: |
37+
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
38+
echo "LATEST_VERSION=${latest_release#v}" >> $GITHUB_OUTPUT
39+
40+
- name: Compare versions
41+
run: |
42+
current_version="${{ steps.get_version.outputs.VERSION }}"
43+
latest_version="${{ steps.get_latest_release.outputs.LATEST_VERSION }}"
44+
if [ "$(printf '%s\n' "$latest_version" "$current_version" | sort -V | tail -n1)" != "$current_version" ]; then
45+
echo "Error: Current version ($current_version) is not higher than the latest release ($latest_version)"
46+
exit 1
47+
fi
48+
49+
create-release:
50+
needs: check-version
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: write
54+
id-token: write
55+
steps:
56+
- uses: actions/checkout@v3
57+
with:
58+
fetch-depth: 0
59+
60+
- name: Create and push tag
61+
run: |
62+
git config --local user.email "action@github.com"
63+
git config --local user.name "GitHub Action"
64+
git tag -a v${{ needs.check-version.outputs.version }} -m "Release v${{ needs.check-version.outputs.version }}"
65+
git push origin v${{ needs.check-version.outputs.version }}
66+
67+
- name: Create GitHub Release
68+
uses: actions/create-release@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
tag_name: v${{ needs.check-version.outputs.version }}
73+
release_name: Release v${{ needs.check-version.outputs.version }}
74+
draft: false
75+
prerelease: false
76+
77+
publish-to-pypi:
78+
needs: [build, check-version, create-release]
79+
name: Publish Python package to PyPI
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: read
83+
steps:
84+
- uses: actions/checkout@v3
85+
86+
- name: Set up Python and Poetry
87+
uses: ./.github/actions/python-poetry
88+
with:
89+
cache: true # Enable caching if your custom action supports it
90+
91+
- name: Download wheel
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: ${{ github.event.repository.name }}
95+
path: dist/
96+
97+
- name: Publish to PyPI
98+
env:
99+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
100+
run: |
101+
poetry config pypi-token.pypi $PYPI_TOKEN
102+
poetry publish

.github/workflows/docs.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-deploy:
13+
concurrency: ci-${{ github.ref }}
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Setup python and poetry
21+
uses: ./.github/actions/python-poetry
22+
with:
23+
groups: "docs"
24+
25+
- name: Deploy docs
26+
run: |
27+
poetry run mkdocs gh-deploy --force

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ groqtoken.txt
55
rsync_exclude.txt
66
__pycache__/
77
temp/
8+
dist/

.pre-commit-config.yaml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,49 @@
1+
fail_fast: true
2+
exclude: '^(?!promptolution/).*$'
13
repos:
4+
- repo: https://github.com/gitleaks/gitleaks
5+
rev: v8.18.2
6+
hooks:
7+
- id: gitleaks
28
- repo: https://github.com/psf/black
3-
rev: 23.3.0 # Use the latest version
9+
rev: 23.7.0
410
hooks:
511
- id: black
6-
12+
- id: black-jupyter
713
- repo: https://github.com/pycqa/flake8
8-
rev: 6.0.0 # Use the latest version
14+
rev: 6.0.0
915
hooks:
1016
- id: flake8
11-
12-
- repo: https://github.com/pre-commit/mirrors-isort
13-
rev: v5.10.1 # Use the latest version
17+
- repo: https://github.com/pycqa/isort
18+
rev: 5.12.0
1419
hooks:
1520
- id: isort
21+
- repo: https://github.com/pycqa/pydocstyle
22+
rev: 6.3.0
23+
hooks:
24+
- id: pydocstyle
25+
- repo: https://github.com/python-poetry/poetry
26+
rev: "1.6.0"
27+
hooks:
28+
- id: poetry-check
29+
- repo: https://github.com/pre-commit/pre-commit-hooks
30+
rev: v4.4.0
31+
hooks:
32+
- id: trailing-whitespace
33+
- id: end-of-file-fixer
34+
- id: mixed-line-ending
35+
- id: check-yaml
36+
- id: check-added-large-files
37+
- id: check-merge-conflict
38+
- id: check-builtin-literals
39+
- id: check-json
40+
- id: check-toml
41+
- id: check-xml
42+
- id: debug-statements
43+
- id: detect-private-key
44+
- repo: https://github.com/compilerla/conventional-pre-commit
45+
rev: v3.4.0
46+
hooks:
47+
- id: conventional-pre-commit
48+
stages: [commit-msg]
49+
args: []

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
![promptolution](https://github.com/user-attachments/assets/84c050bd-61a1-4f2e-bc4e-874d9b4a69af)
12
# Promptolution
2-
33
Promptolution is a library that provides a modular and extensible framework for implementing prompt tuning experiments. It offers a user-friendly interface to assemble the core components for various prompt optimization tasks.
44

55
In addition, this repository contains our experiments for the paper "Towards Cost-Effective Prompt Tuning: Evaluating the Effects of Model Size, Model Family and Task Descriptions in EvoPrompt".

0 commit comments

Comments
 (0)