Skip to content

Commit

Permalink
build: add client header
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-v2-3 committed Jun 21, 2024
1 parent c0a7f70 commit cff83a2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
22 changes: 11 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
import os
from setuptools import setup, find_packages

ROOT = os.path.dirname(__file__)
ROOT = os.path.dirname(os.path.abspath(__file__))


# Read in the package version per recommendations from:
# https://packaging.python.org/guides/single-sourcing-package-version/
def get_version():
with open(os.path.join(ROOT, "videodb", "__init__.py")) as f:
for line in f.readlines():
if line.startswith("__version__"):
return line.split("=")[1].strip().strip('''"''')

about_path = os.path.join(ROOT, "videodb", "__about__.py")
about = {}
with open(about_path) as fp:
exec(fp.read(), about)


# read the contents of README file
long_description = open(os.path.join(ROOT, "README.md"), "r", encoding="utf-8").read()


setup(
name="videodb",
version=get_version(),
author="videodb",
author_email="[email protected]",
name=about["__title__"],
version=about["__version__"],
author=about["__author__"],
author_email=about["__email__"],
description="VideoDB Python SDK",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/video-db/videodb-python",
url=about["__url__"],
packages=find_packages(exclude=["tests", "tests.*"]),
python_requires=">=3.8",
install_requires=[
Expand Down
8 changes: 8 additions & 0 deletions videodb/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
""" About information for videodb sdk"""


__version__ = "0.2.0"
__title__ = "videodb"
__author__ = "videodb"
__email__ = "[email protected]"
__url__ = "https://github.com/video-db/videodb-python"
1 change: 1 addition & 0 deletions videodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging

from typing import Optional
from videodb.__about__ import __version__
from videodb._utils._video import play_stream
from videodb._constants import (
VIDEO_DB_API,
Expand Down
8 changes: 7 additions & 1 deletion videodb/_utils/_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
self,
api_key: str,
base_url: str,
version: str,
max_retries: Optional[int] = HttpClientDefaultValues.max_retries,
) -> None:
"""Create a new http client instance
Expand All @@ -50,8 +51,13 @@ def __init__(
adapter = HTTPAdapter(max_retries=retries)
self.session.mount("http://", adapter)
self.session.mount("https://", adapter)
self.version = version
self.session.headers.update(
{"x-access-token": api_key, "Content-Type": "application/json"}
{
"x-access-token": api_key,
"x-videodb-client": f"videodb-python/{self.version}",
"Content-Type": "application/json",
}
)
self.base_url = base_url
self.show_progress = False
Expand Down
4 changes: 2 additions & 2 deletions videodb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Union,
List,
)

from videodb import __version__
from videodb._constants import (
ApiPath,
)
Expand All @@ -28,7 +28,7 @@ def __init__(self, api_key: str, base_url: str) -> None:
self.api_key = api_key
self.base_url = base_url
self.collection_id = "default"
super().__init__(api_key, base_url)
super().__init__(api_key=api_key, base_url=base_url, version=__version__)

def get_collection(self, collection_id: Optional[str] = "default") -> Collection:
collection_data = self.get(path=f"{ApiPath.collection}/{collection_id}")
Expand Down
1 change: 0 additions & 1 deletion videodb/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ def list_scene_index(self) -> List:
index_data = self._connection.get(
path=f"{ApiPath.video}/{self.id}/{ApiPath.index}/{ApiPath.scene}"
)

return index_data.get("scene_indexes", [])

def get_scene_index(self, scene_index_id: str) -> Optional[List]:
Expand Down

0 comments on commit cff83a2

Please sign in to comment.