unitlab 2.1.8__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unitlab-2.1.8/src/unitlab.egg-info → unitlab-2.2.0}/PKG-INFO +1 -1
- {unitlab-2.1.8 → unitlab-2.2.0}/setup.py +1 -1
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/client.py +6 -10
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/main.py +3 -3
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/utils.py +1 -1
- {unitlab-2.1.8 → unitlab-2.2.0/src/unitlab.egg-info}/PKG-INFO +1 -1
- {unitlab-2.1.8 → unitlab-2.2.0}/LICENSE.md +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/README.md +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/setup.cfg +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/__init__.py +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/__main__.py +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/dataset.py +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab/exceptions.py +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab.egg-info/SOURCES.txt +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab.egg-info/dependency_links.txt +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab.egg-info/entry_points.txt +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab.egg-info/requires.txt +0 -0
- {unitlab-2.1.8 → unitlab-2.2.0}/src/unitlab.egg-info/top_level.txt +0 -0
@@ -9,8 +9,9 @@ import aiohttp
|
|
9
9
|
import requests
|
10
10
|
import tqdm
|
11
11
|
|
12
|
-
from . import exceptions
|
12
|
+
from . import exceptions
|
13
13
|
from .dataset import DatasetUploadHandler
|
14
|
+
from .utils import get_api_url, handle_exceptions
|
14
15
|
|
15
16
|
logger = logging.getLogger(__name__)
|
16
17
|
|
@@ -48,14 +49,9 @@ class UnitlabClient:
|
|
48
49
|
:exc:`~unitlab.exceptions.AuthenticationError`: If an invalid API key is used or (when not passing the API key directly) if ``UNITLAB_API_KEY`` is not found in your environment.
|
49
50
|
"""
|
50
51
|
|
51
|
-
def __init__(self, api_key
|
52
|
-
if api_key is None:
|
53
|
-
api_key = utils.get_api_key()
|
54
|
-
if api_url is None:
|
55
|
-
api_url = utils.get_api_url()
|
56
|
-
|
52
|
+
def __init__(self, api_key, api_url=None):
|
57
53
|
self.api_key = api_key
|
58
|
-
self.api_url = api_url
|
54
|
+
self.api_url = api_url or get_api_url()
|
59
55
|
self.api_session = requests.Session()
|
60
56
|
adapter = requests.adapters.HTTPAdapter(max_retries=3)
|
61
57
|
self.api_session.mount("http://", adapter)
|
@@ -95,13 +91,13 @@ class UnitlabClient:
|
|
95
91
|
def _get_headers(self):
|
96
92
|
return {"Authorization": f"Api-Key {self.api_key}"}
|
97
93
|
|
98
|
-
@
|
94
|
+
@handle_exceptions
|
99
95
|
def _get(self, endpoint):
|
100
96
|
return self.api_session.get(
|
101
97
|
urllib.parse.urljoin(self.api_url, endpoint), headers=self._get_headers()
|
102
98
|
)
|
103
99
|
|
104
|
-
@
|
100
|
+
@handle_exceptions
|
105
101
|
def _post(self, endpoint, data=None):
|
106
102
|
return self.api_session.post(
|
107
103
|
urllib.parse.urljoin(self.api_url, endpoint),
|
@@ -6,8 +6,8 @@ import typer
|
|
6
6
|
import validators
|
7
7
|
from typing_extensions import Annotated
|
8
8
|
|
9
|
+
from . import utils
|
9
10
|
from .client import UnitlabClient
|
10
|
-
from .utils import get_api_key, write_config
|
11
11
|
|
12
12
|
app = typer.Typer()
|
13
13
|
project_app = typer.Typer()
|
@@ -20,7 +20,7 @@ app.add_typer(dataset_app, name="dataset", help="Dataset commands")
|
|
20
20
|
API_KEY = Annotated[
|
21
21
|
str,
|
22
22
|
typer.Option(
|
23
|
-
default_factory=get_api_key, help="The api-key obtained from unitlab.ai"
|
23
|
+
default_factory=utils.get_api_key, help="The api-key obtained from unitlab.ai"
|
24
24
|
),
|
25
25
|
]
|
26
26
|
|
@@ -46,7 +46,7 @@ def configure(
|
|
46
46
|
):
|
47
47
|
if not validators.url(api_url, simple_host=True):
|
48
48
|
raise typer.BadParameter("Invalid api url")
|
49
|
-
write_config(api_key=api_key, api_url=api_url)
|
49
|
+
utils.write_config(api_key=api_key, api_url=api_url)
|
50
50
|
|
51
51
|
|
52
52
|
def get_client(api_key: str) -> UnitlabClient:
|
@@ -53,7 +53,7 @@ def get_api_key() -> str:
|
|
53
53
|
return config.get("default", "api_key")
|
54
54
|
except Exception:
|
55
55
|
raise exceptions.ConfigurationError(
|
56
|
-
f"Key `api_key` not found in {CONFIG_FILE_PATH}. Please run `unitlab configure` or provide
|
56
|
+
f"Key `api_key` not found in {CONFIG_FILE_PATH}. Please run `unitlab configure` or provide the api-key using the --api-key option."
|
57
57
|
)
|
58
58
|
|
59
59
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|