File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 5
5
# Imports from our code
6
6
from .client import Groundlight
7
7
from .binary_labels import Label
8
+ from .version import get_version
8
9
9
- try :
10
- import importlib .metadata
11
-
12
- # Copy the version number from where it's set in pyproject.toml
13
- __version__ = importlib .metadata .version ("groundlight" )
14
- except ModuleNotFoundError :
15
- # importlib.metadata was only added in py3.8
16
- # We're still supporting py3.7
17
- __version__ = "(version number available in python 3.8+)"
10
+ __version__ = get_version ()
Original file line number Diff line number Diff line change 14
14
15
15
from groundlight .images import ByteStreamWrapper
16
16
from groundlight .status_codes import is_ok
17
+ from groundlight .version import get_version
17
18
18
19
logger = logging .getLogger ("groundlight.sdk" )
19
20
@@ -186,6 +187,9 @@ def _headers(self) -> dict:
186
187
"Content-Type" : "application/json" ,
187
188
"x-api-token" : self .configuration .api_key ["ApiToken" ],
188
189
"X-Request-Id" : request_id ,
190
+ # This metadata helps us debug issues with specific SDK versions.
191
+ "x-sdk-version" : get_version (),
192
+ "x-sdk-language" : "python" ,
189
193
}
190
194
191
195
@RequestsRetryDecorator ()
Original file line number Diff line number Diff line change
1
+ def get_version () -> str :
2
+ try :
3
+ import importlib .metadata # pylint: disable=import-outside-toplevel
4
+
5
+ # Copy the version number from where it's set in pyproject.toml
6
+ return importlib .metadata .version ("groundlight" )
7
+ except ModuleNotFoundError :
8
+ # importlib.metadata was only added in py3.8
9
+ # We're still supporting py3.7
10
+ return "(version number available in python 3.8+)"
You can’t perform that action at this time.
0 commit comments