From 657fb8380cd4f609ccd1f90fee48926d0c5a816d Mon Sep 17 00:00:00 2001 From: Adrian Chang Date: Thu, 18 Jul 2024 00:56:20 -0700 Subject: [PATCH 1/3] Publish demo --- libs/lbox-cli/.gitignore | 10 +++ libs/lbox-cli/Dockerfile | 44 +++++++++++++ libs/lbox-cli/README.md | 9 +++ libs/lbox-cli/pyproject.toml | 66 +++++++++++++++++++ libs/lbox-cli/src/lbox/cli/main.py | 18 +++++ .../lbox-cli/tests/unit/lbox/cli/test_main.py | 6 ++ 6 files changed, 153 insertions(+) create mode 100644 libs/lbox-cli/.gitignore create mode 100644 libs/lbox-cli/Dockerfile create mode 100644 libs/lbox-cli/README.md create mode 100644 libs/lbox-cli/pyproject.toml create mode 100644 libs/lbox-cli/src/lbox/cli/main.py create mode 100644 libs/lbox-cli/tests/unit/lbox/cli/test_main.py diff --git a/libs/lbox-cli/.gitignore b/libs/lbox-cli/.gitignore new file mode 100644 index 000000000..ae8554dec --- /dev/null +++ b/libs/lbox-cli/.gitignore @@ -0,0 +1,10 @@ +# python generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# venv +.venv diff --git a/libs/lbox-cli/Dockerfile b/libs/lbox-cli/Dockerfile new file mode 100644 index 000000000..2ee61ab7e --- /dev/null +++ b/libs/lbox-cli/Dockerfile @@ -0,0 +1,44 @@ +# https://github.com/ucyo/python-package-template/blob/master/Dockerfile +FROM python:3.8-slim as rye + +ENV LANG="C.UTF-8" \ + LC_ALL="C.UTF-8" \ + PATH="/home/python/.local/bin:/home/python/.rye/shims:$PATH" \ + PIP_NO_CACHE_DIR="false" \ + RYE_VERSION="0.34.0" \ + RYE_INSTALL_OPTION="--yes" \ + LABELBOX_TEST_ENVIRON="prod" + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + inotify-tools \ + make \ + # cv2 + libsm6 \ + libxext6 \ + ffmpeg \ + libfontconfig1 \ + libxrender1 \ + libgl1-mesa-glx \ + libgeos-dev \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +RUN groupadd --gid 1000 python && \ + useradd --uid 1000 --gid python --shell /bin/bash --create-home python + +USER 1000 +WORKDIR /home/python/ + +RUN curl -sSf https://rye.astral.sh/get | bash - + +COPY --chown=python:python . /home/python/labelbox-python/ +WORKDIR /home/python/labelbox-python + +RUN rye config --set-bool behavior.global-python=true && \ + rye config --set-bool behavior.use-uv=true && \ + rye pin 3.8 && \ + rye sync + +CMD rye run unit && rye integration \ No newline at end of file diff --git a/libs/lbox-cli/README.md b/libs/lbox-cli/README.md new file mode 100644 index 000000000..a7bf3e94f --- /dev/null +++ b/libs/lbox-cli/README.md @@ -0,0 +1,9 @@ +# lbox-example + +This is an example module which can be cloned and reused to develop modules under the `lbox` namespace. + +## Module Status: Experimental + +**TLDR: This module may be removed or altered at any given time and there is no offical support.** + +Please see [here](https://docs.labelbox.com/docs/product-release-phases) for the formal definition of `Experimental`. \ No newline at end of file diff --git a/libs/lbox-cli/pyproject.toml b/libs/lbox-cli/pyproject.toml new file mode 100644 index 000000000..bf0dbf8f4 --- /dev/null +++ b/libs/lbox-cli/pyproject.toml @@ -0,0 +1,66 @@ +[project] +name = "lbox-cli" +version = "0.1.0" +description = "A CLI tool for labelbox" +authors = [ + { name = "Labelbox", email = "engineering@labelbox.com" } +] +dependencies = [ + "tinydb>=4.8.0", + "click>=8.1.7", + "labelbox>=3.75.1", +] +readme = "README.md" +requires-python = ">= 3.8" + +classifiers=[ + # How mature is this project? + "Development Status :: 2 - Pre-Alpha", + # Indicate who your project is intended for + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Software Development :: Libraries", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + # Pick your license as you wish + "License :: OSI Approved :: Apache Software License", + # Specify the Python versions you support here. + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +keywords = ["ml", "ai", "labelbox", "labeling", "llm", "machinelearning", "edu"] + +[project.urls] +Homepage = "https://labelbox.com/" +Documentation = "https://labelbox-python.readthedocs.io/en/latest/" +Repository = "https://github.com/Labelbox/labelbox-python" +Issues = "https://github.com/Labelbox/labelbox-python/issues" +Changelog = "https://github.com/Labelbox/labelbox-python/blob/develop/libs/lbox-cli/CHANGELOG.md" + +[project.scripts] +lbox = 'lbox.cli.main:cli' + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.rye] +managed = true +dev-dependencies = [] + +[tool.rye.scripts] +unit = "pytest tests/unit" +integration = "python -c \"import sys; sys.exit(0)\"" + +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.wheel] +packages = ["src/lbox"] + +[tool.pytest.ini_options] +addopts = "-rP -vvv --durations=20 --cov=lbox.cli --import-mode=importlib" diff --git a/libs/lbox-cli/src/lbox/cli/main.py b/libs/lbox-cli/src/lbox/cli/main.py new file mode 100644 index 000000000..1073ee311 --- /dev/null +++ b/libs/lbox-cli/src/lbox/cli/main.py @@ -0,0 +1,18 @@ +import click +import tinydb +from pathlib import Path + +@click.group() +def cli(): + db = tinydb.TinyDB(Path.home() / '~/.lbox/db.json', create_dirs=True, access_mode='r+') + +@cli.group() +def key(): + pass + +@key.command() +def select(): + print('select') + +def init(): + return 'init' \ No newline at end of file diff --git a/libs/lbox-cli/tests/unit/lbox/cli/test_main.py b/libs/lbox-cli/tests/unit/lbox/cli/test_main.py new file mode 100644 index 000000000..20edbe22f --- /dev/null +++ b/libs/lbox-cli/tests/unit/lbox/cli/test_main.py @@ -0,0 +1,6 @@ +from lbox.cli.main import init + + +class TestArt: + def test_init(self): + assert init() == "init" From 744f207447552df85443532d1a510eb16d7e8043 Mon Sep 17 00:00:00 2001 From: Adrian Chang Date: Thu, 18 Jul 2024 00:58:17 -0700 Subject: [PATCH 2/3] pass linting --- libs/lbox-cli/src/lbox/cli/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/lbox-cli/src/lbox/cli/main.py b/libs/lbox-cli/src/lbox/cli/main.py index 1073ee311..f2ec664a6 100644 --- a/libs/lbox-cli/src/lbox/cli/main.py +++ b/libs/lbox-cli/src/lbox/cli/main.py @@ -2,17 +2,23 @@ import tinydb from pathlib import Path + @click.group() def cli(): - db = tinydb.TinyDB(Path.home() / '~/.lbox/db.json', create_dirs=True, access_mode='r+') + db = tinydb.TinyDB( + Path.home() / "~/.lbox/db.json", create_dirs=True, access_mode="r+" + ) + @cli.group() def key(): pass + @key.command() def select(): - print('select') + print("select") + def init(): - return 'init' \ No newline at end of file + return "init" From f0877ee77b127a2e5e8ceffc2afeb32d039da44b Mon Sep 17 00:00:00 2001 From: Adrian Chang Date: Thu, 18 Jul 2024 01:00:10 -0700 Subject: [PATCH 3/3] pass linting --- libs/lbox-cli/src/lbox/cli/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/lbox-cli/src/lbox/cli/main.py b/libs/lbox-cli/src/lbox/cli/main.py index f2ec664a6..23536ff0f 100644 --- a/libs/lbox-cli/src/lbox/cli/main.py +++ b/libs/lbox-cli/src/lbox/cli/main.py @@ -8,6 +8,7 @@ def cli(): db = tinydb.TinyDB( Path.home() / "~/.lbox/db.json", create_dirs=True, access_mode="r+" ) + print(db.count()) @cli.group()