unitlab 1.8.8__tar.gz → 1.9.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-1.8.8/src/unitlab.egg-info → unitlab-1.9.0}/PKG-INFO +1 -1
- {unitlab-1.8.8 → unitlab-1.9.0}/setup.py +1 -1
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab/cli.py +0 -22
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab/client.py +0 -34
- unitlab-1.9.0/src/unitlab/run.py +74 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab/utils.py +2 -6
- {unitlab-1.8.8 → unitlab-1.9.0/src/unitlab.egg-info}/PKG-INFO +1 -1
- unitlab-1.8.8/src/unitlab/run.py +0 -82
- {unitlab-1.8.8 → unitlab-1.9.0}/LICENSE.md +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/MANIFEST.in +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/README.md +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/setup.cfg +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab/__init__.py +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab/exceptions.py +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab.egg-info/SOURCES.txt +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab.egg-info/dependency_links.txt +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab.egg-info/entry_points.txt +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab.egg-info/requires.txt +0 -0
- {unitlab-1.8.8 → unitlab-1.9.0}/src/unitlab.egg-info/top_level.txt +0 -0
@@ -60,28 +60,6 @@ def task_statistics(api_key, task_id):
|
|
60
60
|
print(response.json())
|
61
61
|
|
62
62
|
|
63
|
-
def ai_models(api_key):
|
64
|
-
response = send_request(
|
65
|
-
{
|
66
|
-
"method": "GET",
|
67
|
-
"headers": get_headers(api_key),
|
68
|
-
"endpoint": ENDPOINTS["cli_ai_models"],
|
69
|
-
}
|
70
|
-
)
|
71
|
-
print(response.json())
|
72
|
-
|
73
|
-
|
74
|
-
def ai_model(api_key, pk):
|
75
|
-
response = send_request(
|
76
|
-
{
|
77
|
-
"method": "GET",
|
78
|
-
"headers": get_headers(api_key),
|
79
|
-
"endpoint": ENDPOINTS["cli_ai_model"].format(pk),
|
80
|
-
}
|
81
|
-
)
|
82
|
-
print(response.json())
|
83
|
-
|
84
|
-
|
85
63
|
def datasets(api_key):
|
86
64
|
response = send_request(
|
87
65
|
{
|
@@ -304,40 +304,6 @@ class UnitlabClient:
|
|
304
304
|
f.write(chunk)
|
305
305
|
return os.path.abspath(filename)
|
306
306
|
|
307
|
-
def ai_models(self):
|
308
|
-
"""Get a list of all ai models.
|
309
|
-
|
310
|
-
Returns:
|
311
|
-
A list of all ai models.
|
312
|
-
"""
|
313
|
-
response = send_request(
|
314
|
-
{
|
315
|
-
"method": "GET",
|
316
|
-
"endpoint": ENDPOINTS["ai_models"],
|
317
|
-
"headers": self._get_headers(),
|
318
|
-
},
|
319
|
-
session=self.api_session,
|
320
|
-
)
|
321
|
-
return response.json()
|
322
|
-
|
323
|
-
def ai_model(self, ai_model_id):
|
324
|
-
"""Get an ai model by id.
|
325
|
-
|
326
|
-
Args:
|
327
|
-
ai_model_id: The id of the ai model.
|
328
|
-
Returns:
|
329
|
-
An ai model.
|
330
|
-
"""
|
331
|
-
response = send_request(
|
332
|
-
{
|
333
|
-
"method": "GET",
|
334
|
-
"endpoint": ENDPOINTS["ai_model"].format(ai_model_id),
|
335
|
-
"headers": self._get_headers(),
|
336
|
-
},
|
337
|
-
session=self.api_session,
|
338
|
-
)
|
339
|
-
return response.json()
|
340
|
-
|
341
307
|
def datasets(self):
|
342
308
|
"""Get a list of all datasets.
|
343
309
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import logging
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import Optional
|
4
|
+
from uuid import UUID
|
5
|
+
|
6
|
+
import typer
|
7
|
+
from typing_extensions import Annotated
|
8
|
+
|
9
|
+
from . import cli
|
10
|
+
from .client import UnitlabClient
|
11
|
+
|
12
|
+
app = typer.Typer()
|
13
|
+
task_app = typer.Typer()
|
14
|
+
app.add_typer(task_app, name="task", help="Task commands")
|
15
|
+
|
16
|
+
API_KEY = Annotated[str, typer.Option(help="The api-key obtained from unitlab.ai")]
|
17
|
+
|
18
|
+
|
19
|
+
def get_client(api_key: str) -> UnitlabClient:
|
20
|
+
return UnitlabClient(api_key=api_key)
|
21
|
+
|
22
|
+
|
23
|
+
@task_app.command(name="list", help="Task List")
|
24
|
+
def task_list(api_key: API_KEY):
|
25
|
+
cli.tasks(api_key)
|
26
|
+
|
27
|
+
|
28
|
+
@task_app.command(name="detail", help="Task Detail")
|
29
|
+
def task_detail(pk: UUID, api_key: API_KEY):
|
30
|
+
cli.task(api_key, pk)
|
31
|
+
|
32
|
+
|
33
|
+
@task_app.command(help="Task datasources")
|
34
|
+
def data(pk: UUID, api_key: API_KEY):
|
35
|
+
cli.task_data(api_key, pk)
|
36
|
+
|
37
|
+
|
38
|
+
@task_app.command(help="Task members")
|
39
|
+
def members(pk: UUID, api_key: API_KEY):
|
40
|
+
cli.task_workers(api_key, pk)
|
41
|
+
|
42
|
+
|
43
|
+
@task_app.command(help="Task statistics")
|
44
|
+
def statistics(pk: UUID, api_key: API_KEY):
|
45
|
+
cli.task_statistics(api_key, pk)
|
46
|
+
|
47
|
+
|
48
|
+
@task_app.command(help="Upload data")
|
49
|
+
def upload(
|
50
|
+
pk: UUID,
|
51
|
+
api_key: API_KEY,
|
52
|
+
directory: Annotated[
|
53
|
+
Path, typer.Option(help="Directory containing the data to be uploaded")
|
54
|
+
],
|
55
|
+
):
|
56
|
+
get_client(api_key).upload_data(str(pk), directory=directory)
|
57
|
+
|
58
|
+
|
59
|
+
@app.command()
|
60
|
+
def dataset(
|
61
|
+
api_key: API_KEY,
|
62
|
+
pk: Annotated[Optional[UUID], typer.Argument()] = None,
|
63
|
+
):
|
64
|
+
"""
|
65
|
+
List or retrieve a dataset if pk is provided
|
66
|
+
"""
|
67
|
+
if pk:
|
68
|
+
logging.info(f"File: {get_client(api_key).dataset(pk)}")
|
69
|
+
else:
|
70
|
+
cli.datasets(api_key)
|
71
|
+
|
72
|
+
|
73
|
+
if __name__ == "__main__":
|
74
|
+
app()
|
@@ -6,8 +6,6 @@ from .exceptions import AuthenticationError
|
|
6
6
|
|
7
7
|
ENDPOINTS = {
|
8
8
|
"check": "/api/check/",
|
9
|
-
"ai_models": "/api/sdk/ai-models/",
|
10
|
-
"ai_model": "/api/sdk/ai-model/{}/",
|
11
9
|
"tasks": "/api/sdk/tasks/",
|
12
10
|
"task": "/api/sdk/tasks/{}/",
|
13
11
|
"task_datasources": "/api/sdk/tasks/{}/datasources/",
|
@@ -17,8 +15,6 @@ ENDPOINTS = {
|
|
17
15
|
"download_data": "/api/sdk/tasks/{}/download-data/",
|
18
16
|
"datasets": "/api/sdk/datasets/",
|
19
17
|
"dataset": "/api/sdk/datasets/{}/",
|
20
|
-
"cli_ai_models": "/api/cli/ai-models/",
|
21
|
-
"cli_ai_model": "/api/cli/ai-model/{}/",
|
22
18
|
"cli_tasks": "/api/cli/tasks/",
|
23
19
|
"cli_task": "/api/cli/tasks/{}/",
|
24
20
|
"cli_task_datasources": "/api/cli/tasks/{}/datasources/",
|
@@ -30,8 +26,8 @@ ENDPOINTS = {
|
|
30
26
|
|
31
27
|
def send_request(request, session=None):
|
32
28
|
endpoint = request.pop("endpoint")
|
33
|
-
if
|
34
|
-
request["url"] =
|
29
|
+
if os.environ.get("UNITLAB_BASE_URL"):
|
30
|
+
request["url"] = os.environ.get("UNITLAB_BASE_URL") + endpoint
|
35
31
|
response = (
|
36
32
|
session.request(**request) if session else requests.request(**request)
|
37
33
|
)
|
unitlab-1.8.8/src/unitlab/run.py
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
from pathlib import Path
|
3
|
-
from uuid import UUID
|
4
|
-
|
5
|
-
import typer
|
6
|
-
from typing_extensions import Annotated
|
7
|
-
|
8
|
-
from . import cli
|
9
|
-
from .client import UnitlabClient
|
10
|
-
|
11
|
-
app = typer.Typer()
|
12
|
-
|
13
|
-
API_KEY = Annotated[str, typer.Option(help="The api-key obtained from unitlab.ai")]
|
14
|
-
|
15
|
-
|
16
|
-
def get_client(api_key: str) -> UnitlabClient:
|
17
|
-
return UnitlabClient(api_key=api_key)
|
18
|
-
|
19
|
-
|
20
|
-
@app.command(help="Task list")
|
21
|
-
def tasks(api_key: API_KEY):
|
22
|
-
cli.tasks(api_key)
|
23
|
-
|
24
|
-
|
25
|
-
@app.command(help="Task detail")
|
26
|
-
def task(pk: UUID, api_key: API_KEY):
|
27
|
-
cli.task(api_key, pk)
|
28
|
-
|
29
|
-
|
30
|
-
@app.command(help="Task datasources")
|
31
|
-
def task_data(pk: UUID, api_key: API_KEY):
|
32
|
-
cli.task_data(api_key, pk)
|
33
|
-
|
34
|
-
|
35
|
-
@app.command(help="Task workers")
|
36
|
-
def task_workers(pk: UUID, api_key: API_KEY):
|
37
|
-
cli.task_workers(api_key, pk)
|
38
|
-
|
39
|
-
|
40
|
-
@app.command(help="Task statistics")
|
41
|
-
def task_statistics(pk: UUID, api_key: API_KEY):
|
42
|
-
cli.task_statistics(api_key, pk)
|
43
|
-
|
44
|
-
|
45
|
-
@app.command(help="Upload data")
|
46
|
-
def upload_data(
|
47
|
-
pk: UUID,
|
48
|
-
api_key: API_KEY,
|
49
|
-
directory: Annotated[
|
50
|
-
Path, typer.Option(help="Directory containing the data to be uploaded")
|
51
|
-
],
|
52
|
-
):
|
53
|
-
get_client(api_key).upload_data(str(pk), directory=directory)
|
54
|
-
|
55
|
-
|
56
|
-
@app.command(help="Download data")
|
57
|
-
def download_data(pk: UUID, api_key: API_KEY):
|
58
|
-
logging.info(f"File: {get_client(api_key).download_data(pk)}")
|
59
|
-
|
60
|
-
|
61
|
-
@app.command(help="AI models")
|
62
|
-
def ai_models(api_key: API_KEY):
|
63
|
-
cli.ai_models(api_key)
|
64
|
-
|
65
|
-
|
66
|
-
@app.command(help="AI model")
|
67
|
-
def ai_model(pk: UUID, api_key: API_KEY):
|
68
|
-
cli.ai_model(api_key, pk)
|
69
|
-
|
70
|
-
|
71
|
-
@app.command(help="Datasets")
|
72
|
-
def datasets(api_key: API_KEY):
|
73
|
-
cli.datasets(api_key)
|
74
|
-
|
75
|
-
|
76
|
-
@app.command(help="Dataset")
|
77
|
-
def dataset(pk: UUID, api_key: API_KEY):
|
78
|
-
logging.info(f"File: {get_client(api_key).dataset(pk)}")
|
79
|
-
|
80
|
-
|
81
|
-
if __name__ == "__main__":
|
82
|
-
app()
|
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
|