Skip to content

Commit 03f2952

Browse files
authored
added sdk version to headers (#100)
* added sdk version to headers * Update client.py * Update _version.py * format code * format * google format * parse __init__.py for version authored-by: Matt Sokoloff <msokoloff@labelbox.com>
1 parent 07a7d3f commit 03f2952

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

labelbox/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name = "labelbox"
2+
__version__ = "2.4.10"
23

34
from labelbox.client import Client
45
from labelbox.schema.bulk_import_request import BulkImportRequest
@@ -14,4 +15,4 @@
1415
from labelbox.schema.asset_metadata import AssetMetadata
1516
from labelbox.schema.webhook import Webhook
1617
from labelbox.schema.prediction import Prediction, PredictionModel
17-
from labelbox.schema.ontology import Ontology
18+
from labelbox.schema.ontology import Ontology

labelbox/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from labelbox.schema.user import User
2020
from labelbox.schema.organization import Organization
2121
from labelbox.schema.labeling_frontend import LabelingFrontend
22+
from labelbox import __version__ as SDK_VERSION
2223

2324
logger = logging.getLogger(__name__)
2425

@@ -66,7 +67,8 @@ def __init__(self,
6667
self.headers = {
6768
'Accept': 'application/json',
6869
'Content-Type': 'application/json',
69-
'Authorization': 'Bearer %s' % api_key
70+
'Authorization': 'Bearer %s' % api_key,
71+
'X-User-Agent': f'python-sdk {SDK_VERSION}'
7072
}
7173

7274
@retry.Retry(predicate=retry.if_exception_type(

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import setuptools
22

3+
with open('labelbox/__init__.py') as fid:
4+
for line in fid:
5+
if line.startswith('__version__'):
6+
SDK_VERSION = line.strip().split()[-1][1:-1]
7+
break
8+
39
with open("README.md", "r") as fh:
410
long_description = fh.read()
511

612
setuptools.setup(
713
name="labelbox",
8-
version="2.4.9",
14+
version=SDK_VERSION,
915
author="Labelbox",
1016
author_email="engineering@labelbox.com",
1117
description="Labelbox Python API",

0 commit comments

Comments
 (0)