Skip to content

Commit 695f98b

Browse files
authored
Merge pull request #3 from OpenMined/madhava/call_interface
Madhava/call interface
2 parents a65a0b9 + 4e54dda commit 695f98b

29 files changed

+1922
-45
lines changed

.github/workflows/docker-build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'python/**'
9+
- 'docker/**'
10+
- '.github/workflows/docker-build.yml'
11+
release:
12+
types: [published]
13+
workflow_dispatch:
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract version from __init__.py
41+
id: version
42+
run: |
43+
VERSION=$(grep '^__version__ = ' python/src/bioscript/__init__.py | cut -d'"' -f2)
44+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
45+
echo "Extracted version: ${VERSION}"
46+
47+
- name: Extract metadata for Docker
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+
tags: |
53+
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }}
54+
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }}
55+
type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }}
56+
type=raw,value=${{ steps.version.outputs.version }}
57+
type=raw,value=latest,enable={{is_default_branch}}
58+
type=sha,prefix={{branch}}-
59+
60+
- name: Build and push Docker image
61+
id: build
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: .
65+
file: ./docker/Dockerfile
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
cache-from: type=gha
70+
cache-to: type=gha,mode=max
71+
72+
- name: Generate artifact attestation
73+
uses: actions/attest-build-provenance@v1
74+
with:
75+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
76+
subject-digest: ${{ steps.build.outputs.digest }}
77+
push-to-registry: true

.github/workflows/pr-checks.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,8 @@ jobs:
2525
cd python
2626
uv sync --all-extras
2727
28-
- name: Run ruff format check
29-
run: |
30-
cd python
31-
uv run ruff format --check .
32-
33-
- name: Run ruff linting
34-
run: |
35-
cd python
36-
uv run ruff check .
37-
38-
- name: Run mypy
39-
run: |
40-
cd python
41-
uv run mypy src/bioscript
28+
- name: Run linting
29+
run: bash lint.sh
4230

4331
test:
4432
runs-on: ubuntu-latest
@@ -65,3 +53,38 @@ jobs:
6553
run: |
6654
cd python
6755
uv run pytest
56+
57+
test-local:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Install uv
63+
uses: astral-sh/setup-uv@v5
64+
with:
65+
enable-cache: true
66+
67+
- name: Set up Python
68+
run: uv python install 3.8
69+
70+
- name: Run local smoke test
71+
run: bash test_local.sh
72+
73+
test-docker:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Install uv
82+
uses: astral-sh/setup-uv@v5
83+
with:
84+
enable-cache: true
85+
86+
- name: Set up Python
87+
run: uv python install 3.8
88+
89+
- name: Run Docker smoke test
90+
run: bash test_docker.sh

.github/workflows/publish.yml

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ name: Publish to PyPI
33
on:
44
workflow_dispatch:
55
inputs:
6-
version:
7-
description: 'Version to publish (e.g., 0.1.0)'
6+
bump:
7+
description: 'Version bump type'
88
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
- custom
15+
default: 'patch'
16+
custom_version:
17+
description: 'Custom version (only if bump=custom, e.g., 0.2.0)'
18+
required: false
919
type: string
1020

1121
jobs:
@@ -25,15 +35,42 @@ jobs:
2535
- name: Set up Python
2636
run: uv python install 3.8
2737

28-
- name: Update version in pyproject.toml
38+
- name: Get current version
39+
id: current
2940
run: |
30-
cd python
31-
sed -i 's/version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml
41+
CURRENT=$(grep '^__version__ = ' python/src/bioscript/__init__.py | cut -d'"' -f2)
42+
echo "version=${CURRENT}" >> $GITHUB_OUTPUT
43+
echo "Current version: ${CURRENT}"
44+
45+
- name: Calculate new version
46+
id: new
47+
run: |
48+
CURRENT="${{ steps.current.outputs.version }}"
49+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
50+
51+
case "${{ inputs.bump }}" in
52+
major)
53+
NEW_VERSION="$((MAJOR + 1)).0.0"
54+
;;
55+
minor)
56+
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
57+
;;
58+
patch)
59+
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
60+
;;
61+
custom)
62+
NEW_VERSION="${{ inputs.custom_version }}"
63+
;;
64+
esac
65+
66+
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
67+
echo "New version: ${NEW_VERSION}"
3268
3369
- name: Update version in __init__.py
3470
run: |
3571
cd python
36-
sed -i 's/__version__ = ".*"/__version__ = "${{ inputs.version }}"/' src/bioscript/__init__.py
72+
sed -i 's/__version__ = ".*"/__version__ = "${{ steps.new.outputs.version }}"/' src/bioscript/__init__.py
73+
grep '__version__' src/bioscript/__init__.py
3774
3875
- name: Install dependencies
3976
run: |
@@ -56,11 +93,11 @@ jobs:
5693
packages-dir: python/dist/
5794
password: ${{ secrets.PYPI_API_TOKEN }}
5895

