Skip to content

Commit 06d8dcd

Browse files
authored
[PLT-0] fix pypath / use of pytest conventions around fixtures (#1505)
1 parent bd7fa0a commit 06d8dcd

Some content is hidden

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

47 files changed

+3302
-2721
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Labelbox Python SDK Shared
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
api-key:
10+
required: true
11+
type: string
12+
da-test-key:
13+
required: true
14+
type: string
15+
test-env:
16+
required: true
17+
type: string
18+
fixture-profile:
19+
required: true
20+
type: boolean
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
env:
25+
# make sure to tell tox to use these environs in tox.ini
26+
LABELBOX_TEST_API_KEY: ${{ secrets[inputs.api-key] }}
27+
DA_GCP_LABELBOX_API_KEY: ${{ secrets[inputs.da-test-key] }}
28+
LABELBOX_TEST_ENVIRON: ${{ inputs.test-env }}
29+
FIXTURE_PROFILE: ${{ inputs.fixture-profile }}
30+
steps:
31+
- name: Cancel previous workflow
32+
uses: styfle/cancel-workflow-action@0.12.1
33+
with:
34+
access_token: ${{ github.token }}
35+
36+
- uses: actions/checkout@v4
37+
with:
38+
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
39+
ref: ${{ github.head_ref }}
40+
41+
- name: Set up Python ${{ inputs.python-version }}
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ inputs.python-version }}
45+
cache: "pip"
46+
47+
- name: yapf
48+
id: yapf
49+
uses: AlexanderMelde/yapf-action@master
50+
with:
51+
args: --verbose --recursive --parallel --style "google"
52+
- name: dependencies
53+
run: |
54+
sudo apt-get -y update
55+
sudo apt install -y libsm6 \
56+
libxext6 \
57+
ffmpeg \
58+
libfontconfig1 \
59+
libxrender1 \
60+
libgl1-mesa-glx
61+
- name: mypy
62+
run: |
63+
pip install strenum
64+
pip install mypy==1.9.0
65+
# TODO: consider installing requests typing
66+
mypy -p labelbox --pretty --show-error-codes --non-interactive --install-types
67+
- name: Install test dependencies
68+
run: |
69+
pip install tox==4.14.1
70+
# TODO: replace tox.ini with what the Makefile does
71+
# to make sure local testing is
72+
# identical to github actions which uses tox.ini
73+
- name: Test with tox (unit)
74+
run: |
75+
tox -e py -- tests/unit
76+
- name: Test with tox (integration / data)
77+
run: |
78+
tox -e py -- tests/integration tests/data

.github/workflows/python-package.yml

Lines changed: 43 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,100 +7,60 @@ on:
77
branches: [develop, master]
88

