Skip to content

Commit 795d04c

Browse files
authored
Upgrade GUI to 2.0 : PySide6 multi-camera GUI - Merge pull request #38 from DeepLabCut/cy/pre-release-fixes-2.0
Upgrade GUI to 2.0 : PySide6 multi-camera GUI
2 parents 2fd130c + dc61681 commit 795d04c

File tree

114 files changed

+26053
-4980
lines changed

Some content is hidden

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

114 files changed

+26053
-4980
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# .coveragerc
3+
[run]
4+
branch = True
5+
source = dlclivegui
6+
# omit =

.github/workflows/format.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: pre-commit (PR only on changed files)
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
detect_changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
changed: ${{ steps.changed_files.outputs.changed }}
12+
13+
steps:
14+
- name: Checkout full history
15+
uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Detect changed files
20+
id: changed_files
21+
run: |
22+
git fetch origin ${{ github.base_ref }}
23+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
24+
25+
{
26+
echo "changed<<EOF"
27+
echo "$CHANGED_FILES"
28+
echo "EOF"
29+
} >> "$GITHUB_OUTPUT"
30+
31+
- name: Show changed files
32+
run: |
33+
echo "Changed files:"
34+
echo "${{ steps.changed_files.outputs.changed }}"
35+
36+
precommit:
37+
needs: detect_changes
38+
runs-on: ubuntu-latest
39+
if: ${{ needs.detect_changes.outputs.changed != '' }}
40+
41+
steps:
42+
- name: Checkout PR branch
43+
uses: actions/checkout@v6
44+
with:
45+
fetch-depth: 0
46+
ref: ${{ github.head_ref }}
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v6
50+
with:
51+
python-version: "3.12"
52+
53+
- name: Install pre-commit
54+
run: pip install pre-commit
55+
56+
- name: Run pre-commit (CI check-only stage) on changed files
57+
env:
58+
CHANGED_FILES: ${{ needs.detect_changes.outputs.changed }}
59+
run: |
60+
mapfile -t files <<< "$CHANGED_FILES"
61+
pre-commit run --hook-stage manual --files "${files[@]}" --show-diff-on-failure
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Build, validate & Release
2+
3+
# Usage:
4+
# - For PRs: this workflow runs automatically to validate the package builds and installs correctly on multiple Python versions. No artifacts are published for PRs.
5+
# - For releases: when you push a tag like v1.2.3, this workflow runs the full matrix validation, then builds the release artifacts, and finally publishes to PyPI if all checks pass.
6+
7+
on:
8+
# Release pipeline: run only when pushing a version-like tag (e.g. v1.2.3)
9+
push:
10+
tags:
11+
- "v*.*.*"
12+
13+
# Validation pipeline: run on PRs targeting main/master (no publishing)
14+
pull_request:
15+
branches: [main, master]
16+
types: [opened, edited, synchronize, reopened]
17+
18+
# This workflow only needs to read repo contents
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test_matrix:
24+
# PR + tag validation: ensure the project builds and installs on multiple Pythons
25+
name: Test install & smoke (Py ${{ matrix.python-version }})
26+
runs-on: ubuntu-latest
27+
strategy:
28+
# Run all versions even if one fails (helps spot version-specific issues)
29+
fail-fast: false
30+
matrix:
31+
python-version: ["3.10", "3.11", "3.12"]
32+
33+
steps:
34+
# Fetch repository sources so we can build/test
35+
- name: Checkout sources
36+
uses: actions/checkout@v6
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v6
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install Qt/OpenGL runtime deps (Ubuntu)
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y \
47+
libegl1 \
48+
libgl1 \
49+
libopengl0 \
50+
libxkbcommon-x11-0 \
51+
libxcb-cursor0
52+
53+
# Install packaging toolchain:
54+
# - build: creates wheel + sdist
55+
# - twine: validates metadata and can upload (upload only happens in publish job)
56+
- name: Install build tools
57+
run: python -m pip install -U pip build twine
58+
59+
# Build distributions just to verify packaging config works on this Python
60+
- name: Build (for validation only)
61+
run: python -m build
62+
63+
# Validate dist metadata (README rendering, required fields, etc.)
64+
- name: Twine check
65+
run: python -m twine check dist/*
66+
67+
# Smoke test: install the built wheel and verify the package imports
68+
- name: Install from wheel & smoke test
69+
run: |
70+
WHEEL=$(ls -1 dist/*.whl | head -n 1)
71+
echo "Using wheel: $WHEEL"
72+
python -m pip install \
73+
--extra-index-url https://download.pytorch.org/whl/cpu \
74+
"deeplabcut-live-gui[pytorch] @ file://$(pwd)/${WHEEL}"
75+
python -c "import dlclivegui; print('Imported dlclivegui OK')"
76+
QT_QPA_PLATFORM=offscreen dlclivegui --help
77+
78+
build_release:
79+
# Tag-only build: produce the "official" release artifacts once matrix passed
80+
name: Build release artifacts
81+
runs-on: ubuntu-latest
82+
needs: test_matrix
83+
# Safety gate: only run for version tags, never for PRs/branches
84+
if: startsWith(github.ref, 'refs/tags/v')
85+
86+
steps:
87+
# Fetch sources for the tagged revision
88+
- name: Checkout sources
89+
uses: actions/checkout@v6
90+
91+
# Use a single, modern Python for the canonical release build
92+
- name: Set up Python (release build)
93+
uses: actions/setup-python@v6
94+
with:
95+
python-version: "3.12"
96+
97+
# Install build + validation tooling
98+
- name: Install build tools
99+
run: python -m pip install -U pip build twine
100+
101+
# Produce both sdist and wheel in dist/
102+
- name: Build distributions
103+
run: python -m build
104+
105+
# Re-check metadata on the final artifacts we intend to publish
106+
- name: Twine check
107+
run: python -m twine check dist/*
108+
109+
# Store dist/ outputs so the publish job uploads exactly what we built here
110+
- name: Upload dist artifacts
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: dist
114+
path: dist/*
115+
116+
publish:
117+
# Tag-only publish: download built artifacts and upload them to PyPI
118+
name: Publish to PyPI (API token)
119+
runs-on: ubuntu-latest
120+
needs: build_release
121+
# Safety gate: only run for version tags
122+
if: startsWith(github.ref, 'refs/tags/v')
123+
124+
steps:
125+
# Retrieve the exact distributions produced in build_release
126+
- name: Download dist artifacts
127+
uses: actions/download-artifact@v4
128+
with:
129+
name: dist
130+
path: dist
131+
132+
# Set up Python (only needed to run Twine)
133+
- name: Set up Python (publish)
134+
uses: actions/setup-python@v6
135+
with:
136+
python-version: "3.x"
137+
138+
# Install twine for uploading
139+
- name: Install Twine
140+
run: python -m pip install -U twine
141+
142+
# Upload to PyPI using an API token stored in repo secrets.
143+
# --skip-existing avoids failing if you re-run a workflow for the same version.
144+
- name: Publish to PyPI
145+
env:
146+
TWINE_USERNAME: __token__
147+
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
148+
run: python -m twine upload --non-interactive --verbose --skip-existing dist/*

.github/workflows/testing-ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: ci-${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
unit:
13+
name: Unit + Smoke (no hardware) • ${{ matrix.os }} • py${{ matrix.python }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
python: ['3.10', '3.11', '3.12']
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v6
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: ${{ matrix.python }}
29+
cache: 'pip'
30+
31+
- name: Cache tox environments
32+
uses: actions/cache@v4
33+
with:
34+
path: .tox
35+
key: tox-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}
36+
restore-keys: |
37+
tox-${{ runner.os }}-py${{ matrix.python }}-
38+
39+
40+
- name: Install tox
41+
run: |
42+
python -m pip install -U pip wheel
43+
python -m pip install -U tox tox-gh-actions
44+
45+
- name: Install Qt/OpenGL runtime deps (Ubuntu)
46+
if: startsWith(matrix.os, 'ubuntu')
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y \
50+
libegl1 \
51+
libgl1 \
52+
libopengl0 \
53+
libxkbcommon-x11-0 \
54+
libxcb-cursor0
55+
56+
- name: Run tests (exclude hardware) with coverage via tox
57+
run: |
58+
tox -q | tee tox-output.log
59+
60+
61+
- name: Append Coverage Summary to Job
62+
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
63+
shell: bash
64+
run: |
65+
echo "## Coverage Summary" >> "$GITHUB_STEP_SUMMARY"
66+
echo '```text' >> "$GITHUB_STEP_SUMMARY"
67+
awk '
68+
/^Name[[:space:]]+Stmts[[:space:]]+Miss/ {p=1}
69+
p==1 {print}
70+
/^Coverage XML written to file/ {exit}
71+
' tox-output.log >> "$GITHUB_STEP_SUMMARY" || true
72+
echo '```' >> "$GITHUB_STEP_SUMMARY"
73+
74+
- name: Upload coverage to Codecov
75+
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12' && github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'master')
76+
uses: codecov/codecov-action@v5
77+
with:
78+
token: ${{ secrets.CODECOV_TOKEN }}
79+
files: ./.coverage.py312.xml
80+
fail_ci_if_error: false

.gitignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#####################
2-
### DLC Live Specific
3-
#####################
4-
5-
*config*
6-
**test*
7-
81
###################
92
### python standard
103
###################
@@ -116,3 +109,7 @@ venv.bak/
116109

117110
# ide files
118111
.vscode
112+
113+
!dlclivegui/config.py
114+
# uv package files
115+
uv.lock

.pre-commit-config.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
default_stages: [pre-commit]
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
# These are safe to run in both local & CI (they don't require "fix vs check" split)
8+
- id: check-added-large-files
9+
stages: [pre-commit, manual]
10+
- id: check-yaml
11+
stages: [pre-commit, manual]
12+
- id: check-toml
13+
stages: [pre-commit, manual]
14+
- id: check-merge-conflict
15+
stages: [pre-commit, manual]
16+
17+
# These modify files. Run locally only (pre-commit stage).
18+
- id: end-of-file-fixer
19+
stages: [pre-commit]
20+
- id: trailing-whitespace
21+
stages: [pre-commit]
22+
23+
- repo: https://github.com/tox-dev/pyproject-fmt
24+
rev: v2.15.2
25+
hooks:
26+
- id: pyproject-fmt
27+
stages: [pre-commit] # modifies -> local only
28+
29+
- repo: https://github.com/abravalheri/validate-pyproject
30+
rev: v0.25
31+
hooks:
32+
- id: validate-pyproject
33+
stages: [pre-commit, manual]
34+
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.15.0
37+
hooks:
38+
# --------------------------
39+
# LOCAL AUTOFIX (developers)
40+
# --------------------------
41+
- id: ruff-check
42+
name: ruff-check (fix)
43+
args: [--fix, --unsafe-fixes]
44+
stages: [pre-commit]
45+
46+
- id: ruff-format
47+
name: ruff-format (write)
48+
stages: [pre-commit]
49+
50+
# --------------------------
51+
# CI CHECK-ONLY (no writes)
52+
# --------------------------
53+
- id: ruff-check
54+
name: ruff-check (ci)
55+
args: [--output-format=github]
56+
stages: [manual]
57+
58+
- id: ruff-format
59+
name: ruff-format (ci)
60+
args: [--check, --diff]
61+
stages: [manual]

0 commit comments

Comments
 (0)