Skip to content

Commit

Permalink
add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayof committed Aug 6, 2024
1 parent 11d5c58 commit 630eff3
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
87 changes: 86 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions vision_agent/clients/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion vision_agent/clients/landing_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

0 comments on commit 630eff3

Please sign in to comment.