superb-ai-onprem 0.5.9__py3-none-any.whl → 0.5.11__py3-none-any.whl
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.
Potentially problematic release.
This version of superb-ai-onprem might be problematic. Click here for more details.
- spb_onprem/__init__.py +8 -0
- spb_onprem/_version.py +2 -2
- spb_onprem/activities/service.py +1 -2
- spb_onprem/contents/params/__init__.py +2 -0
- spb_onprem/contents/params/delete_content.py +10 -0
- spb_onprem/contents/queries.py +11 -0
- spb_onprem/contents/service.py +19 -0
- spb_onprem/data/entities/data.py +0 -1
- spb_onprem/data/params/__init__.py +8 -0
- spb_onprem/data/params/create_data.py +2 -10
- spb_onprem/data/params/get_data_detail.py +14 -0
- spb_onprem/data/params/get_evaluation_value_list.py +36 -0
- spb_onprem/data/params/update_data.py +0 -16
- spb_onprem/data/params/upsert_data_meta.py +0 -12
- spb_onprem/data/queries.py +72 -6
- spb_onprem/data/service.py +103 -108
- spb_onprem/datasets/params/__init__.py +2 -0
- spb_onprem/datasets/params/delete_dataset.py +12 -0
- spb_onprem/datasets/queries.py +11 -0
- spb_onprem/datasets/service.py +18 -0
- spb_onprem/entities.py +4 -0
- spb_onprem/inferences/__init__.py +5 -0
- spb_onprem/inferences/service.py +56 -0
- spb_onprem/models/__init__.py +7 -0
- spb_onprem/models/entities.py +9 -0
- spb_onprem/models/params/__init__.py +7 -0
- spb_onprem/models/params/delete_model.py +14 -0
- spb_onprem/models/params/get_models.py +29 -0
- spb_onprem/models/queries.py +33 -0
- spb_onprem/models/service.py +76 -0
- spb_onprem/predictions/__init__.py +7 -0
- spb_onprem/predictions/entities.py +11 -0
- spb_onprem/predictions/params/__init__.py +15 -0
- spb_onprem/predictions/params/create_prediction_set.py +44 -0
- spb_onprem/predictions/params/delete_prediction_from_data.py +20 -0
- spb_onprem/predictions/params/delete_prediction_set.py +14 -0
- spb_onprem/predictions/params/get_prediction_set.py +14 -0
- spb_onprem/predictions/params/get_prediction_sets.py +29 -0
- spb_onprem/predictions/params/update_prediction_set_data_info.py +28 -0
- spb_onprem/predictions/queries.py +110 -0
- spb_onprem/predictions/service.py +225 -0
- {superb_ai_onprem-0.5.9.dist-info → superb_ai_onprem-0.5.11.dist-info}/METADATA +1 -1
- {superb_ai_onprem-0.5.9.dist-info → superb_ai_onprem-0.5.11.dist-info}/RECORD +57 -25
- tests/activities/test_params.py +2 -2
- tests/activities/test_service.py +28 -38
- tests/data/__init__.py +0 -0
- tests/data/test_data_service.py +412 -0
- tests/datasets/__init__.py +1 -0
- tests/datasets/test_dataset_service.py +135 -0
- tests/exports/test_service.py +1 -0
- tests/models/__init__.py +1 -0
- tests/models/test_model_service.py +249 -0
- tests/predictions/__init__.py +1 -0
- tests/predictions/test_prediction_service.py +359 -0
- {superb_ai_onprem-0.5.9.dist-info → superb_ai_onprem-0.5.11.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.5.9.dist-info → superb_ai_onprem-0.5.11.dist-info}/licenses/LICENSE +0 -0
- {superb_ai_onprem-0.5.9.dist-info → superb_ai_onprem-0.5.11.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
def delete_dataset_params(dataset_id: str):
|
|
2
|
+
"""Generate variables for delete dataset GraphQL mutation.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
dataset_id (str): The ID of the dataset to delete.
|
|
6
|
+
|
|
7
|
+
Returns:
|
|
8
|
+
dict: Variables dictionary for the GraphQL mutation.
|
|
9
|
+
"""
|
|
10
|
+
return {
|
|
11
|
+
"dataset_id": dataset_id
|
|
12
|
+
}
|
spb_onprem/datasets/queries.py
CHANGED
|
@@ -3,6 +3,7 @@ from spb_onprem.datasets.params import (
|
|
|
3
3
|
datasets_params,
|
|
4
4
|
create_dataset_params,
|
|
5
5
|
update_dataset_params,
|
|
6
|
+
delete_dataset_params,
|
|
6
7
|
)
|
|
7
8
|
|
|
8
9
|
class Schemas:
|
|
@@ -77,3 +78,13 @@ class Queries():
|
|
|
77
78
|
''',
|
|
78
79
|
"variables": update_dataset_params,
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
DELETE_DATASET = {
|
|
83
|
+
"name": "deleteDataset",
|
|
84
|
+
"query": '''
|
|
85
|
+
mutation DeleteDataset($dataset_id: String!) {
|
|
86
|
+
deleteDataset(datasetId: $dataset_id)
|
|
87
|
+
}
|
|
88
|
+
''',
|
|
89
|
+
"variables": delete_dataset_params,
|
|
90
|
+
}
|
spb_onprem/datasets/service.py
CHANGED
|
@@ -130,3 +130,21 @@ class DatasetService(BaseService):
|
|
|
130
130
|
),
|
|
131
131
|
)
|
|
132
132
|
return Dataset.model_validate(response)
|
|
133
|
+
|
|
134
|
+
def delete_dataset(self, dataset_id: str) -> bool:
|
|
135
|
+
"""Delete the dataset.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
dataset_id (str): The ID of the dataset to delete.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
bool: True if deletion was successful.
|
|
142
|
+
"""
|
|
143
|
+
if dataset_id is None:
|
|
144
|
+
raise BadParameterError("dataset_id is required.")
|
|
145
|
+
|
|
146
|
+
response = self.request_gql(
|
|
147
|
+
Queries.DELETE_DATASET,
|
|
148
|
+
Queries.DELETE_DATASET["variables"](dataset_id=dataset_id)
|
|
149
|
+
)
|
|
150
|
+
return response.get("deleteDataset", False)
|
spb_onprem/entities.py
CHANGED
|
@@ -26,6 +26,8 @@ from .activities.entities import (
|
|
|
26
26
|
)
|
|
27
27
|
from .exports.entities import Export
|
|
28
28
|
from .contents.entities import Content
|
|
29
|
+
from .predictions.entities import PredictionSet
|
|
30
|
+
from .models.entities import Model
|
|
29
31
|
|
|
30
32
|
__all__ = [
|
|
31
33
|
# Core Entities
|
|
@@ -43,6 +45,8 @@ __all__ = [
|
|
|
43
45
|
"Export",
|
|
44
46
|
"Content",
|
|
45
47
|
"Frame",
|
|
48
|
+
"PredictionSet",
|
|
49
|
+
"Model",
|
|
46
50
|
|
|
47
51
|
# Enums
|
|
48
52
|
"DataType",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
from spb_onprem.base_service import BaseService
|
|
5
|
+
from spb_onprem.exceptions import BadParameterError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InferService(BaseService):
|
|
9
|
+
"""Service class for handling inference operations."""
|
|
10
|
+
|
|
11
|
+
def __init__(self):
|
|
12
|
+
super().__init__()
|
|
13
|
+
self.model_endpoint_url = os.environ.get("MODEL_ENDPOINT_URL")
|
|
14
|
+
if not self.model_endpoint_url:
|
|
15
|
+
raise ValueError("MODEL_ENDPOINT_URL environment variable is required")
|
|
16
|
+
|
|
17
|
+
def infer_data(
|
|
18
|
+
self,
|
|
19
|
+
model_id: str,
|
|
20
|
+
base64_image: str
|
|
21
|
+
) -> Dict[str, Any]:
|
|
22
|
+
"""Perform inference on image data using the specified model.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
model_id (str): The model ID to use for inference.
|
|
26
|
+
base64_image (str): Base64 encoded image data.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Dict[str, Any]: The inference result.
|
|
30
|
+
|
|
31
|
+
Raises:
|
|
32
|
+
BadParameterError: If required parameters are missing.
|
|
33
|
+
"""
|
|
34
|
+
if model_id is None:
|
|
35
|
+
raise BadParameterError("model_id is required.")
|
|
36
|
+
if base64_image is None:
|
|
37
|
+
raise BadParameterError("base64_image is required.")
|
|
38
|
+
|
|
39
|
+
payload = {
|
|
40
|
+
"model_id": model_id,
|
|
41
|
+
"base64_image": base64_image,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
response = self.request(
|
|
46
|
+
method="POST",
|
|
47
|
+
url=self.model_endpoint_url,
|
|
48
|
+
json_data=payload,
|
|
49
|
+
headers={
|
|
50
|
+
"Content-Type": "application/json"
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
return response
|
|
54
|
+
except Exception as e:
|
|
55
|
+
print(f"Failed to fetch inference result: {e}")
|
|
56
|
+
raise
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def delete_model_params(dataset_id: str, model_id: str):
|
|
2
|
+
"""Generate variables for delete model GraphQL mutation.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
dataset_id (str): The ID of the dataset.
|
|
6
|
+
model_id (str): The ID of the model to delete.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
dict: Variables dictionary for the GraphQL mutation.
|
|
10
|
+
"""
|
|
11
|
+
return {
|
|
12
|
+
"dataset_id": dataset_id,
|
|
13
|
+
"id": model_id
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
def get_models_params(
|
|
2
|
+
dataset_id: str,
|
|
3
|
+
filter: dict = None,
|
|
4
|
+
cursor: str = None,
|
|
5
|
+
length: int = 50
|
|
6
|
+
):
|
|
7
|
+
"""Generate variables for get models GraphQL query.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
dataset_id (str): The ID of the dataset.
|
|
11
|
+
filter (dict, optional): Filter for models.
|
|
12
|
+
cursor (str, optional): Cursor for pagination.
|
|
13
|
+
length (int): Number of items to retrieve per page.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
dict: Variables dictionary for the GraphQL query.
|
|
17
|
+
"""
|
|
18
|
+
params = {
|
|
19
|
+
"dataset_id": dataset_id,
|
|
20
|
+
"length": length
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if filter is not None:
|
|
24
|
+
params["filter"] = filter
|
|
25
|
+
|
|
26
|
+
if cursor is not None:
|
|
27
|
+
params["cursor"] = cursor
|
|
28
|
+
|
|
29
|
+
return params
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from .params import (
|
|
2
|
+
get_models_params,
|
|
3
|
+
delete_model_params,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Queries:
|
|
8
|
+
GET_MODELS = {
|
|
9
|
+
"name": "getModels",
|
|
10
|
+
"query": '''
|
|
11
|
+
query GetModels($dataset_id: String!, $filter: ModelFilter, $cursor: String, $length: Int) {
|
|
12
|
+
models(datasetId: $dataset_id, filter: $filter, cursor: $cursor, length: $length) {
|
|
13
|
+
models {
|
|
14
|
+
id
|
|
15
|
+
name
|
|
16
|
+
}
|
|
17
|
+
next
|
|
18
|
+
totalCount
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
''',
|
|
22
|
+
"variables": get_models_params
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
DELETE_MODEL = {
|
|
26
|
+
"name": "deleteModel",
|
|
27
|
+
"query": '''
|
|
28
|
+
mutation DeleteModel($dataset_id: String!, $id: String!) {
|
|
29
|
+
deleteModel(datasetId: $dataset_id, id: $id)
|
|
30
|
+
}
|
|
31
|
+
''',
|
|
32
|
+
"variables": delete_model_params
|
|
33
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any, List, Tuple, Union
|
|
2
|
+
|
|
3
|
+
from spb_onprem.base_service import BaseService
|
|
4
|
+
from spb_onprem.base_types import Undefined, UndefinedType
|
|
5
|
+
from spb_onprem.exceptions import BadParameterError
|
|
6
|
+
from .queries import Queries
|
|
7
|
+
from .entities import Model
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ModelService(BaseService):
|
|
11
|
+
"""Service class for handling model operations."""
|
|
12
|
+
|
|
13
|
+
def get_models(
|
|
14
|
+
self,
|
|
15
|
+
dataset_id: str,
|
|
16
|
+
filter: Union[UndefinedType, Dict[str, Any]] = Undefined,
|
|
17
|
+
cursor: Union[UndefinedType, str] = Undefined,
|
|
18
|
+
length: int = 50
|
|
19
|
+
) -> Tuple[List[Model], Optional[str], int]:
|
|
20
|
+
"""Get paginated list of models for a dataset.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
dataset_id (str): The dataset ID.
|
|
24
|
+
filter (Union[UndefinedType, Dict[str, Any]]): Filter for models.
|
|
25
|
+
cursor (Union[UndefinedType, str]): Cursor for pagination.
|
|
26
|
+
length (int): Number of items to retrieve per page.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Tuple[List[Model], Optional[str], int]: A tuple containing models, next cursor, and total count.
|
|
30
|
+
"""
|
|
31
|
+
if dataset_id is None:
|
|
32
|
+
raise BadParameterError("dataset_id is required.")
|
|
33
|
+
|
|
34
|
+
response = self.request_gql(
|
|
35
|
+
Queries.GET_MODELS,
|
|
36
|
+
Queries.GET_MODELS["variables"](
|
|
37
|
+
dataset_id=dataset_id,
|
|
38
|
+
filter=filter,
|
|
39
|
+
cursor=cursor,
|
|
40
|
+
length=length
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
models_list = response.get("models", [])
|
|
44
|
+
return (
|
|
45
|
+
[Model.model_validate(model) for model in models_list],
|
|
46
|
+
response.get("next"),
|
|
47
|
+
response.get("totalCount", 0)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def delete_model(
|
|
51
|
+
self,
|
|
52
|
+
dataset_id: str,
|
|
53
|
+
model_id: str
|
|
54
|
+
) -> bool:
|
|
55
|
+
"""Delete a model from the dataset.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
dataset_id (str): The dataset ID.
|
|
59
|
+
model_id (str): The model ID to delete.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
bool: True if deletion was successful.
|
|
63
|
+
"""
|
|
64
|
+
if dataset_id is None:
|
|
65
|
+
raise BadParameterError("dataset_id is required.")
|
|
66
|
+
if model_id is None:
|
|
67
|
+
raise BadParameterError("model_id is required.")
|
|
68
|
+
|
|
69
|
+
response = self.request_gql(
|
|
70
|
+
Queries.DELETE_MODEL,
|
|
71
|
+
Queries.DELETE_MODEL["variables"](
|
|
72
|
+
dataset_id=dataset_id,
|
|
73
|
+
model_id=model_id
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
return response.get("deleteModel", False)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
from spb_onprem.base_model import CustomBaseModel, Field
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class PredictionSet(CustomBaseModel):
|
|
6
|
+
"""PredictionSet entity representing a set of predictions in the dataset."""
|
|
7
|
+
|
|
8
|
+
id: str
|
|
9
|
+
name: Optional[str] = None
|
|
10
|
+
annotations_contents: Optional[List[str]] = Field(None, alias="annotationsContents")
|
|
11
|
+
evaluation_result_content: Optional[dict] = Field(None, alias="evaluationResultContent")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .get_prediction_sets import get_prediction_sets_params
|
|
2
|
+
from .get_prediction_set import get_prediction_set_params
|
|
3
|
+
from .delete_prediction_set import delete_prediction_set_params
|
|
4
|
+
from .delete_prediction_from_data import delete_prediction_from_data_params
|
|
5
|
+
from .create_prediction_set import create_prediction_set_params
|
|
6
|
+
from .update_prediction_set_data_info import update_prediction_set_data_info_params
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"get_prediction_sets_params",
|
|
10
|
+
"get_prediction_set_params",
|
|
11
|
+
"delete_prediction_set_params",
|
|
12
|
+
"delete_prediction_from_data_params",
|
|
13
|
+
"create_prediction_set_params",
|
|
14
|
+
"update_prediction_set_data_info_params",
|
|
15
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def create_prediction_set_params(
|
|
5
|
+
dataset_id: str,
|
|
6
|
+
model_id: str,
|
|
7
|
+
name: str,
|
|
8
|
+
type: str,
|
|
9
|
+
description: Optional[str] = None,
|
|
10
|
+
annotations_count: Optional[int] = None,
|
|
11
|
+
data_count: Optional[int] = None,
|
|
12
|
+
) -> Dict[str, Any]:
|
|
13
|
+
"""Convert parameters for create_prediction_set GraphQL mutation.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
dataset_id (str): The dataset ID
|
|
17
|
+
model_id (str): The model ID
|
|
18
|
+
name (str): Name of the prediction set
|
|
19
|
+
type (str): Type of the prediction set
|
|
20
|
+
description (Optional[str]): Description of the prediction set
|
|
21
|
+
annotations_count (Optional[int]): Number of annotations
|
|
22
|
+
data_count (Optional[int]): Number of data items
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
Dict[str, Any]: Parameters formatted for GraphQL mutation
|
|
26
|
+
"""
|
|
27
|
+
params = {
|
|
28
|
+
"datasetId": dataset_id,
|
|
29
|
+
"modelId": model_id,
|
|
30
|
+
"name": name,
|
|
31
|
+
"type": type,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if description is not None:
|
|
35
|
+
params["description"] = description
|
|
36
|
+
|
|
37
|
+
if annotations_count is not None or data_count is not None:
|
|
38
|
+
params["dataInfo"] = {}
|
|
39
|
+
if annotations_count is not None:
|
|
40
|
+
params["dataInfo"]["annotationsCount"] = annotations_count
|
|
41
|
+
if data_count is not None:
|
|
42
|
+
params["dataInfo"]["dataCount"] = data_count
|
|
43
|
+
|
|
44
|
+
return params
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
def delete_prediction_from_data_params(
|
|
2
|
+
dataset_id: str,
|
|
3
|
+
data_id: str,
|
|
4
|
+
prediction_set_id: str
|
|
5
|
+
):
|
|
6
|
+
"""Generate variables for delete prediction from data GraphQL mutation.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
dataset_id (str): The ID of the dataset.
|
|
10
|
+
data_id (str): The ID of the data.
|
|
11
|
+
prediction_set_id (str): The ID of the prediction set.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
dict: Variables dictionary for the GraphQL mutation.
|
|
15
|
+
"""
|
|
16
|
+
return {
|
|
17
|
+
"dataset_id": dataset_id,
|
|
18
|
+
"data_id": data_id,
|
|
19
|
+
"prediction_set_id": prediction_set_id
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def delete_prediction_set_params(dataset_id: str, prediction_set_id: str):
|
|
2
|
+
"""Generate variables for delete prediction set GraphQL mutation.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
dataset_id (str): The ID of the dataset.
|
|
6
|
+
prediction_set_id (str): The ID of the prediction set to delete.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
dict: Variables dictionary for the GraphQL mutation.
|
|
10
|
+
"""
|
|
11
|
+
return {
|
|
12
|
+
"dataset_id": dataset_id,
|
|
13
|
+
"id": prediction_set_id
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def get_prediction_set_params(dataset_id: str, prediction_set_id: str):
|
|
2
|
+
"""Generate variables for get prediction set GraphQL query.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
dataset_id (str): The ID of the dataset.
|
|
6
|
+
prediction_set_id (str): The ID of the prediction set.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
dict: Variables dictionary for the GraphQL query.
|
|
10
|
+
"""
|
|
11
|
+
return {
|
|
12
|
+
"dataset_id": dataset_id,
|
|
13
|
+
"id": prediction_set_id
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
def get_prediction_sets_params(
|
|
2
|
+
dataset_id: str,
|
|
3
|
+
filter: dict = None,
|
|
4
|
+
cursor: str = None,
|
|
5
|
+
length: int = 50
|
|
6
|
+
):
|
|
7
|
+
"""Generate variables for get prediction sets GraphQL query.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
dataset_id (str): The ID of the dataset.
|
|
11
|
+
filter (dict, optional): Filter for prediction sets.
|
|
12
|
+
cursor (str, optional): Cursor for pagination.
|
|
13
|
+
length (int): Number of items to retrieve per page.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
dict: Variables dictionary for the GraphQL query.
|
|
17
|
+
"""
|
|
18
|
+
params = {
|
|
19
|
+
"dataset_id": dataset_id,
|
|
20
|
+
"length": length
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if filter is not None:
|
|
24
|
+
params["filter"] = filter
|
|
25
|
+
|
|
26
|
+
if cursor is not None:
|
|
27
|
+
params["cursor"] = cursor
|
|
28
|
+
|
|
29
|
+
return params
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def update_prediction_set_data_info_params(
|
|
5
|
+
dataset_id: str,
|
|
6
|
+
id: str,
|
|
7
|
+
annotation_count: int,
|
|
8
|
+
data_count: int
|
|
9
|
+
) -> Dict[str, Any]:
|
|
10
|
+
"""Convert parameters for update_prediction_set_data_info GraphQL mutation.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
dataset_id (str): The dataset ID
|
|
14
|
+
id (str): The prediction set ID to update
|
|
15
|
+
annotation_count (int): Number of annotations
|
|
16
|
+
data_count (int): Number of data items
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Dict[str, Any]: Parameters formatted for GraphQL mutation
|
|
20
|
+
"""
|
|
21
|
+
return {
|
|
22
|
+
"datasetId": dataset_id,
|
|
23
|
+
"updatePredictionSetId": id,
|
|
24
|
+
"dataInfo": {
|
|
25
|
+
"annotationsCount": annotation_count,
|
|
26
|
+
"dataCount": data_count,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from .params import (
|
|
2
|
+
get_prediction_sets_params,
|
|
3
|
+
get_prediction_set_params,
|
|
4
|
+
delete_prediction_set_params,
|
|
5
|
+
delete_prediction_from_data_params,
|
|
6
|
+
create_prediction_set_params,
|
|
7
|
+
update_prediction_set_data_info_params,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Queries:
|
|
12
|
+
GET_PREDICTION_SETS = {
|
|
13
|
+
"name": "getPredictionSets",
|
|
14
|
+
"query": '''
|
|
15
|
+
query GetPredictionSets($dataset_id: String!, $filter: PredictionSetFilter, $cursor: String, $length: Int) {
|
|
16
|
+
predictionSets(datasetId: $dataset_id, filter: $filter, cursor: $cursor, length: $length) {
|
|
17
|
+
predictionSets {
|
|
18
|
+
id
|
|
19
|
+
name
|
|
20
|
+
}
|
|
21
|
+
next
|
|
22
|
+
totalCount
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
''',
|
|
26
|
+
"variables": get_prediction_sets_params
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
GET_PREDICTION_SET = {
|
|
30
|
+
"name": "getPredictionSet",
|
|
31
|
+
"query": '''
|
|
32
|
+
query GetPredictionSet($dataset_id: String!, $id: String!) {
|
|
33
|
+
predictionSet(datasetId: $dataset_id, id: $id) {
|
|
34
|
+
id
|
|
35
|
+
name
|
|
36
|
+
annotationsContents
|
|
37
|
+
evaluationResultContent {
|
|
38
|
+
id
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
''',
|
|
43
|
+
"variables": get_prediction_set_params
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
DELETE_PREDICTION_SET = {
|
|
47
|
+
"name": "deletePredictionSet",
|
|
48
|
+
"query": '''
|
|
49
|
+
mutation DeletePredictionSet($dataset_id: String!, $id: String!) {
|
|
50
|
+
deletePredictionSet(datasetId: $dataset_id, id: $id)
|
|
51
|
+
}
|
|
52
|
+
''',
|
|
53
|
+
"variables": delete_prediction_set_params
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
DELETE_PREDICTION_FROM_DATA = {
|
|
57
|
+
"name": "deletePredictionFromData",
|
|
58
|
+
"query": '''
|
|
59
|
+
mutation DeletePrediction($dataset_id: String!, $data_id: String!, $set_id: String!) {
|
|
60
|
+
deletePrediction(datasetId: $dataset_id, dataId: $data_id, setId: $set_id)
|
|
61
|
+
}
|
|
62
|
+
''',
|
|
63
|
+
"variables": delete_prediction_from_data_params
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
CREATE_PREDICTION_SET = {
|
|
67
|
+
"name": "createPredictionSet",
|
|
68
|
+
"query": '''
|
|
69
|
+
mutation CreatePredictionSet(
|
|
70
|
+
$datasetId: ID!,
|
|
71
|
+
$modelId: ID!,
|
|
72
|
+
$name: String!,
|
|
73
|
+
$description: String,
|
|
74
|
+
$type: PredictionSetTypes!,
|
|
75
|
+
$dataInfo: PredictionSetDataInfoInput
|
|
76
|
+
) {
|
|
77
|
+
createPredictionSet(
|
|
78
|
+
datasetId: $datasetId,
|
|
79
|
+
modelId: $modelId,
|
|
80
|
+
name: $name,
|
|
81
|
+
description: $description,
|
|
82
|
+
type: $type,
|
|
83
|
+
dataInfo: $dataInfo
|
|
84
|
+
) {
|
|
85
|
+
id
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
''',
|
|
89
|
+
"variables": create_prediction_set_params
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
UPDATE_PREDICTION_SET_DATA_INFO = {
|
|
93
|
+
"name": "updatePredictionSet",
|
|
94
|
+
"query": '''
|
|
95
|
+
mutation UpdatePredictionSet(
|
|
96
|
+
$datasetId: ID!,
|
|
97
|
+
$updatePredictionSetId: ID!,
|
|
98
|
+
$dataInfo: PredictionSetDataInfoInput
|
|
99
|
+
) {
|
|
100
|
+
updatePredictionSet(
|
|
101
|
+
datasetId: $datasetId,
|
|
102
|
+
id: $updatePredictionSetId,
|
|
103
|
+
dataInfo: $dataInfo
|
|
104
|
+
) {
|
|
105
|
+
id
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
''',
|
|
109
|
+
"variables": update_prediction_set_data_info_params
|
|
110
|
+
}
|