Skip to content

Commit

Permalink
multi line
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-chang committed Mar 25, 2024
1 parent e385378 commit 9b63b4b
Show file tree
Hide file tree
Showing 66 changed files with 2,982 additions and 2,483 deletions.
157 changes: 131 additions & 26 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,118 @@
# Triggers a pypi publication when a release is created

name: Publish Python Package
name: Labelbox Python SDK Publish

on:
release:
types: [created]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: '0.29.0'
enable-cache: true
- name: Rye Setup
run: |
python setup.py sdist bdist_wheel
rye config --set-bool behavior.use-uv=true
- name: Create build
working-directory: libs/labelbox
run: rye build

run: |
rye sync
rye build
- uses: actions/upload-artifact@v4
with:
name: build
path: ./dist
test-build:
needs: ['build']
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.8
prod-key: PROD_LABELBOX_API_KEY_2
staging-key: STAGING_LABELBOX_API_KEY_2
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.9
prod-key: PROD_LABELBOX_API_KEY_3
staging-key: STAGING_LABELBOX_API_KEY_3
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: "3.10"
prod-key: PROD_LABELBOX_API_KEY_4
staging-key: STAGING_LABELBOX_API_KEY_4
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.11
prod-key: LABELBOX_API_KEY
staging-key: STAGING_LABELBOX_API_KEY
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.12
prod-key: PROD_LABELBOX_API_KEY_5
staging-key: STAGING_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: '0.29.0'
enable-cache: true
- name: Rye Setup
run: |
rye config --set-bool behavior.use-uv=true
- name: Python setup
run: rye pin ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: build
path: ./dist
- name: Prepare package and environment
run: |
rye sync
rye run toml unset --toml-path pyproject.toml tool.rye.workspace
rye sync -f
rye sync -f --update-all
- name: Integration Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.prod-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENVIRON: prod
run: |
rye add labelbox --path ./$(find ./dist/ -name *.tar.gz) --sync
- uses: actions/upload-artifact@v4
with:
path: ./dist

cd libs/labelbox
rm pyproject.toml
rye run pytest tests/integration
- name: Data Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.prod-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENVIRON: prod
run: |
rye add labelbox --path ./$(find ./dist/ -name *.tar.gz) --sync --features data
cd libs/labelbox
rye run pytest tests/data
pypi-publish:
needs: ['build']
needs: ['test-build']
environment:
name: publish
url: 'https://pypi.org/project/labelbox/'
Expand All @@ -50,10 +122,43 @@ jobs:
id-token: write
steps:
- uses: actions/download-artifact@v4

with:
name: build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/

github-pages:
needs: ['test-build']
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: '0.29.0'
enable-cache: true
- name: Rye Setup
run: |
rye config --set-bool behavior.use-uv=true
- name: Create build
run: |
rye sync
rye run docs
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Note that the build and pypi-publish jobs are split so that the additional permissions are only granted to the pypi-publish job.
70 changes: 49 additions & 21 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@ jobs:
include:
- python-version: 3.8
prod-key: PROD_LABELBOX_API_KEY_2
staging-key: STAGING_LABELBOX_API_KEY_2
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.9
prod-key: PROD_LABELBOX_API_KEY_3
staging-key: STAGING_LABELBOX_API_KEY_3
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: "3.10"
prod-key: PROD_LABELBOX_API_KEY_4
staging-key: STAGING_LABELBOX_API_KEY_4
da-test-key: DA_GCP_LABELBOX_API_KEY
#- python-version: 3.9
# prod-key: PROD_LABELBOX_API_KEY_3
# da-test-key: DA_GCP_LABELBOX_API_KEY
#- python-version: "3.10"
# prod-key: PROD_LABELBOX_API_KEY_4
# da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.11
prod-key: LABELBOX_API_KEY
staging-key: STAGING_LABELBOX_API_KEY
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.12
prod-key: PROD_LABELBOX_API_KEY_5
staging-key: STAGING_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
steps:
- name: Cancel previous workflow
Expand All @@ -59,28 +54,61 @@ jobs:
- name: Environment setup
working-directory: libs/labelbox
run: |
rye lock --update-all
rye sync -f
rye sync -f --update-all
- name: Linting
working-directory: libs/labelbox
run: rye run lint
- name: Unit Testing
working-directory: libs/labelbox
run: rye run unit
- name: Integration Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.prod-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
working-directory: libs/labelbox
run: rye run integration
- name: Data Testing
- name: Unit && Data Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.prod-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
working-directory: libs/labelbox
run: >
rye sync -f --features data
rye lock --update-all
rye run data
run: |
rye sync -f --features labelbox/data
rye run unit
rye run data
test-pypi:
runs-on: ubuntu-latest
needs: ['build']
environment:
name: Test-PyPI
url: 'https://test.pypi.org/p/labelbox-test'
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: '0.29.0'
enable-cache: true
- name: Rye Setup
run: |
rye config --set-bool behavior.use-uv=true
- name: Create build
id: create-build
working-directory: libs/labelbox
run: |
VERSION=$(date +"%Y.%m.%d.%H.%M")
echo "pip install --index-url https://test.pypi.org/simple/ labelbox-test@$VERSION" >> "$GITHUB_STEP_SUMMARY"
rye sync
rye version "$VERSION"
rye run toml set --toml-path pyproject.toml project.name labelbox-test
rye build
- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ To understand why Rye was chosen, see [here](https://alpopkes.com/posts/python/p

If you want to not deal with setting up `Rye` on your local machine directly, feel free to use one of [Docker containers](https://github.com/Labelbox/labelbox-python/pkgs/container/labelbox-python) we have built which contains the entire SDK with `Rye` setup for you already.

**You can use Poetry to manage the virtual environment.** There's nothing blocking you from using Poetry to manage the virtual environment as the standard `pyproject.toml` format is used, but you'll have to deal with managing Python yourself + be asked not to check in any `poetry.lock` files. Also, you'll have to run equivalent poetry commands that may not be listed in the documentation to perform the same general operations (testing, building, etc.).

## Building Locally

These are general steps that all modules in `libs/` adhere to give the prerequisite of the installation of `Rye`.
Expand Down Expand Up @@ -89,6 +91,14 @@ You may also manually format your code by running the following:
rye run lint
```

### Documentation

To generate `ReadTheDocs,` run the following command.

```bash
rye run docs
```

## Jupyter Notebooks

We have samples in the `examples` directory and using them for testing can help increase your productivity.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ RUN rye config --set-bool behavior.global-python=true && \
rye config --set-bool behavior.use-uv=true && \
rye sync

CMD ["rye", "run", "pytest", "libs/labelbox/tests/integration libs/labelbox/tests/data"]
CMD cd libs/labelbox && rye run integration && rye sync -f --features labelbox/data && rye run unit && rye run data
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ The SDK is well-documented to help developers get started quickly and use the SD

- [Labelbox Official Documentation](https://docs.labelbox.com/docs/overview)
- [Jupyter Notebook Examples](https://github.com/Labelbox/labelbox-python/tree/master/examples)
- [Read The Docs](https://labelbox-python.readthedocs.io/en/latest/)
- [Github Pages](https://labelbox.github.io/labelbox-python/)
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

Loading

0 comments on commit 9b63b4b

Please sign in to comment.