Skip to content

Commit

Permalink
shared prod event
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-chang committed Apr 1, 2024
1 parent 8c1c207 commit 6b2ba7f
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 82 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/publish.yaml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,6 @@ permissions:
id-token: write

jobs:
test-prod:
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.8
api-key: PROD_LABELBOX_API_KEY_2
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.9
api-key: PROD_LABELBOX_API_KEY_3
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: "3.10"
api-key: PROD_LABELBOX_API_KEY_4
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.11
api-key: LABELBOX_API_KEY
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.12
api-key: PROD_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
uses: ./.github/workflows/python-package-shared.yml
with:
python-version: ${{ matrix.python-version }}
api-key: ${{ matrix.api-key }}
da-test-key: ${{ matrix.da-test-key }}
fixture-profile: false
test-env: 'prod'
secrets: inherit
build:
runs-on: ubuntu-latest
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Labelbox Python SDK Develop
name: Labelbox Python SDK Staging (Develop)

on:
push:
Expand All @@ -8,7 +8,6 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -28,51 +27,14 @@ jobs:
- python-version: 3.12
api-key: STAGING_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
steps:
- name: Cancel previous workflow
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- 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 }}
- name: Environment setup
working-directory: libs/labelbox
run: |
rye sync -f --update-all
- name: Linting
working-directory: libs/labelbox
run: rye run lint
- name: Integration Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENV: 'staging'
working-directory: libs/labelbox
run: rye run integration
- name: Unit && Data Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[matrix.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
LABELBOX_TEST_ENV: 'staging'
working-directory: libs/labelbox
run: |
rye sync -f --features labelbox/data
rye run unit
rye run data
uses: ./.github/workflows/python-package-shared.yml
with:
python-version: ${{ matrix.python-version }}
api-key: ${{ matrix.api-key }}
da-test-key: ${{ matrix.da-test-key }}
fixture-profile: true
test-env: 'staging'
secrets: inherit
test-pypi:
runs-on: ubuntu-latest
if: github.event == 'push'
Expand All @@ -91,7 +53,7 @@ jobs:
- name: Install the latest version of rye
uses: eifinger/setup-rye@v2
with:
version: '0.29.0'
version: '0.32.0'
enable-cache: true
- name: Rye Setup
run: |
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/python-package-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Labelbox Python SDK PRod (Develop)

on:
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.8
api-key: PROD_LABELBOX_API_KEY_2
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.9
api-key: PROD_LABELBOX_API_KEY_3
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: "3.10"
api-key: PROD_LABELBOX_API_KEY_4
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.11
api-key: LABELBOX_API_KEY
da-test-key: DA_GCP_LABELBOX_API_KEY
- python-version: 3.12
api-key: PROD_LABELBOX_API_KEY_5
da-test-key: DA_GCP_LABELBOX_API_KEY
uses: ./.github/workflows/python-package-shared.yml
with:
python-version: ${{ matrix.python-version }}
api-key: ${{ matrix.api-key }}
da-test-key: ${{ matrix.da-test-key }}
fixture-profile: false
test-env: 'prod'
secrets: inherit
69 changes: 69 additions & 0 deletions .github/workflows/python-package-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Labelbox Python SDK Shared

on:
workflow_call:
inputs:
python-version:
required: true
type: string
api-key:
required: true
type: string
da-test-key:
required: true
type: string
test-env:
required: true
type: string
fixture-profile:
required: true
type: boolean

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- 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.32.0'
enable-cache: true
- name: Rye Setup
run: |
rye config --set-bool behavior.use-uv=true
- name: Python setup
run: rye pin ${{ inputs.python-version }}
- name: Environment setup
working-directory: libs/labelbox
run: |
rye sync -f --update-all
- name: Linting
working-directory: libs/labelbox
run: rye run lint
- name: Integration Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[inputs.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[inputs.da-test-key] }}
LABELBOX_TEST_ENVIRON: ${{ inputs.test-env }}
working-directory: libs/labelbox
run: rye run integration
- name: Unit && Data Testing
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: 32
LABELBOX_TEST_API_KEY: ${{ secrets[inputs.api-key] }}
DA_GCP_LABELBOX_API_KEY: ${{ secrets[inputs.da-test-key] }}
LABELBOX_TEST_ENVIRON: ${{ inputs.test-env }}
working-directory: libs/labelbox
run: |
rye sync -f --features labelbox/data
rye run unit
rye run data
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,7 @@ docs/source/_templates


# pytest
.testmondata*
.testmondata*

# rye
.env
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ rye run unit
### Integration Testing

```bash
LABELBOX_TEST_API_KEY="YOUR_API_TEST_KEY" rye run integration
LABELBOX_TEST_API_KEY="YOUR_API_TEST_KEY" LABELBOX_TEST_ENVIRON="prod" rye run integration
```
For more info on how to get a `LABELBOX_TEST_API_KEY` [Labelbox API key docs](https://labelbox.helpdocs.io/docs/api/getting-started).

**Integration tests by default will run against your account that you provide an API Key from and modify its data. If you want to run integration tests, without it impacting your existing account, create an additional account using a secondary e-mail on [Labelbox](https://labelbox.com). Free accounts are sufficent for integration testing purposes.**

You can also use a `.env` file if you prefer instead of needing to type out the environmental overrides every single time you want to run commands. Please add a `--env-file` parameter to the test command (EG `rye --env-file=.env run integration`).

### (Optional) Data Testing

For testing the impact of the extra installs included with `labelbox[data]`, run the following:

```bash
LABELBOX_TEST_API_KEY="YOUR_API_TEST_KEY" rye run data
LABELBOX_TEST_API_KEY="YOUR_API_TEST_KEY" LABELBOX_TEST_ENVIRON="prod" rye run data
```

By default `rye sync` does not install the extra packages needed in `labelbox[data]`. You'll need to run `rye sync --all-features`. Do not checkin `requirements.lock` or `requirements-dev.lock` after doing this.
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV LANG="C.UTF-8" \
LC_ALL="C.UTF-8" \
PATH="/home/python/.local/bin:/home/python/.rye/shims:$PATH" \
PIP_NO_CACHE_DIR="false" \
RYE_VERSION="0.29.0" \
RYE_VERSION="0.32.0" \
RYE_INSTALL_OPTION="--yes" \
LABELBOX_TEST_ENVIRON="prod"

Expand All @@ -29,6 +29,7 @@ WORKDIR /home/python/labelbox-python

RUN rye config --set-bool behavior.global-python=true && \
rye config --set-bool behavior.use-uv=true && \
rye pin 3.8 && \
rye sync

CMD cd libs/labelbox && rye run integration && rye sync -f --features labelbox/data && rye run unit && rye run data
4 changes: 2 additions & 2 deletions libs/labelbox/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ unit = "pytest tests/unit"
# LABELBOX_TEST_ENVIRON="ephemeral" \
# SERVICE_API_KEY=${SERVICE_API_KEY} \
# LABELBOX_TEST_BASE_URL="http://host.docker.internal:8080" \
integration = { cmd = "pytest tests/integration", env = { LABELBOX_TEST_ENVIRON = "prod" } }
data = { cmd = "pytest tests/data", env = { LABELBOX_TEST_ENVIRON = "prod" } }
integration = { cmd = "pytest tests/integration" }
data = { cmd = "pytest tests/data" }
yapf-lint = "yapf tests src -i --verbose --recursive --parallel --style \"google\""
mypy-lint = "mypy src --pretty --show-error-codes --non-interactive --install-types"
lint = { chain = ["yapf-lint", "mypy-lint"] }
Expand Down

0 comments on commit 6b2ba7f

Please sign in to comment.