Skip to content

Commit 861e1b4

Browse files
authored
Merge pull request #451 from roboflow/ENT-1082
feat: add vision events SDK and CLI support
2 parents d45fb3e + a30e2a7 commit 861e1b4

15 files changed

Lines changed: 1922 additions & 27 deletions

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ jobs:
2828
run: |
2929
make publish -e PYPI_USERNAME=$PYPI_USERNAME -e PYPI_PASSWORD=$PYPI_PASSWORD -e PYPI_TEST_PASSWORD=$PYPI_TEST_PASSWORD
3030
31+
build-slim:
32+
needs: build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: 🛎️ Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.head_ref }}
39+
- name: 🐍 Set up Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.10'
43+
- name: 🦾 Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install ".[dev]"
47+
- name: 🚀 Publish roboflow-slim to PyPi
48+
env:
49+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
50+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
51+
run: |
52+
make publish-slim -e PYPI_USERNAME=$PYPI_USERNAME -e PYPI_PASSWORD=$PYPI_PASSWORD
53+
3154
deploy-docs:
3255
needs: build
3356
runs-on: ubuntu-latest

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
branches: [main]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
build:
1114
strategy:
@@ -35,3 +38,24 @@ jobs:
3538
make check_code_quality
3639
- name: 🧪 Run tests
3740
run: "python -m unittest"
41+
42+
test-slim:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: 🛎️ Checkout
46+
uses: actions/checkout@v4
47+
with:
48+
ref: ${{ github.event.pull_request.head.ref }}
49+
repository: ${{ github.event.pull_request.head.repo.full_name }}
50+
- name: 🐍 Set up Python 3.10
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: '3.10'
54+
- name: 🦾 Install slim dependencies
55+
run: |
56+
python -m pip install --upgrade pip
57+
pip install -r requirements-slim.txt
58+
pip install -e . --no-deps
59+
pip install responses
60+
- name: 🧪 Run slim-compatible tests
61+
run: "python -m unittest tests.test_slim_compat tests.test_vision_events"

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: style check_code_quality publish
1+
.PHONY: style check_code_quality publish publish-slim
22

33
export PYTHONPATH = .
44
check_dirs := roboflow
@@ -16,3 +16,9 @@ publish:
1616
python setup.py sdist bdist_wheel
1717
twine check dist/*
1818
twine upload dist/* -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} --verbose
19+
20+
publish-slim:
21+
rm -rf dist/ build/ *.egg-info
22+
python setup_slim.py sdist bdist_wheel
23+
twine check dist/*
24+
twine upload dist/* -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} --verbose

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ pip install "roboflow[desktop]"
5151
```
5252

5353

54+
<details>
55+
<summary>Lightweight install (roboflow-slim)</summary>
56+
57+
If you only need vision events, workspace management, and the CLI (no image processing, inference, or training), install the lightweight package:
58+
59+
```bash
60+
pip install roboflow-slim
61+
```
62+
63+
This skips heavy dependencies like OpenCV, NumPy, Matplotlib, and Pillow, reducing install size from ~400MB to ~50MB. Useful for embedded devices, CI pipelines, and serverless environments.
64+
65+
Both packages share the same codebase and version. `pip install roboflow` includes everything.
66+
</details>
67+
5468
<details>
5569
<summary>Install from source</summary>
5670

requirements-slim.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
certifi
2+
idna
3+
requests
4+
urllib3>=1.26.6
5+
tqdm>=4.41.0
6+
PyYAML>=5.3.1
7+
requests_toolbelt
8+
filetype
9+
typer>=0.12.0
10+
python-dateutil
11+
python-dotenv
12+
six

roboflow/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
from roboflow.adapters import rfapi
1212
from roboflow.config import API_URL, APP_URL, DEMO_KEYS, load_roboflow_api_key
13-
from roboflow.core.project import Project
1413
from roboflow.core.workspace import Workspace
15-
from roboflow.models import CLIPModel, GazeModel # noqa: F401
1614
from roboflow.util.general import write_line
1715

16+
try:
17+
from roboflow.core.project import Project
18+
from roboflow.models import CLIPModel, GazeModel # noqa: F401
19+
except ImportError:
20+
Project = None # type: ignore[assignment,misc]
21+
CLIPModel = None # type: ignore[assignment,misc]
22+
GazeModel = None # type: ignore[assignment,misc]
23+
1824
__version__ = "1.3.1"
1925

2026

@@ -250,6 +256,10 @@ def project(self, project_name, the_workspace=None):
250256
:param the_workspace workspace name
251257
:return project object
252258
"""
259+
if Project is None:
260+
raise ImportError(
261+
"Project requires additional dependencies. Install the full package: pip install roboflow"
262+
)
253263

254264
if the_workspace is None:
255265
if "/" in project_name:

roboflow/adapters/rfapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from requests_toolbelt.multipart.encoder import MultipartEncoder
99

1010
from roboflow.config import API_URL, DEFAULT_BATCH_NAME, DEFAULT_JOB_NAME
11-
from roboflow.util import image_utils
1211

1312

1413
class RoboflowError(Exception):
@@ -294,6 +293,8 @@ def upload_image(
294293

295294
# If image is not a hosted image
296295
if not hosted_image:
296+
from roboflow.util import image_utils
297+
297298
image_name = os.path.basename(image_path)
298299
imgjpeg = image_utils.file2jpeg(image_path)
299300

0 commit comments

Comments
 (0)