Skip to content

Commit

Permalink
refactor: use Rye
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsbarnard committed Jan 29, 2025
1 parent aa3ff92 commit c8a8642
Show file tree
Hide file tree
Showing 57 changed files with 157 additions and 104 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

101 changes: 57 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,43 @@ on:
branches: [ main ]

jobs:
poetry-build:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
uses: actions/checkout@v4

- name: Cache Poetry
- name: Cache Rye
id: cache-rye
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
path: ~/.rye
key: ${{ runner.os }}-rye

- name: Install dependencies
- name: Install Rye (if not cached)
if: steps.cache-rye.outputs.cache-hit != 'true'
run: |
pip install poetry
poetry install
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.38.0" RYE_INSTALL_OPTION="--yes" bash
- name: Set up Rye in PATH
run: |
echo "$HOME/.rye/bin" >> $GITHUB_PATH
- name: Build package
- name: Build
run: |
poetry build
rye build
semantic-release-version:
- name: Store built package
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

release:
runs-on: ubuntu-latest
needs: poetry-build
concurrency: semantic-release-version
needs: build
concurrency: release
permissions:
id-token: write
contents: write
Expand All @@ -47,46 +52,54 @@ jobs:
tag: ${{ steps.semantic_release.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Python semantic release
id: semantic_release
uses: python-semantic-release/python-semantic-release@master
uses: python-semantic-release/python-semantic-release@v9.15.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
vcs_release: true

poetry-publish:
publish:
runs-on: ubuntu-latest
needs: semantic-release-version
if: ${{ needs.semantic-release-version.outputs.released == 'true' }}
concurrency: poetry-publish
needs: [build, release]
if: needs.release.outputs.released == 'true'
concurrency: publish
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.semantic-release-version.outputs.tag }}

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/checkout@v4
with:
python-version: "3.11"

- name: Cache Poetry
ref: ${{ needs.release.outputs.tag }}

- name: Restore Rye from cache
id: cache-rye
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
path: ~/.rye
key: ${{ runner.os }}-rye

- name: Install Rye (if not cached)
if: steps.cache-rye.outputs.cache-hit != 'true'
run: |
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.38.0" RYE_INSTALL_OPTION="--yes" bash
echo "$HOME/.rye/bin" >> $GITHUB_PATH
- name: Set up Rye in PATH
run: |
echo "$HOME/.rye/bin" >> $GITHUB_PATH
- name: Download built package
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish package
run: |
pip install poetry
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
rye publish --token ${{ secrets.PYPI_TOKEN }} --yes
# pyinstaller-build:
# runs-on: ${{ matrix.os }}
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*__pycache__/
vars_gridview/assets/gui.ini
vars_gridview/logs/
src/vars_gridview/assets/gui.ini
src/vars_gridview/logs/
logs/
build/
dist/
poetry.lock
requirements.lock
requirements-dev.lock
2 changes: 0 additions & 2 deletions .isort.cfg

This file was deleted.

19 changes: 6 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["--config", ".flake8"]
# Lint
- id: ruff
# Format
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
52 changes: 29 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
[tool.poetry]
[project]
name = "vars-gridview"
version = "0.16.0"
description = "VARS GridView is a tool for reviewing and correcting VARS localizations in bulk."
authors = [
"Kevin Barnard <[email protected]>",
"Paul Roberts <[email protected]>"
{ name = "Kevin Barnard", email = "[email protected]" },
{ name = "Paul Roberts", email = "[email protected]" }
]
dependencies = [
"pyqt6>=6.4.0",
"requests>=2.27.1",
"pyqtgraph>=0.13.0",
"opencv-python>=4.5.5.62",
"qdarkstyle>=3.0.3",
"beholder-client>=0.1.0",
"sharktopoda-client>=0.4.5",
"platformdirs>=4.0.0",
"dreamsim>=0.1.3",
"iso8601>=2.1.0",
]
readme = "README.md"
repository = "https://github.com/mbari-org/vars-gridview"
requires-python = ">= 3.8"
keywords = ["VARS", "localization", "annotation"]
license = "MIT"
include = ["LICENSE"]

