layernext-beta 2.2.1b7__tar.gz → 2.2.1b8__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.
- {layernext-beta-2.2.1b7/layernext_beta.egg-info → layernext-beta-2.2.1b8}/PKG-INFO +1 -6
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/__init__.py +61 -10
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/automatic_analysis/__init__.py +28 -14
- layernext-beta-2.2.1b8/layernext/automatic_analysis/automatic_analysis.py +84 -0
- layernext-beta-2.2.1b8/layernext/automatic_analysis/automatic_analysis_interface.py +155 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/__init__.py +1 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/constants.py +5 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8/layernext_beta.egg-info}/PKG-INFO +1 -6
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/SOURCES.txt +1 -4
- layernext-beta-2.2.1b7/layernext/automatic_analysis/automatic_analysis_interface.py +0 -213
- layernext-beta-2.2.1b7/layernext/automatic_analysis/status_check_autotag_collection.py +0 -218
- layernext-beta-2.2.1b7/layernext/automatic_analysis/status_check_autotag_population.py +0 -201
- layernext-beta-2.2.1b7/layernext/automatic_analysis/status_check_embedding_collection.py +0 -214
- layernext-beta-2.2.1b7/layernext/automatic_analysis/status_check_embedding_population.py +0 -142
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/LICENSE +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/README.md +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/automatic_analysis/status_check_autoannotate_project.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/automatic_analysis/support.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/annotation.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/aws_s3_client.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/azure_client.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/datalakeinterface.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/dataset.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/file_trash.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/file_upload.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/gcs_client.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/ground_truth.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/keys.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/label.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/logger.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/metadata.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/model_run.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/query.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/storage_client.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/storage_interface.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/datalake/storage_upload.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/dataset/__init__.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/dataset/dataset.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/dataset/datasetinterface.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/dataset/logger.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/dataset/sync.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/studio/__init__.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/studio/logger.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/studio/project.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext/studio/studiointerface.py +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/dependency_links.txt +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/requires.txt +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/top_level.txt +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/setup.cfg +0 -0
- {layernext-beta-2.2.1b7 → layernext-beta-2.2.1b8}/setup.py +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: layernext-beta
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1b8
|
|
4
4
|
Summary: LayerNext Python SDK
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
5
|
Author: LayerNext
|
|
7
6
|
Author-email: <support@layernext.ai>
|
|
8
|
-
License: UNKNOWN
|
|
9
7
|
Keywords: python,datalake,datasetsync,ai,annotation,layernext,layernext,machine learning
|
|
10
|
-
Platform: UNKNOWN
|
|
11
8
|
Classifier: Development Status :: 1 - Planning
|
|
12
9
|
Classifier: Intended Audience :: Developers
|
|
13
10
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -40,5 +37,3 @@ url = 'https://api.xxxx.layernext.ai'
|
|
|
40
37
|
client = layernext.LayerNextClient(api_key, secret, url)
|
|
41
38
|
|
|
42
39
|
```
|
|
43
|
-
|
|
44
|
-
|
|
@@ -8,7 +8,7 @@ from layernext.datalake.constants import (AnnotationUploadType, ItemType, JobSta
|
|
|
8
8
|
SortFieldName, SortOrder, AnnotationShapeType)
|
|
9
9
|
from deprecated import deprecated
|
|
10
10
|
|
|
11
|
-
__version__ = '2.2.
|
|
11
|
+
__version__ = '2.2.1b8'
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class LayerNextClient:
|
|
@@ -2045,10 +2045,23 @@ class LayerNextClient:
|
|
|
2045
2045
|
confidence_threshold=0.5
|
|
2046
2046
|
):
|
|
2047
2047
|
|
|
2048
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2049
|
+
job_name = f"Auto-tagging-generate-{model_id}"
|
|
2050
|
+
|
|
2051
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_AUTO_TAGGING.value, 0, JobStatus.QUEUED.value)
|
|
2052
|
+
|
|
2053
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2054
|
+
job_id = res_obj["jobId"]
|
|
2055
|
+
else:
|
|
2056
|
+
print("Error occurred while create job")
|
|
2057
|
+
raise Exception("Error occurred while create job")
|
|
2058
|
+
|
|
2048
2059
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2049
2060
|
self.encoded_key_secret, self.layernext_url)
|
|
2050
|
-
_automatic_analysis_client.model_tag_collection(
|
|
2051
|
-
collection_id, model_id, input_resolution,confidence_threshold)
|
|
2061
|
+
res = _automatic_analysis_client.model_tag_collection(
|
|
2062
|
+
collection_id, model_id, input_resolution,confidence_threshold,session_id,job_id,job_name)
|
|
2063
|
+
|
|
2064
|
+
return res
|
|
2052
2065
|
|
|
2053
2066
|
|
|
2054
2067
|
"""
|
|
@@ -2066,10 +2079,23 @@ class LayerNextClient:
|
|
|
2066
2079
|
confidence_threshold=0.5
|
|
2067
2080
|
):
|
|
2068
2081
|
|
|
2082
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2083
|
+
job_name = f"Auto-tagging-generate-{model_id}"
|
|
2084
|
+
|
|
2085
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_AUTO_TAGGING.value, 0, JobStatus.QUEUED.value)
|
|
2086
|
+
|
|
2087
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2088
|
+
job_id = res_obj["jobId"]
|
|
2089
|
+
else:
|
|
2090
|
+
print("Error occurred while create job")
|
|
2091
|
+
raise Exception("Error occurred while create job")
|
|
2092
|
+
|
|
2069
2093
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2070
2094
|
self.encoded_key_secret, self.layernext_url)
|
|
2071
|
-
_automatic_analysis_client.model_tag_population(
|
|
2072
|
-
item_type, model_id, input_resolution, confidence_threshold)
|
|
2095
|
+
res = _automatic_analysis_client.model_tag_population(
|
|
2096
|
+
item_type, model_id, input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
2097
|
+
|
|
2098
|
+
return res
|
|
2073
2099
|
|
|
2074
2100
|
|
|
2075
2101
|
"""
|
|
@@ -2126,10 +2152,22 @@ class LayerNextClient:
|
|
|
2126
2152
|
filters={}
|
|
2127
2153
|
):
|
|
2128
2154
|
|
|
2155
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2156
|
+
job_name = f"Embedding-generate-{model_id}"
|
|
2157
|
+
|
|
2158
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_EMBEDDING.value, 0, JobStatus.QUEUED.value)
|
|
2159
|
+
|
|
2160
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2161
|
+
job_id = res_obj["jobId"]
|
|
2162
|
+
else:
|
|
2163
|
+
print("Error occurred while create job")
|
|
2164
|
+
raise Exception("Error occurred while create job")
|
|
2165
|
+
|
|
2129
2166
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2130
2167
|
self.encoded_key_secret, self.layernext_url)
|
|
2131
|
-
_automatic_analysis_client.embedding_model_inference_collection(
|
|
2132
|
-
collection_id, model_id, query, filters)
|
|
2168
|
+
res = _automatic_analysis_client.embedding_model_inference_collection(
|
|
2169
|
+
collection_id, model_id, query, filters, session_id,job_id, job_name)
|
|
2170
|
+
return res
|
|
2133
2171
|
|
|
2134
2172
|
|
|
2135
2173
|
def generate_embeddings_to_metalake(
|
|
@@ -2140,10 +2178,23 @@ class LayerNextClient:
|
|
|
2140
2178
|
filters={}
|
|
2141
2179
|
):
|
|
2142
2180
|
|
|
2181
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2182
|
+
job_name = f"Embedding-generate-{model_id}"
|
|
2183
|
+
|
|
2184
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_EMBEDDING.value, 0, JobStatus.QUEUED.value)
|
|
2185
|
+
|
|
2186
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2187
|
+
job_id = res_obj["jobId"]
|
|
2188
|
+
else:
|
|
2189
|
+
print("Error occurred while create job")
|
|
2190
|
+
raise Exception("Error occurred while create job")
|
|
2191
|
+
|
|
2143
2192
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2144
2193
|
self.encoded_key_secret, self.layernext_url)
|
|
2145
|
-
_automatic_analysis_client.model_embedding_population(
|
|
2146
|
-
item_type, model_id, query, filters)
|
|
2194
|
+
res = _automatic_analysis_client.model_embedding_population(
|
|
2195
|
+
item_type, model_id, query, filters, session_id,job_id, job_name)
|
|
2196
|
+
|
|
2197
|
+
return res
|
|
2147
2198
|
|
|
2148
2199
|
"""
|
|
2149
2200
|
get item list from data lake
|
|
@@ -2675,7 +2726,7 @@ class LayerNextClient:
|
|
|
2675
2726
|
job_type:int,
|
|
2676
2727
|
progress:int,
|
|
2677
2728
|
status:int,
|
|
2678
|
-
job_detail:dict
|
|
2729
|
+
job_detail:dict={}
|
|
2679
2730
|
):
|
|
2680
2731
|
|
|
2681
2732
|
if(not isinstance(session_id, str) or not isinstance(job_name, str) or not isinstance(progress, (int, float)) or not isinstance(JobStatus(status), JobStatus) or not isinstance(JobType(job_type), JobType)):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from .automatic_analysis_interface import AutomaticAnalysisInterface
|
|
1
|
+
from layernext.automatic_analysis.automatic_analysis_interface import AutomaticAnalysisInterface
|
|
2
|
+
from .automatic_analysis import AutomaticAnalysis
|
|
2
3
|
from .support import make_tarfile_in_memory, validate_input_prompt, validate_input_annotation_type, validate_confidence, validate_task, validate_resolution_input
|
|
3
4
|
"""
|
|
4
5
|
Class to initiate AutomaticAnalysisClient and handle functions integrated to it
|
|
@@ -14,6 +15,7 @@ class AutomaticAnalysisClient:
|
|
|
14
15
|
_automatic_analysis_url = f'{layernext_url}/analytics'
|
|
15
16
|
self.encoded_key_secret=encoded_key_secret
|
|
16
17
|
self.layernext_url=layernext_url
|
|
18
|
+
self.automatic_analysis = AutomaticAnalysis(encoded_key_secret, _automatic_analysis_url)
|
|
17
19
|
self.automatic_analysis_interface = AutomaticAnalysisInterface(encoded_key_secret, _automatic_analysis_url)
|
|
18
20
|
|
|
19
21
|
|
|
@@ -50,15 +52,18 @@ class AutomaticAnalysisClient:
|
|
|
50
52
|
collection_id,
|
|
51
53
|
model_id,
|
|
52
54
|
input_resolution,
|
|
53
|
-
confidence_threshold
|
|
55
|
+
confidence_threshold,
|
|
56
|
+
session_id,
|
|
57
|
+
job_id,
|
|
58
|
+
job_name
|
|
54
59
|
):
|
|
55
60
|
try:
|
|
56
61
|
validate_confidence(confidence_threshold)
|
|
57
62
|
validate_resolution_input(input_resolution)
|
|
58
63
|
application='collection_autotag'
|
|
59
64
|
item_type=""
|
|
60
|
-
self.
|
|
61
|
-
application, collection_id, item_type, model_id, input_resolution, confidence_threshold)
|
|
65
|
+
self.automatic_analysis.tagger_detail_send(
|
|
66
|
+
application, collection_id, item_type, model_id, input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
62
67
|
except ValueError as e:
|
|
63
68
|
print(f"ValueError: {e}")
|
|
64
69
|
|
|
@@ -74,15 +79,18 @@ class AutomaticAnalysisClient:
|
|
|
74
79
|
item_type,
|
|
75
80
|
model_id,
|
|
76
81
|
input_resolution,
|
|
77
|
-
confidence_threshold
|
|
82
|
+
confidence_threshold,
|
|
83
|
+
session_id,
|
|
84
|
+
job_id,
|
|
85
|
+
job_name
|
|
78
86
|
):
|
|
79
87
|
try:
|
|
80
88
|
application='population_autotag'
|
|
81
89
|
collection_id=""
|
|
82
90
|
validate_confidence(confidence_threshold)
|
|
83
91
|
validate_resolution_input(input_resolution)
|
|
84
|
-
self.
|
|
85
|
-
application,collection_id,item_type,model_id,input_resolution, confidence_threshold)
|
|
92
|
+
self.automatic_analysis.tagger_detail_send(
|
|
93
|
+
application,collection_id,item_type,model_id,input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
86
94
|
except ValueError as e:
|
|
87
95
|
print(f"ValueError: {e}")
|
|
88
96
|
|
|
@@ -115,7 +123,7 @@ class AutomaticAnalysisClient:
|
|
|
115
123
|
validate_input_prompt(kwargs["prompt"])
|
|
116
124
|
if "confidence_threshold" in kwargs:
|
|
117
125
|
validate_confidence(kwargs["confidence_threshold"])
|
|
118
|
-
self.
|
|
126
|
+
self.automatic_analysis.annotater_detail_send(
|
|
119
127
|
application,project_id,model_id, annotation_type, **kwargs)
|
|
120
128
|
except ValueError as e:
|
|
121
129
|
print(f"ValueError: {e}")
|
|
@@ -144,24 +152,30 @@ class AutomaticAnalysisClient:
|
|
|
144
152
|
collection_id,
|
|
145
153
|
model_id,
|
|
146
154
|
query,
|
|
147
|
-
filters
|
|
155
|
+
filters,
|
|
156
|
+
session_id,
|
|
157
|
+
job_id,
|
|
158
|
+
job_name):
|
|
148
159
|
|
|
149
160
|
application ='collection_embedding'
|
|
150
161
|
item_type=""
|
|
151
|
-
self.
|
|
152
|
-
collection_id, model_id, application,item_type, query, filters)
|
|
162
|
+
return self.automatic_analysis.embedding_detail_send(
|
|
163
|
+
collection_id, model_id, application,item_type, query, filters, session_id,job_id,job_name)
|
|
153
164
|
|
|
154
165
|
def model_embedding_population(
|
|
155
166
|
self,
|
|
156
167
|
item_type,
|
|
157
168
|
model_id,
|
|
158
169
|
query,
|
|
159
|
-
filters
|
|
170
|
+
filters,
|
|
171
|
+
session_id,
|
|
172
|
+
job_id,
|
|
173
|
+
job_name
|
|
160
174
|
):
|
|
161
175
|
try:
|
|
162
176
|
application='population_embedding'
|
|
163
177
|
collection_id=""
|
|
164
|
-
self.
|
|
165
|
-
collection_id, model_id, application,item_type, query, filters)
|
|
178
|
+
return self.automatic_analysis.embedding_detail_send(
|
|
179
|
+
collection_id, model_id, application,item_type, query, filters, session_id, job_id, job_name)
|
|
166
180
|
except ValueError as e:
|
|
167
181
|
print(f"ValueError: {e}")
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
import traceback
|
|
4
|
+
|
|
5
|
+
from layernext.datalake.constants import Task
|
|
6
|
+
from .support import generate_unique_id
|
|
7
|
+
from .status_check_autoannotate_project import main_annotation
|
|
8
|
+
from .automatic_analysis_interface import AutomaticAnalysisInterface
|
|
9
|
+
"""
|
|
10
|
+
Class to initiate AutomaticAnalysisClientInterface(class which handles all the API request and responses reagrding to automatic analysis) and handle functions integrated to it
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AutomaticAnalysis:
|
|
15
|
+
|
|
16
|
+
def __init__(self, auth_token: str, automatic_analysis_url: str):
|
|
17
|
+
self.auth_token = auth_token
|
|
18
|
+
self.automatic_analysis_url = automatic_analysis_url
|
|
19
|
+
self.automatic_analysis_interface = AutomaticAnalysisInterface(auth_token, automatic_analysis_url)
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
Making the payload and sending it to the given API endpoint in and handle responses in regarding to autotagging
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def tagger_detail_send(self, application, collection_id, item_type, model_id, input_resolution,confidence_threshold,session_id,job_id,job_name):
|
|
26
|
+
task = Task.AUTO_TAGGING.value
|
|
27
|
+
unique_id = generate_unique_id()
|
|
28
|
+
payload = {
|
|
29
|
+
"Application":application,
|
|
30
|
+
"ItemType":item_type,
|
|
31
|
+
"collectionId":collection_id,
|
|
32
|
+
"ModelID":model_id,
|
|
33
|
+
"UniqueID":unique_id,
|
|
34
|
+
"InputResolution":input_resolution,
|
|
35
|
+
"Confidence" : confidence_threshold,
|
|
36
|
+
"Task" : task,
|
|
37
|
+
"SessionId":session_id,
|
|
38
|
+
"JobName":job_name
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
response = self.automatic_analysis_interface.main_analysis(payload,job_id,task)
|
|
42
|
+
return response
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def annotater_detail_send(self,application,project_id,model_id, annotation_type, **kwargs):
|
|
46
|
+
task=Task.AUTO_ANNOTATION.value
|
|
47
|
+
unique_id = generate_unique_id()
|
|
48
|
+
auto_annotation_op = kwargs["auto_annotation_operation"] if "auto_annotation_operation" in kwargs else "user-model"
|
|
49
|
+
payload = {
|
|
50
|
+
"Application":application,
|
|
51
|
+
"ProjectID":project_id,
|
|
52
|
+
"ModelID":model_id,
|
|
53
|
+
"UniqueID":unique_id,
|
|
54
|
+
"Prompt": kwargs["prompt"] if "prompt" in kwargs else [],
|
|
55
|
+
"AnnotationType": annotation_type,
|
|
56
|
+
"Confidence" : kwargs["confidence_threshold"] if "confidence_threshold" in kwargs else 0.5,
|
|
57
|
+
"Autoannotation_op" : auto_annotation_op,
|
|
58
|
+
"Labels" : kwargs["labels"] if "labels" in kwargs else {},
|
|
59
|
+
"Task" : task
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
response = self.automatic_analysis_interface.main_analysis(payload,"",task)
|
|
63
|
+
return response
|
|
64
|
+
|
|
65
|
+
def embedding_detail_send(self, collection_id, model_id, application,item_type, query, filters, session_id, job_id, job_name):
|
|
66
|
+
|
|
67
|
+
task=Task.EMBEDDING.value
|
|
68
|
+
unique_id = generate_unique_id()
|
|
69
|
+
payload = {
|
|
70
|
+
"collectionId": collection_id,
|
|
71
|
+
"ModelID": model_id,
|
|
72
|
+
"UniqueID": unique_id,
|
|
73
|
+
"Task" : task,
|
|
74
|
+
"Application" : application,
|
|
75
|
+
"ItemType":item_type,
|
|
76
|
+
"Query":query,
|
|
77
|
+
"Filters":filters,
|
|
78
|
+
"SessionId":session_id,
|
|
79
|
+
"JobName":job_name
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
response = self.automatic_analysis_interface.main_analysis(payload,job_id,task)
|
|
83
|
+
return response
|
|
84
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
import requests
|
|
3
|
+
import time
|
|
4
|
+
import threading
|
|
5
|
+
from urllib.parse import quote_plus
|
|
6
|
+
from tqdm import tqdm
|
|
7
|
+
|
|
8
|
+
from layernext.datalake.constants import Task
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AutomaticAnalysisInterface:
|
|
12
|
+
def __init__(self, auth_token: str, automatic_analysis_url: str):
|
|
13
|
+
self.auth_token = auth_token
|
|
14
|
+
self.automatic_analysis_url = automatic_analysis_url
|
|
15
|
+
self.insufficient_load = False
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
Sending the main request to invokde flask app endpoint and start autotagging on the server side.
|
|
19
|
+
@param url:url which the request is sent : {self.automatic_analysis_url} in automatic_analysis_interface.py
|
|
20
|
+
@param payload:payload of the request sent
|
|
21
|
+
@param headers: headers of the reqeust sent
|
|
22
|
+
"""
|
|
23
|
+
def send_request(self,url, payload, headers, task):
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
self.insufficient_load = False
|
|
27
|
+
if task==Task.EMBEDDING.value:
|
|
28
|
+
response = requests.post(url=f"{url}/dataIn_embedding", json=payload, headers=headers, timeout=30)
|
|
29
|
+
elif task==Task.AUTO_TAGGING.value:
|
|
30
|
+
response = requests.post(url=f"{url}/dataIn", json=payload, headers=headers, timeout=30)
|
|
31
|
+
elif task==Task.AUTO_ANNOTATION.value:
|
|
32
|
+
response = requests.post(url=f"{url}/dataIn_annotation", json=payload, headers=headers, timeout=30)
|
|
33
|
+
status_code = response.status_code
|
|
34
|
+
if status_code == 200:
|
|
35
|
+
pass
|
|
36
|
+
""" Okay to proceed """
|
|
37
|
+
elif status_code == 204:
|
|
38
|
+
print(f"No content return from this API call")
|
|
39
|
+
elif status_code == 401:
|
|
40
|
+
error_obj= response.json()
|
|
41
|
+
error = error_obj.get("error")
|
|
42
|
+
message = error_obj.get("message")
|
|
43
|
+
print(f"Error: {format(error)}")
|
|
44
|
+
print(message)
|
|
45
|
+
else:
|
|
46
|
+
print(f"Error occur with status code: {status_code}")
|
|
47
|
+
#Handle connection error
|
|
48
|
+
except requests.exceptions.ConnectionError as e:
|
|
49
|
+
print(f"Error: {format(e)}")
|
|
50
|
+
print(f"Failed to connect with Meta Lake Flask app")
|
|
51
|
+
#Handle timeout error
|
|
52
|
+
except requests.exceptions.Timeout as e:
|
|
53
|
+
# print(f"Error: {format(e)}")
|
|
54
|
+
print("Timeout error from Meta Lake Flask connection")
|
|
55
|
+
pass
|
|
56
|
+
#Handle HTTP errors
|
|
57
|
+
except requests.exceptions.HTTPError as e:
|
|
58
|
+
print(f"Error: {format(e)}")
|
|
59
|
+
print("HTTP error from Meta Lake Flask connection")
|
|
60
|
+
except requests.exceptions.RequestException as e:
|
|
61
|
+
print(f"An unexpected request exception occurred: {format(e)}")
|
|
62
|
+
except Exception as e1:
|
|
63
|
+
print(f"An unexpected exception occurred: {format(e1)}")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
combining about two processes as two threads to run them parallely
|
|
68
|
+
@param url:url which the request is sent : {self.automatic_analysis_url} in automatic_analysis_interface.py
|
|
69
|
+
@param payload:payload of the request sent
|
|
70
|
+
@param headers: headers of the reqeust sent
|
|
71
|
+
@param unique_id: a unique id generated to identify which autotagging process to refer.
|
|
72
|
+
"""
|
|
73
|
+
def main_analysis(self, payload, job_id, task):
|
|
74
|
+
url = f'{self.automatic_analysis_url}'
|
|
75
|
+
headers = {'Authorization': 'Basic ' + self.auth_token}
|
|
76
|
+
request_thread = threading.Thread(target=self.send_request, args=(url, payload, headers, task))
|
|
77
|
+
request_thread.start()
|
|
78
|
+
|
|
79
|
+
return {"jobId": job_id}
|
|
80
|
+
|
|
81
|
+
def inference_model_upload(self, storage_url, bucket_name, object_key, model_id, label_list, model_name, task):
|
|
82
|
+
|
|
83
|
+
hed = {'Authorization': 'Basic ' + self.auth_token}
|
|
84
|
+
payload = {
|
|
85
|
+
"storage_url": storage_url,
|
|
86
|
+
"bucket_name": bucket_name,
|
|
87
|
+
"object_key": object_key,
|
|
88
|
+
"model_ID": model_id,
|
|
89
|
+
"model_name": model_name,
|
|
90
|
+
"label_list": label_list,
|
|
91
|
+
"task": task
|
|
92
|
+
}
|
|
93
|
+
url = f'{self.automatic_analysis_url}/model_setup'
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
response = requests.post(url=url, json=payload, headers=hed)
|
|
97
|
+
status_code = response.status_code
|
|
98
|
+
if status_code == 200:
|
|
99
|
+
print(response.json())
|
|
100
|
+
""" Okay to proceed """
|
|
101
|
+
elif status_code == 204:
|
|
102
|
+
print(f"No content return from this API call")
|
|
103
|
+
elif status_code == 401:
|
|
104
|
+
error_obj= response.json()
|
|
105
|
+
error = error_obj.get("error")
|
|
106
|
+
message = error_obj.get("message")
|
|
107
|
+
print(f"Error: {format(error)}")
|
|
108
|
+
print(message)
|
|
109
|
+
else:
|
|
110
|
+
print(f"Error occur with status code: {status_code}")
|
|
111
|
+
#Handle connection error
|
|
112
|
+
except requests.exceptions.ConnectionError as e:
|
|
113
|
+
print(f"Error: {format(e)}")
|
|
114
|
+
print(f"Failed to connect with Meta Lake Flask app")
|
|
115
|
+
#Handle timeout error
|
|
116
|
+
except requests.exceptions.Timeout as e:
|
|
117
|
+
# print(f"Error: {format(e)}")
|
|
118
|
+
print("Timeout error from Meta Lake Flask connection")
|
|
119
|
+
#Handle HTTP errors
|
|
120
|
+
except requests.exceptions.HTTPError as e:
|
|
121
|
+
print(f"Error: {format(e)}")
|
|
122
|
+
print("HTTP error from Meta Lake Flask connection")
|
|
123
|
+
except requests.exceptions.RequestException as e:
|
|
124
|
+
print(f"An unexpected request exception occurred: {format(e)}")
|
|
125
|
+
except Exception as e1:
|
|
126
|
+
print(f"An unexpected exception occurred: {format(e1)}")
|
|
127
|
+
|
|
128
|
+
def prompt_detail_send(self, name, shape, **kwargs):
|
|
129
|
+
hed = {'Authorization': 'Basic ' + self.auth_token}
|
|
130
|
+
payload = {
|
|
131
|
+
"bbox": kwargs["bbox"] if "bbox" in kwargs else {},
|
|
132
|
+
"clicks": kwargs["clicks"] if "clicks" in kwargs else [],
|
|
133
|
+
"shape" : shape,
|
|
134
|
+
"uniqueName" : name
|
|
135
|
+
}
|
|
136
|
+
url = f'{self.automatic_analysis_url}'
|
|
137
|
+
try:
|
|
138
|
+
response = requests.post(url=f'{url}/dataIn_prompt_infer', json=payload, headers=hed)
|
|
139
|
+
# main_annotation(url,payload,hed,unique_id,task, auto_annotation_op)
|
|
140
|
+
#print(response.json())
|
|
141
|
+
#Handle connection error
|
|
142
|
+
except requests.exceptions.ConnectionError as e:
|
|
143
|
+
print("Failed to connect with Automatic Analysis application")
|
|
144
|
+
# Handle timeout error
|
|
145
|
+
except requests.exceptions.Timeout as e:
|
|
146
|
+
print("Timeout error from Data Lake connection")
|
|
147
|
+
# Handle HTTP errors
|
|
148
|
+
except requests.exceptions.HTTPError as e:
|
|
149
|
+
print("HTTP error from Data Lake connection")
|
|
150
|
+
except requests.exceptions.RequestException as e:
|
|
151
|
+
print(f"An unexpected request exception occurred: {format(e)}")
|
|
152
|
+
traceback.print_exc()
|
|
153
|
+
except Exception as e1:
|
|
154
|
+
print(f"An unexpected exception occurred: {format(e1)}")
|
|
155
|
+
traceback.print_exc()
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: layernext-beta
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1b8
|
|
4
4
|
Summary: LayerNext Python SDK
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
5
|
Author: LayerNext
|
|
7
6
|
Author-email: <support@layernext.ai>
|
|
8
|
-
License: UNKNOWN
|
|
9
7
|
Keywords: python,datalake,datasetsync,ai,annotation,layernext,layernext,machine learning
|
|
10
|
-
Platform: UNKNOWN
|
|
11
8
|
Classifier: Development Status :: 1 - Planning
|
|
12
9
|
Classifier: Intended Audience :: Developers
|
|
13
10
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -40,5 +37,3 @@ url = 'https://api.xxxx.layernext.ai'
|
|
|
40
37
|
client = layernext.LayerNextClient(api_key, secret, url)
|
|
41
38
|
|
|
42
39
|
```
|
|
43
|
-
|
|
44
|
-
|
|
@@ -3,12 +3,9 @@ README.md
|
|
|
3
3
|
setup.py
|
|
4
4
|
layernext/__init__.py
|
|
5
5
|
layernext/automatic_analysis/__init__.py
|
|
6
|
+
layernext/automatic_analysis/automatic_analysis.py
|
|
6
7
|
layernext/automatic_analysis/automatic_analysis_interface.py
|
|
7
8
|
layernext/automatic_analysis/status_check_autoannotate_project.py
|
|
8
|
-
layernext/automatic_analysis/status_check_autotag_collection.py
|
|
9
|
-
layernext/automatic_analysis/status_check_autotag_population.py
|
|
10
|
-
layernext/automatic_analysis/status_check_embedding_collection.py
|
|
11
|
-
layernext/automatic_analysis/status_check_embedding_population.py
|
|
12
9
|
layernext/automatic_analysis/support.py
|
|
13
10
|
layernext/datalake/__init__.py
|
|
14
11
|
layernext/datalake/annotation.py
|