59-
- name: Commit version bump
96+
- name: Commit version bump and tag
6097
run: |
6198
git config user.name "github-actions[bot]"
6299
git config user.email "github-actions[bot]@users.noreply.github.com"
63-
git add python/pyproject.toml python/src/bioscript/__init__.py
64-
git commit -m "Bump version to ${{ inputs.version }}"
65-
git tag "v${{ inputs.version }}"
100+
git add python/src/bioscript/__init__.py
101+
git commit -m "Bump version to ${{ steps.new.outputs.version }}"
102+
git tag "v${{ steps.new.outputs.version }}"
66103
git push origin main --tags

bump_version.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Bump version in __init__.py
5+
# Usage: ./bump_version.sh <major|minor|patch|version>
6+
#
7+
# Examples:
8+
# ./bump_version.sh patch # 0.1.0 -> 0.1.1
9+
# ./bump_version.sh minor # 0.1.0 -> 0.2.0
10+
# ./bump_version.sh major # 0.1.0 -> 1.0.0
11+
# ./bump_version.sh 0.2.0 # Set to specific version
12+
13+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
INIT_FILE="$REPO_ROOT/python/src/bioscript/__init__.py"
15+
16+
if [ $# -ne 1 ]; then
17+
echo "Usage: $0 <major|minor|patch|version>"
18+
exit 1
19+
fi
20+
21+
# Get current version
22+
CURRENT_VERSION=$(grep '^__version__ = ' "$INIT_FILE" | cut -d'"' -f2)
23+
echo "Current version: $CURRENT_VERSION"
24+
25+
# Parse current version
26+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
27+
28+
# Calculate new version
29+
case "$1" in
30+
major)
31+
NEW_VERSION="$((MAJOR + 1)).0.0"
32+
;;
33+
minor)
34+
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
35+
;;
36+
patch)
37+
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
38+
;;
39+
*)
40+
# Assume it's a specific version
41+
NEW_VERSION="$1"
42+
;;
43+
esac
44+
45+
echo "New version: $NEW_VERSION"
46+
47+
# Update __init__.py
48+
sed -i.bak "s/__version__ = .*/__version__ = \"${NEW_VERSION}\"/" "$INIT_FILE"
49+
rm "${INIT_FILE}.bak"
50+
51+
echo "✓ Updated $INIT_FILE"
52+
echo ""
53+
echo "Next steps:"
54+
echo " git add python/src/bioscript/__init__.py"
55+
echo " git commit -m \"Bump version to ${NEW_VERSION}\""
56+
echo " git tag v${NEW_VERSION}"
57+
echo " git push origin main --tags"

docker/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.13-slim
2+
3+
LABEL org.opencontainers.image.source=https://github.com/OpenMined/bioscript
4+
LABEL org.opencontainers.image.description="BioScript - Genetic variant classification tool"
5+
LABEL org.opencontainers.image.licenses=Apache-2.0
6+
7+
# Install uv for fast package management
8+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
9+
10+
# Set working directory
11+
WORKDIR /app
12+
13+
# Copy Python package files
14+
COPY python/pyproject.toml python/README.md ./
15+
COPY python/src ./src
16+
17+
# Install bioscript
18+
RUN uv pip install --system --no-cache .
19+
20+
# Set the default command to show help
21+
CMD ["bioscript", "--help"]

0 commit comments

Comments
 (0)