[tool.poetry.dependencies]
python = ">=3.8,<3.13"
pyqt6 = "^6.4.0"
requests = "^2.27.1"
pyqtgraph = "^0.13.0"
opencv-python = "^4.5.5.62"
qdarkstyle = "^3.0.3"
beholder-client = "^0.1.0"
sharktopoda-client = "^0.4.5"
platformdirs = "^4.0.0"
dreamsim = "^0.1.3"
iso8601 = "^2.1.0"
[project.scripts]
vars-gridview = "vars_gridview.__main__:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry.scripts]
vars-gridview = "vars_gridview.scripts.run:main"
[tool.rye]
managed = true
dev-dependencies = [
"pre-commit>=3.5.0",
"python-semantic-release>=9.17.0",
"pyinstaller>=6.11.1",
]

[tool.poetry.group.dev.dependencies]
black = "^23.1.0"
Expand Down Expand Up @@ -93,7 +103,3 @@ env = "GH_TOKEN"
[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
8 changes: 4 additions & 4 deletions run.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


a = Analysis(
['vars_gridview/scripts/run.py'],
['src/vars_gridview/scripts/run.py'],
pathex=[],
binaries=[],
datas=[('vars_gridview/assets', 'assets')],
datas=[('src/vars_gridview/assets', 'assets')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
Expand All @@ -31,7 +31,7 @@ exe = EXE(
target_arch=None,
codesign_identity='Developer ID Application: Monterey Bay Aquarium Research Institute (9TN7A342V4)',
entitlements_file=None,
icon=['vars_gridview/assets/icons/VARSGridView.icns'],
icon=['src/vars_gridview/assets/icons/VARSGridView.icns'],
)
coll = COLLECT(
exe,
Expand All @@ -45,6 +45,6 @@ coll = COLLECT(
app = BUNDLE(
coll,
name='VARS GridView.app',
icon='vars_gridview/assets/icons/VARSGridView.icns',
icon='src/vars_gridview/assets/icons/VARSGridView.icns',
bundle_identifier='org.mbari.vars.gridview',
)
File renamed without changes.
13 changes: 8 additions & 5 deletions vars_gridview/scripts/run.py → src/vars_gridview/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from vars_gridview.lib.util import open_file_browser
from vars_gridview.lib.widgets import RectWidget
from vars_gridview.ui.ConfirmationDialog import ConfirmationDialog
from vars_gridview.ui.JSONTree import JSONTree
from vars_gridview.ui.LoginDialog import LoginDialog
from vars_gridview.ui.QueryDialog import QueryDialog
from vars_gridview.ui.settings.SettingsDialog import SettingsDialog
Expand Down Expand Up @@ -86,6 +87,11 @@ def __init__(self, app):
# Create the main window
self.ui = WindowTemplate()
self.ui.setupUi(self)
bb_info_tree: QtWidgets.QWidget = self.ui.boundingBoxInfoTree
bb_info_tree.setLayout(QtWidgets.QVBoxLayout())
bb_json_tree = JSONTree()
bb_info_tree.layout().addWidget(bb_json_tree)
self.ui.boundingBoxInfoTree = bb_json_tree

# Set the window title
self.setWindowTitle(f"{constants.APP_NAME} v{__version__}")
Expand Down Expand Up @@ -728,7 +734,7 @@ def delete(self):
self.image_mosaic.delete_selected()
self.box_handler.roi_detail.clear()
self.box_handler.clear()
self.ui.annotationXML.clear()
self.boundingBoxInfoTree.clear()
self.ui.imageInfoList.clear()

self.image_mosaic.render_mosaic()
Expand Down Expand Up @@ -834,10 +840,7 @@ def rect_clicked(self, rect: RectWidget, event: Optional[QtGui.QMouseEvent]):
self.box_handler.add_annotation(rect.localization_index, rect)

# Add localization data to the panel
self.ui.annotationXML.clear()
self.ui.annotationXML.insertPlainText(
json.dumps(rect.localization.json, indent=2)
)
self.ui.boundingBoxInfoTree.set_data(rect.localization.json)

# Add ancillary data to the image info list
self.ui.imageInfoList.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,15 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTextEdit" name="annotationXML">
<widget class="QWidget" name="boundingBoxInfoTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<!-- Set read-only -->
<property name="readOnly">
<bool>true</bool>
</property>
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
Expand All @@ -107,7 +102,6 @@
</property>
<property name="font">
<font>
<family>MS Shell Dlg 2</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c8a8642

Please sign in to comment.