Skip to content

Commit cff83a2

Browse files
committed
build: add client header
1 parent c0a7f70 commit cff83a2

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

setup.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
import os
33
from setuptools import setup, find_packages
44

5-
ROOT = os.path.dirname(__file__)
5+
ROOT = os.path.dirname(os.path.abspath(__file__))
66

77

88
# Read in the package version per recommendations from:
99
# https://packaging.python.org/guides/single-sourcing-package-version/
10-
def get_version():
11-
with open(os.path.join(ROOT, "videodb", "__init__.py")) as f:
12-
for line in f.readlines():
13-
if line.startswith("__version__"):
14-
return line.split("=")[1].strip().strip('''"''')
10+
11+
about_path = os.path.join(ROOT, "videodb", "__about__.py")
12+
about = {}
13+
with open(about_path) as fp:
14+
exec(fp.read(), about)
1515

1616

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

2020

2121
setup(
22-
name="videodb",
23-
version=get_version(),
24-
author="videodb",
25-
author_email="contact@videodb.io",
22+
name=about["__title__"],
23+
version=about["__version__"],
24+
author=about["__author__"],
25+
author_email=about["__email__"],
2626
description="VideoDB Python SDK",
2727
long_description=long_description,
2828
long_description_content_type="text/markdown",
29-
url="https://github.com/video-db/videodb-python",
29+
url=about["__url__"],
3030
packages=find_packages(exclude=["tests", "tests.*"]),
3131
python_requires=">=3.8",
3232
install_requires=[

videodb/__about__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
""" About information for videodb sdk"""
2+
3+
4+
__version__ = "0.2.0"
5+
__title__ = "videodb"
6+
__author__ = "videodb"
7+
__email__ = "contact@videodb.io"
8+
__url__ = "https://github.com/video-db/videodb-python"

videodb/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55

66
from typing import Optional
7+
from videodb.__about__ import __version__
78
from videodb._utils._video import play_stream
89
from videodb._constants import (
910
VIDEO_DB_API,

videodb/_utils/_http_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(
3232
self,
3333
api_key: str,
3434
base_url: str,
35+
version: str,
3536
max_retries: Optional[int] = HttpClientDefaultValues.max_retries,
3637
) -> None:
3738
"""Create a new http client instance
@@ -50,8 +51,13 @@ def __init__(
5051
adapter = HTTPAdapter(max_retries=retries)
5152
self.session.mount("http://", adapter)
5253
self.session.mount("https://", adapter)
54+
self.version = version
5355
self.session.headers.update(
54-
{"x-access-token": api_key, "Content-Type": "application/json"}
56+
{
57+
"x-access-token": api_key,
58+
"x-videodb-client": f"videodb-python/{self.version}",
59+
"Content-Type": "application/json",
60+
}
5561
)
5662
self.base_url = base_url
5763
self.show_progress = False

videodb/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Union,
66
List,
77
)
8-
8+
from videodb import __version__
99
from videodb._constants import (
1010
ApiPath,
1111
)
@@ -28,7 +28,7 @@ def __init__(self, api_key: str, base_url: str) -> None:
2828
self.api_key = api_key
2929
self.base_url = base_url
3030
self.collection_id = "default"
31-
super().__init__(api_key, base_url)
31+
super().__init__(api_key=api_key, base_url=base_url, version=__version__)
3232

3333
def get_collection(self, collection_id: Optional[str] = "default") -> Collection:
3434
collection_data = self.get(path=f"{ApiPath.collection}/{collection_id}")

videodb/video.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ def list_scene_index(self) -> List:
276276
index_data = self._connection.get(
277277
path=f"{ApiPath.video}/{self.id}/{ApiPath.index}/{ApiPath.scene}"
278278
)
279-
280279
return index_data.get("scene_indexes", [])
281280

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

0 commit comments

Comments
 (0)