99
jobs:
10-
build:
11-
runs-on: ubuntu-latest
10+
build-prod:
1211
strategy:
1312
fail-fast: false
1413
matrix:
1514
include:
1615
- python-version: 3.8
17-
prod-key: PROD_LABELBOX_API_KEY_2
18-
staging-key: STAGING_LABELBOX_API_KEY_2
16+
api-key: PROD_LABELBOX_API_KEY_2
1917
da-test-key: DA_GCP_LABELBOX_API_KEY
2018
- python-version: 3.9
21-
prod-key: PROD_LABELBOX_API_KEY_3
22-
staging-key: STAGING_LABELBOX_API_KEY_3
19+
api-key: PROD_LABELBOX_API_KEY_3
2320
da-test-key: DA_GCP_LABELBOX_API_KEY
2421
- python-version: "3.10"
25-
prod-key: PROD_LABELBOX_API_KEY_4
26-
staging-key: STAGING_LABELBOX_API_KEY_4
22+
api-key: PROD_LABELBOX_API_KEY_4
2723
da-test-key: DA_GCP_LABELBOX_API_KEY
2824
- python-version: 3.11
29-
prod-key: LABELBOX_API_KEY
30-
staging-key: STAGING_LABELBOX_API_KEY
25+
api-key: LABELBOX_API_KEY
3126
da-test-key: DA_GCP_LABELBOX_API_KEY
3227
- python-version: 3.12
33-
prod-key: PROD_LABELBOX_API_KEY_5
34-
staging-key: STAGING_LABELBOX_API_KEY_5
28+
api-key: PROD_LABELBOX_API_KEY_5
3529
da-test-key: DA_GCP_LABELBOX_API_KEY
36-
37-
env:
38-
cache-key: testmon=${{ github.ref_name }}-${{ matrix.python-version }}
39-
steps:
40-
- name: Cancel previous workflow
41-
uses: styfle/cancel-workflow-action@0.12.1
42-
with:
43-
access_token: ${{ github.token }}
44-
45-
- name: set environment for branch
46-
run: |
47-
if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then
48-
echo "LABELBOX_TEST_ENVIRON=prod" >> $GITHUB_ENV
49-
else
50-
echo "LABELBOX_TEST_ENVIRON=staging" >> $GITHUB_ENV
51-
echo "FIXTURE_PROFILE=true" >> $GITHUB_ENV
52-
fi
53-
54-
- uses: actions/checkout@v4
55-
with:
56-
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
57-
ref: ${{ github.head_ref }}
58-
59-
- name: Set up Python ${{ matrix.python-version }}
60-
uses: actions/setup-python@v5
61-
with:
62-
python-version: ${{ matrix.python-version }}
63-
cache: "pip"
64-
65-
- name: yapf
66-
id: yapf
67-
uses: AlexanderMelde/yapf-action@master
68-
with:
69-
args: --verbose --recursive --parallel --style "google"
70-
- name: dependencies
71-
run: |
72-
sudo apt-get -y update
73-
sudo apt install -y libsm6 \
74-
libxext6 \
75-
ffmpeg \
76-
libfontconfig1 \
77-
libxrender1 \
78-
libgl1-mesa-glx
79-
- name: mypy
80-
run: |
81-
pip install strenum
82-
pip install mypy==1.9.0
83-
# TODO: consider installing requests typing
84-
mypy -p labelbox --pretty --show-error-codes --non-interactive --install-types
85-
- name: Install test dependencies
86-
run: |
87-
pip install tox==4.14.1
88-
# TODO: replace tox.ini with what the Makefile does
89-
# to make sure local testing is
90-
# identical to github actions which uses tox.ini
91-
- name: Test with tox (unit)
92-
env:
93-
# make sure to tell tox to use these environs in tox.ini
94-
LABELBOX_TEST_API_KEY_PROD: ${{ secrets[matrix.prod-key] }}
95-
LABELBOX_TEST_API_KEY_STAGING: ${{ secrets[matrix.staging-key] }}
96-
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
97-
run: |
98-
tox -e py -- tests/unit
99-
- name: Test with tox (integration / data)
100-
env:
101-
# make sure to tell tox to use these environs in tox.ini
102-
LABELBOX_TEST_API_KEY_PROD: ${{ secrets[matrix.prod-key] }}
103-
LABELBOX_TEST_API_KEY_STAGING: ${{ secrets[matrix.staging-key] }}
104-
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
105-
run: |
106-
tox -e py -- tests/integration tests/data
30+
uses: ./.github/workflows/python-package-shared.yml
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
api-key: ${{ matrix.api-key }}
34+
da-test-key: ${{ matrix.da-test-key }}
35+
fixture-profile: false
36+
test-env: 'prod'
37+
secrets: inherit
38+
build-staging:
39+
if: ${{ github.event_name }} == 'pull_request'
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- python-version: 3.8
45+
api-key: STAGING_LABELBOX_API_KEY_2
46+
da-test-key: DA_GCP_LABELBOX_API_KEY
47+
- python-version: 3.9
48+
api-key: STAGING_LABELBOX_API_KEY_3
49+
da-test-key: DA_GCP_LABELBOX_API_KEY
50+
- python-version: "3.10"
51+
api-key: STAGING_LABELBOX_API_KEY_4
52+
da-test-key: DA_GCP_LABELBOX_API_KEY
53+
- python-version: 3.11
54+
api-key: STAGING_LABELBOX_API_KEY
55+
da-test-key: DA_GCP_LABELBOX_API_KEY
56+
- python-version: 3.12
57+
api-key: STAGING_LABELBOX_API_KEY_5
58+
da-test-key: DA_GCP_LABELBOX_API_KEY
59+
uses: ./.github/workflows/python-package-shared.yml
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
api-key: ${{ matrix.api-key }}
63+
da-test-key: ${{ matrix.da-test-key }}
64+
fixture-profile: true
65+
test-env: 'staging'
66+
secrets: inherit

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
22
pythonpath = .
3-
addopts = -rP -vvv --reruns 5 --reruns-delay 10 --durations=20 -n 20
3+
addopts = -rP -vvv --reruns 5 --reruns-delay 10 --durations=20 -n 32
44
markers =
55
slow: marks tests as slow (deselect with '-m "not slow"')

0 commit comments

Comments
 (0)