Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,30 @@
run: |
make publish -e PYPI_USERNAME=$PYPI_USERNAME -e PYPI_PASSWORD=$PYPI_PASSWORD -e PYPI_TEST_PASSWORD=$PYPI_TEST_PASSWORD

build-slim:
needs: build
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 🦾 Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
- name: 🚀 Publish roboflow-slim to PyPi
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
make publish-slim -e PYPI_USERNAME=$PYPI_USERNAME -e PYPI_PASSWORD=$PYPI_PASSWORD

deploy-docs:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
needs: build
runs-on: ubuntu-latest
permissions:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
build:
strategy:
Expand Down Expand Up @@ -35,3 +38,24 @@ jobs:
make check_code_quality
- name: 🧪 Run tests
run: "python -m unittest"

test-slim:
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: 🐍 Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: 🦾 Install slim dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-slim.txt
pip install -e . --no-deps
pip install responses
- name: 🧪 Run slim-compatible tests
run: "python -m unittest tests.test_slim_compat tests.test_vision_events"
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: style check_code_quality publish
.PHONY: style check_code_quality publish publish-slim

export PYTHONPATH = .
check_dirs := roboflow
Expand All @@ -16,3 +16,9 @@ publish:
python setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/* -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} --verbose

publish-slim:
rm -rf dist/ build/ *.egg-info
python setup_slim.py sdist bdist_wheel
twine check dist/*
twine upload dist/* -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} --verbose
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ pip install "roboflow[desktop]"
```


<details>
<summary>Lightweight install (roboflow-slim)</summary>

If you only need vision events, workspace management, and the CLI (no image processing, inference, or training), install the lightweight package:

```bash
pip install roboflow-slim
```

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.

Both packages share the same codebase and version. `pip install roboflow` includes everything.
</details>

<details>
<summary>Install from source</summary>

Expand Down
12 changes: 12 additions & 0 deletions requirements-slim.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
certifi
idna
requests
urllib3>=1.26.6
tqdm>=4.41.0
PyYAML>=5.3.1
requests_toolbelt
filetype
typer>=0.12.0
python-dateutil
python-dotenv
six
14 changes: 12 additions & 2 deletions roboflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@

from roboflow.adapters import rfapi
from roboflow.config import API_URL, APP_URL, DEMO_KEYS, load_roboflow_api_key
from roboflow.core.project import Project
from roboflow.core.workspace import Workspace
from roboflow.models import CLIPModel, GazeModel # noqa: F401
from roboflow.util.general import write_line

try:
from roboflow.core.project import Project
from roboflow.models import CLIPModel, GazeModel # noqa: F401
except ImportError:
Project = None # type: ignore[assignment,misc]
CLIPModel = None # type: ignore[assignment,misc]
GazeModel = None # type: ignore[assignment,misc]

__version__ = "1.3.1"


Expand Down Expand Up @@ -250,6 +256,10 @@ def project(self, project_name, the_workspace=None):
:param the_workspace workspace name
:return project object
"""
if Project is None:
raise ImportError(
"Project requires additional dependencies. Install the full package: pip install roboflow"
)

if the_workspace is None:
if "/" in project_name:
Expand Down
3 changes: 2 additions & 1 deletion roboflow/adapters/rfapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from requests_toolbelt.multipart.encoder import MultipartEncoder

from roboflow.config import API_URL, DEFAULT_BATCH_NAME, DEFAULT_JOB_NAME
from roboflow.util import image_utils


class RoboflowError(Exception):
Expand Down Expand Up @@ -294,6 +293,8 @@ def upload_image(

# If image is not a hosted image
if not hosted_image:
from roboflow.util import image_utils

image_name = os.path.basename(image_path)
imgjpeg = image_utils.file2jpeg(image_path)

Expand Down
Loading
Loading