Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
eelcovdw committed Oct 9, 2024
2 parents 781c973 + 4c5ba8b commit 6a9addd
Show file tree
Hide file tree
Showing 18 changed files with 720 additions and 650 deletions.
9 changes: 9 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[bumpversion]
current_version = 0.1.3
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}

[bumpversion:file:pyproject.toml]

[bumpversion:file:syftbox/__version__.py]
37 changes: 37 additions & 0 deletions .github/workflows/cd-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CD - Deploy SyftBox Server

on:
workflow_dispatch:
inputs:
version:
description: "SyftBox Version to deploy"
type: string
default: latest

# Prevents concurrent runs of the same workflow
# while the previous run is still in progress
concurrency:
group: "CD - Deploy SyftBox Server"
cancel-in-progress: false

jobs:

deploy-syftbox-server:
runs-on: ubuntu-latest

steps:
- name: Install Just
uses: extractions/setup-just@v2
with:
just-version: "1.36.0"

- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SYFTBOX_SERVER_PRIVATE_KEY }}" > ~/.ssh/syftbox.pem
chmod 600 ~/.ssh/syftbox.pem
ssh-keyscan -H "20.168.10.234" >> ~/.ssh/known_hosts
- name: Deploy SyftBox Server
run: |
just deploy ~/.ssh/syftbox.pem ${{ inputs.version }}
88 changes: 88 additions & 0 deletions .github/workflows/cd-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: CD - SyftBox

on:
workflow_dispatch:
inputs:
bump_type:
description: "Version bump type"
type: choice
default: patch
options:
- patch
- minor
- major

test_bump:
description: "Perform a test bump version without pushing to pypi and repo"
type: boolean
default: false

skip_tests:
description: "If true, skip pre-release tests"
required: false
default: "false"
type: choice
options:
- "false"
- "true"

# Prevents concurrent runs of the same workflow
# while the previous run is still in progress
concurrency:
group: "CD - SyftBox"
cancel-in-progress: false

jobs:
call-pr-tests:
if: ${{ inputs.skip_tests == 'false' }}
uses: ./.github/workflows/pr-tests.yaml


deploy-syftbox:
needs: [call-pr-tests]
runs-on: ubuntu-latest

steps:
- name: Checkout SyftBox repo with github token
uses: actions/checkout@v4
with:
token: ${{ secrets.SYFTBOX_BOT_COMMIT_TOKEN }}

- name: Configure git user
run: |
git config user.name "${{ secrets.OM_BOT_NAME }}"
git config user.email "${{ secrets.OM_BOT_EMAIL }}"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv==0.4.19 twine
uv --version
- name: Install Just
uses: extractions/setup-just@v2
with:
just-version: "1.36.0"

