diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..457961bd --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: + - repo: https://github.com/psf/black + rev: 24.4.2 + hooks: + - id: black + language_version: python3.9 + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 diff --git a/poetry.lock b/poetry.lock index cd0799a3..3bd1ca8b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -282,6 +282,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + [[package]] name = "charset-normalizer" version = "3.3.2" @@ -479,6 +490,17 @@ files = [ {file = "decorator-4.4.2.tar.gz", hash = "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"}, ] +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + [[package]] name = "distro" version = "1.9.0" @@ -761,6 +783,20 @@ testing = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "fastapi", "gr torch = ["safetensors[torch]", "torch"] typing = ["types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)"] +[[package]] +name = "identify" +version = "2.6.0" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.6.0-py2.py3-none-any.whl", hash = "sha256:e79ae4406387a9d300332b5fd366d8994f1525e8414984e1a59e058b2eda2dd0"}, + {file = "identify-2.6.0.tar.gz", hash = "sha256:cb171c685bdc31bcc4c1734698736a7d5b6c8bf2e0c15117f4d469c8640ae5cf"}, +] + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.7" @@ -1616,6 +1652,17 @@ doc = ["nb2plots (>=0.7)", "nbconvert (<7.9)", "numpydoc (>=1.6)", "pillow (>=9. extra = ["lxml (>=4.6)", "pydot (>=1.4.2)", "pygraphviz (>=1.11)", "sympy (>=1.10)"] test = ["pytest (>=7.2)", "pytest-cov (>=4.0)"] +[[package]] +name = "nodeenv" +version = "1.9.1" +description = "Node.js virtual environment builder" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, + {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, +] + [[package]] name = "nptyping" version = "2.5.0" @@ -2124,6 +2171,24 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pre-commit" +version = "3.8.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.9" +files = [ + {file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"}, + {file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "proglog" version = "0.1.10" @@ -3464,6 +3529,26 @@ h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] +[[package]] +name = "virtualenv" +version = "20.26.3" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.26.3-py3-none-any.whl", hash = "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589"}, + {file = "virtualenv-20.26.3.tar.gz", hash = "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "watchdog" version = "4.0.1" @@ -3537,4 +3622,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "dcfbb136239868e45fa3aa41e87653e9e7f8174e2ed4ccfab03b3a391f9a16c5" +content-hash = "d42117f2f0150ad2fc3cde5913d985b8d8059e4606c77860b80fac76b655800e" diff --git a/pyproject.toml b/pyproject.toml index 59d4c723..e56d77de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,7 @@ mkdocstrings = {extras = ["python"], version = "^0.23.0"} mkdocs-material = "^9.4.2" types-tabulate = "^0.9.0.20240106" scikit-image = "<0.23.1" +pre-commit = "^3.8.0" [tool.pytest.ini_options] log_cli = true diff --git a/vision_agent/clients/http.py b/vision_agent/clients/http.py index 6cd37654..a041952f 100644 --- a/vision_agent/clients/http.py +++ b/vision_agent/clients/http.py @@ -13,7 +13,9 @@ class BaseHTTP: _TIMEOUT = 30 # seconds _MAX_RETRIES = 3 - def __init__(self, base_endpoint: str, *, headers: Optional[Dict[str, Any]] = None) -> None: + def __init__( + self, base_endpoint: str, *, headers: Optional[Dict[str, Any]] = None + ) -> None: self._headers = headers if headers is None: self._headers = { @@ -22,16 +24,16 @@ def __init__(self, base_endpoint: str, *, headers: Optional[Dict[str, Any]] = No self._base_endpoint = base_endpoint self._session = Session() self._session.headers.update(self._headers) - self._session.mount(self._base_endpoint, HTTPAdapter(max_retries=self._MAX_RETRIES)) + self._session.mount( + self._base_endpoint, HTTPAdapter(max_retries=self._MAX_RETRIES) + ) def post(self, url: str, payload: Dict[str, Any]) -> None: formatted_url = f"{self._base_endpoint}/{url}" _LOGGER.info(f"Sending data to {formatted_url}") try: response = self._session.post( - url=formatted_url, - json=payload, - timeout=self._TIMEOUT + url=formatted_url, json=payload, timeout=self._TIMEOUT ) response.raise_for_status() _LOGGER.info(json.dumps(response.json())) diff --git a/vision_agent/clients/landing_public_api.py b/vision_agent/clients/landing_public_api.py index 846ea935..c62faa33 100644 --- a/vision_agent/clients/landing_public_api.py +++ b/vision_agent/clients/landing_public_api.py @@ -20,7 +20,7 @@ def launch_fine_tuning_job( url = "v1/agent/jobs/fine-tuning" data = { "model": {"name": model_name, "task": task}, - "bboxes": [bbox.model_dump(by_alias=True) for bbox in bboxes] + "bboxes": [bbox.model_dump(by_alias=True) for bbox in bboxes], } response = self.post(url, payload=data) return UUID(response["jobId"])