- name: Bump the Version
run: |
just bump-version ${{ inputs.bump_type }}
- name: Build syftbox
run: |
just build
- name: Push to pypi
if: ${{ inputs.test_bump == false }}
run: |
twine upload -u __token__ -p ${{ secrets.OM_SYFTBOX_PYPI_TOKEN }} dist/*
- name: Push changes to SyftBox repo
if: ${{ inputs.test_bump == false }}
run: |
git push origin
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ repos:
always_run: true
- id: trailing-whitespace
always_run: true
exclude: .bumpversion.cfg
- id: check-docstring-first
always_run: true
- id: check-json
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ curl -LsSf https://astral.sh/uv/install.sh | sh

uv venv .venv

## install the wheel
## Install Syftbox

uv pip install http://20.168.10.234:8080/wheel/syftbox-0.1.0-py3-none-any.whl --reinstall
uv pip install -U syftbox

## run the client

Expand Down
76 changes: 58 additions & 18 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,43 @@ build:
rm -rf dist
uv build

# Build & Deploy syftbox to a remote server using SSH
[group('build')]
deploy keyfile remote="azureuser@20.168.10.234": build
fetch-syftbox-version version="latest":
#!/bin/bash
set -eou pipefail

# there will be only one wheel file in the dist directory, but you never know...
LOCAL_WHEEL=$(ls dist/*.whl | grep syftbox | head -n 1)
set -euo pipefail

# If version is latest, then fetch the latest version from PyPI
# else, check if the version exists on PyPI
if [ "{{ version }}" = "latest" ]; then
echo "Fetching the latest version of syftbox from PyPI..."
curl -sSf "https://pypi.org/pypi/syftbox/json" | jq -r ".info.version" || { echo "Failed to fetch the latest version." >&2; exit 1; }
else
echo "Checking if syftbox version {{ version }} exists on PyPI..."
if curl -sSf -o /dev/null "https://pypi.org/pypi/syftbox/{{ version }}/json"; then
echo "{{ version }}"
else
echo "syftbox version {{ version }} does not exist." >&2
exit 1
fi
fi

# Remote paths to copy the wheel to
REMOTE_DIR="~"
REMOTE_WHEEL="$REMOTE_DIR/$(basename $LOCAL_WHEEL)"

echo -e "Deploying {{ _cyan }}$LOCAL_WHEEL{{ _nc }} to {{ _green }}{{ remote }}:$REMOTE_WHEEL{{ _nc }}"
# Build & Deploy syftbox to a remote server using SSH
[group('build')]
deploy keyfile version="latest" remote="azureuser@20.168.10.234":
#!/bin/bash
set -eou pipefail

# change permissions to comply with ssh/scp
chmod 600 {{ keyfile }}

# Use scp to transfer the file to the remote server
scp -i {{ keyfile }} "$LOCAL_WHEEL" "{{ remote }}:$REMOTE_DIR"
# Sanity Check the syft box version
REMOTE_VERSION=$(just fetch-syftbox-version {{ version }} | tail -n 1)

echo -e "Deploying syftbox version $REMOTE_VERSION to {{ remote }}..."

# install pip package
ssh -i {{ keyfile }} {{ remote }} "pip install --break-system-packages $REMOTE_WHEEL --force"
ssh -i {{ keyfile }} {{ remote }} "pip install syftbox==$REMOTE_VERSION --break-system-packages --force"

# restart service
# TODO - syftbox service was created manually on 20.168.10.234
Expand All @@ -107,11 +121,39 @@ deploy keyfile remote="azureuser@20.168.10.234": build

echo -e "{{ _green }}Deploy successful!{{ _nc }}"

# Bump version, commit and tag
[group('build')]
bump-version level="patch":
#!/bin/bash
# We need to uv.lock before we can commit the whole thing in the repo.
# DO not bump the version on the uv.lock file, else other packages with same version might get updated

set -eou pipefail

# sync dev dependencies for bump2version
uv sync --frozen

# get the current and new version
BUMPVERS_CHANGES=$(uv run bump2version --dry-run --allow-dirty --list {{ level }})
CURRENT_VERSION=$(echo "$BUMPVERS_CHANGES" | grep current_version | cut -d'=' -f2)
NEW_VERSION=$(echo "$BUMPVERS_CHANGES" | grep new_version | cut -d'=' -f2)
echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION"

# first bump version
uv run bump2version {{ level }}

# update uv.lock file to reflect new package version
uv lock

# commit the changes
git commit -am "Bump version $CURRENT_VERSION -> $NEW_VERSION"
git tag -a $NEW_VERSION -m "Release $NEW_VERSION"

# ---------------------------------------------------------------------------------------------------------------------

[group('utils')]
ssh keyfile remote="azureuser@20.168.10.234":
ssh -i {{ keyfile }} remote
ssh -i {{ keyfile }} {{ remote }}

# remove all local files & directories
[group('utils')]
Expand All @@ -121,7 +163,5 @@ reset:

[group('utils')]
run-jupyter jupyter_args="":
uv run \
--with "jupyterlab" \
--with-editable ".[dev]" \
jupyter lab --notebook-dir=./notebooks {{ jupyter_args }}
uv run --frozen --with "jupyterlab" \
jupyter lab {{ jupyter_args }}
6 changes: 0 additions & 6 deletions notebooks/Untitled.ipynb

This file was deleted.

37 changes: 20 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "syftbox"
version = "0.1.0"
version = "0.1.3"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -20,36 +20,39 @@ dependencies = [
"watchdog>=5.0.2",
]

[project.optional-dependencies]
# add using `uv add --optional <group> <pip package>`
# will be referenced in the built wheel


[project.scripts]
syftbox = "syftbox.main:main"

[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[tool.uv]
# add using `uv add --dev <group> <pip package>`
# this will be completely ignored in the built wheel
dev-dependencies = [
"bump2version>=1.0.1",
"pytest-cov>=5.0.0",
"pytest-xdist[psutil]>=3.6.1",
"pytest>=8.3.3",
"httpx>=0.27.2",
]

[tool.setuptools]
packages = { find = {} } # Use the find directive as a table
include-package-data = true # Include package data


[tool.setuptools.package-data]
syftbox = ["*.css", ".js", ".html", ".zip", ".sh"]

[project.scripts]
syftbox = "syftbox.main:main"

[tool.pytest.ini_options]
pythonpath = ["."]

[project.optional-dependencies]
dev = [
"pytest",
"pytest-xdist[psutil]",
"pytest-cov",
"mypy",
"uv",
"ruff",
"httpx",
]


[tool.ruff]
line-length = 120
exclude = ["./data", "./users", "build", "dist", ".venv"]
Expand Down
1 change: 0 additions & 1 deletion syftbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = "0.1.0"
11 changes: 11 additions & 0 deletions syftbox/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ____ __ _ ____
# / ___| _ _ / _| |_| __ ) _____ __
# \___ \| | | | |_| __| _ \ / _ \ \/ /
# ___) | |_| | _| |_| |_) | (_) > <
# |____/ \__, |_| \__|____/ \___/_/\_\
# |___/

__title__ = "SyftBox"
__description__ = ""
__url__ = "https://openmined.org"
__version__ = "0.1.3"
Loading

0 comments on commit 6a9addd

Please sign in to comment.