anatools 6.0.1__py3-none-any.whl → 6.0.3__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.
- anatools/__init__.py +1 -1
- anatools/anaclient/api/graphs.py +8 -1
- anatools/anaclient/api/preview.py +24 -3
- anatools/anaclient/api/services.py +12 -4
- anatools/anaclient/api/workspaces.py +7 -1
- anatools/anaclient/preview.py +26 -4
- anatools/anaclient/volumes.py +20 -13
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anadeploy +1 -1
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anarules +6 -4
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/renderedai +462 -68
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/METADATA +2 -2
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/RECORD +22 -22
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/ana +0 -0
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anamount +0 -0
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anaprofile +0 -0
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anaserver +0 -0
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anatransfer +0 -0
- {anatools-6.0.1.data → anatools-6.0.3.data}/scripts/anautils +0 -0
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/WHEEL +0 -0
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/entry_points.txt +0 -0
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/licenses/LICENSE +0 -0
- {anatools-6.0.1.dist-info → anatools-6.0.3.dist-info}/top_level.txt +0 -0
anatools/__init__.py
CHANGED
anatools/anaclient/api/graphs.py
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
Graphs API calls.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
GRAPH_DEFAULT_FIELDS = [
|
|
6
|
+
"graphId", "workspaceId", "name", "description",
|
|
7
|
+
"channel", "channelId", "readOnly", "showPreview", "previewId",
|
|
8
|
+
"createdBy", "createdAt", "updatedBy", "updatedAt",
|
|
9
|
+
"hash", "tags",
|
|
10
|
+
]
|
|
11
|
+
|
|
5
12
|
def getGraphs(self, workspaceId, graphId=None, name=None, email=None, staged=True, limit=100, cursor=None, filters={}, fields=None):
|
|
6
|
-
if fields is None: fields =
|
|
13
|
+
if fields is None: fields = GRAPH_DEFAULT_FIELDS
|
|
7
14
|
fields = "\n".join(fields)
|
|
8
15
|
if filters is None: filters = {}
|
|
9
16
|
response = self.session.post(
|
|
@@ -25,17 +25,38 @@ def getPreview(self, workspaceId, previewId, fields=None):
|
|
|
25
25
|
|
|
26
26
|
def createPreview(self, workspaceId, graphId):
|
|
27
27
|
response = self.session.post(
|
|
28
|
-
url = self.url,
|
|
29
|
-
headers = self.headers,
|
|
28
|
+
url = self.url,
|
|
29
|
+
headers = self.headers,
|
|
30
30
|
json = {
|
|
31
31
|
"operationName": "createPreview",
|
|
32
32
|
"variables": {
|
|
33
33
|
"workspaceId": workspaceId,
|
|
34
34
|
"graphId": graphId
|
|
35
35
|
},
|
|
36
|
-
"query": """mutation
|
|
36
|
+
"query": """mutation
|
|
37
37
|
createPreview($workspaceId: String!, $graphId: String!) {
|
|
38
38
|
createPreview(workspaceId: $workspaceId, graphId: $graphId)
|
|
39
39
|
}"""})
|
|
40
40
|
return self.errorhandler(response, "createPreview")
|
|
41
41
|
|
|
42
|
+
|
|
43
|
+
def getPreviewLog(self, workspaceId, previewId, fields=None):
|
|
44
|
+
if fields is None: fields = self.getTypeFields("PreviewLog")
|
|
45
|
+
fields = "\n".join(fields)
|
|
46
|
+
response = self.session.post(
|
|
47
|
+
url = self.url,
|
|
48
|
+
headers = self.headers,
|
|
49
|
+
json = {
|
|
50
|
+
"operationName": "getPreviewLog",
|
|
51
|
+
"variables": {
|
|
52
|
+
"workspaceId": workspaceId,
|
|
53
|
+
"previewId": previewId
|
|
54
|
+
},
|
|
55
|
+
"query": f"""query
|
|
56
|
+
getPreviewLog($workspaceId: String!, $previewId: String!) {{
|
|
57
|
+
getPreviewLog(workspaceId: $workspaceId, previewId: $previewId) {{
|
|
58
|
+
{fields}
|
|
59
|
+
}}
|
|
60
|
+
}}"""})
|
|
61
|
+
return self.errorhandler(response, "getPreviewLog")
|
|
62
|
+
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
Services API calls.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
SERVICE_DEFAULT_FIELDS = [
|
|
6
|
+
"serviceId", "name", "sanitizedName", "description", "type",
|
|
7
|
+
"volumes", "instance", "version", "state", "tags",
|
|
8
|
+
"organizationId", "organization", "serviceType",
|
|
9
|
+
"persistentServiceId", "parentServiceId", "url",
|
|
10
|
+
"createdAt", "updatedAt", "createdBy", "updatedBy",
|
|
11
|
+
]
|
|
12
|
+
|
|
5
13
|
def getServiceTypes(self, fields=None):
|
|
6
14
|
if fields is None: fields = self.getTypeFields("ServiceType")
|
|
7
15
|
fields = "\n".join(fields)
|
|
8
16
|
response = self.session.post(
|
|
9
|
-
url = self.url,
|
|
10
|
-
headers = self.headers,
|
|
17
|
+
url = self.url,
|
|
18
|
+
headers = self.headers,
|
|
11
19
|
json = {
|
|
12
20
|
"operationName": "getServiceTypes",
|
|
13
21
|
"variables": {},
|
|
14
|
-
"query": F"""query
|
|
22
|
+
"query": F"""query
|
|
15
23
|
getServiceTypes {{
|
|
16
24
|
getServiceTypes {{
|
|
17
25
|
{fields}
|
|
@@ -21,7 +29,7 @@ def getServiceTypes(self, fields=None):
|
|
|
21
29
|
|
|
22
30
|
|
|
23
31
|
def getServices(self, organizationId=None, workspaceId=None, serviceId=None, limit=100, cursor=None, filters={}, fields=None):
|
|
24
|
-
if fields is None: fields =
|
|
32
|
+
if fields is None: fields = SERVICE_DEFAULT_FIELDS
|
|
25
33
|
fields = "\n".join(fields)
|
|
26
34
|
if filters is None: filters = {}
|
|
27
35
|
response = self.session.post(
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
Workspaces API calls.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
WORKSPACE_DEFAULT_FIELDS = [
|
|
6
|
+
"workspaceId", "name", "description", "objective",
|
|
7
|
+
"organizationId", "organization", "status", "tags",
|
|
8
|
+
"createdAt", "createdBy", "updatedAt", "updatedBy",
|
|
9
|
+
]
|
|
10
|
+
|
|
5
11
|
def getWorkspaces(self, organizationId=None, workspaceId=None, cursor=None, limit=100, filters={}, fields=None):
|
|
6
|
-
if fields is None: fields =
|
|
12
|
+
if fields is None: fields = WORKSPACE_DEFAULT_FIELDS
|
|
7
13
|
fields = "\n".join(fields)
|
|
8
14
|
if filters is None: filters = {}
|
|
9
15
|
response = self.session.post(
|
anatools/anaclient/preview.py
CHANGED
|
@@ -27,14 +27,14 @@ def get_preview(self, previewId, workspaceId=None, fields=None):
|
|
|
27
27
|
|
|
28
28
|
def create_preview(self, graphId, workspaceId=None):
|
|
29
29
|
"""Creates a preview job.
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
Parameters
|
|
32
32
|
----------
|
|
33
33
|
graphId: str
|
|
34
34
|
The unique identifier for the graph.
|
|
35
|
-
workspaceId : str
|
|
36
|
-
Workspace ID create the preview in. If none is provided, the default workspace will get used.
|
|
37
|
-
|
|
35
|
+
workspaceId : str
|
|
36
|
+
Workspace ID create the preview in. If none is provided, the default workspace will get used.
|
|
37
|
+
|
|
38
38
|
Returns
|
|
39
39
|
-------
|
|
40
40
|
str
|
|
@@ -43,4 +43,26 @@ def create_preview(self, graphId, workspaceId=None):
|
|
|
43
43
|
if self.check_logout(): return
|
|
44
44
|
if workspaceId is None: workspaceId = self.workspace
|
|
45
45
|
return self.ana_api.createPreview(workspaceId=workspaceId, graphId=graphId)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_preview_log(self, previewId, workspaceId=None, fields=None):
|
|
49
|
+
"""Fetches the logs for a preview job.
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
previewId : str
|
|
54
|
+
The unique identifier for the preview job.
|
|
55
|
+
workspaceId : str
|
|
56
|
+
Workspace the preview job was run in. If none is provided, the default workspace will get used.
|
|
57
|
+
fields : list
|
|
58
|
+
List of fields to return, leave empty to get all fields.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
dict
|
|
63
|
+
Preview log information containing previewId, status, and logs.
|
|
64
|
+
"""
|
|
65
|
+
if self.check_logout(): return
|
|
66
|
+
if workspaceId is None: workspaceId = self.workspace
|
|
67
|
+
return self.ana_api.getPreviewLog(workspaceId=workspaceId, previewId=previewId, fields=fields)
|
|
46
68
|
|
anatools/anaclient/volumes.py
CHANGED
|
@@ -311,35 +311,42 @@ def upload_volume_data(self, volumeId, files=None, localDir=None, destinationDir
|
|
|
311
311
|
if destinationDir: destinationDir += '/'
|
|
312
312
|
|
|
313
313
|
source_files = []
|
|
314
|
+
source_paths = []
|
|
314
315
|
source_hashes = []
|
|
315
316
|
faileduploads = []
|
|
316
|
-
|
|
317
|
+
|
|
317
318
|
if len(files):
|
|
318
319
|
for file in files:
|
|
319
|
-
filepath = os.path.join(localDir, file)
|
|
320
|
+
filepath = os.path.join(localDir, file) if not os.path.isabs(file) else file
|
|
320
321
|
if os.path.isdir(filepath):
|
|
321
322
|
for root, dirs, files in os.walk(filepath):
|
|
322
323
|
for file in files:
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
local_path = os.path.join(root, file)
|
|
325
|
+
relative_name = local_path.replace(localDir, '') if local_path.startswith(localDir) else os.path.relpath(local_path, localDir)
|
|
326
|
+
source_files.append(relative_name)
|
|
327
|
+
source_paths.append(local_path)
|
|
325
328
|
if sync == True:
|
|
326
|
-
file_hash = generate_etag(
|
|
327
|
-
source_hashes.append(
|
|
329
|
+
file_hash = generate_etag(local_path)
|
|
330
|
+
source_hashes.append(relative_name + file_hash)
|
|
328
331
|
elif os.path.isfile(filepath):
|
|
329
|
-
|
|
332
|
+
upload_name = os.path.basename(file) if os.path.isabs(file) else file
|
|
333
|
+
source_files.append(upload_name)
|
|
334
|
+
source_paths.append(filepath)
|
|
330
335
|
if sync == True:
|
|
331
336
|
file_hash = generate_etag(filepath)
|
|
332
|
-
source_hashes.append(
|
|
337
|
+
source_hashes.append(upload_name + file_hash)
|
|
333
338
|
else:
|
|
334
339
|
if self.interactive: print(f"Could not find {filepath}.")
|
|
335
340
|
else:
|
|
336
341
|
for root, dirs, files in os.walk(localDir):
|
|
337
342
|
for file in files:
|
|
338
|
-
|
|
339
|
-
|
|
343
|
+
local_path = os.path.join(root, file)
|
|
344
|
+
relative_name = local_path.replace(localDir, '')
|
|
345
|
+
source_files.append(relative_name)
|
|
346
|
+
source_paths.append(local_path)
|
|
340
347
|
if sync == True:
|
|
341
|
-
file_hash = generate_etag(
|
|
342
|
-
source_hashes.append(
|
|
348
|
+
file_hash = generate_etag(local_path)
|
|
349
|
+
source_hashes.append(relative_name + file_hash)
|
|
343
350
|
|
|
344
351
|
if sync == True:
|
|
345
352
|
response = []
|
|
@@ -389,7 +396,7 @@ def upload_volume_data(self, volumeId, files=None, localDir=None, destinationDir
|
|
|
389
396
|
elif sync == False or (source_hashes[index] not in destination_hashes):
|
|
390
397
|
try:
|
|
391
398
|
self.refresh_token()
|
|
392
|
-
filepath =
|
|
399
|
+
filepath = source_paths[index]
|
|
393
400
|
filesize = os.path.getsize(filepath)
|
|
394
401
|
fileinfo = self.ana_api.uploadVolumeData(volumeId=volumeId, key=destination_key, size=filesize)
|
|
395
402
|
parts = multipart_upload_file(filepath, int(fileinfo["partSize"]), fileinfo["urls"], f"Uploading {file} to the volume [{index+1} / {len(source_files)}]", interactive=self.interactive)
|
|
@@ -523,7 +523,7 @@ try:
|
|
|
523
523
|
print(f'\033[1F\033[FRegistering Service Image...done. [{time.time()-registerstart:.3f}s]\033[K\n\033[K')
|
|
524
524
|
print_color(f"The service has been deployed and is ready to use!", color='brand')
|
|
525
525
|
print(f'Deployment Time: {time.time()-starttime:.3f}s\n')
|
|
526
|
-
client.edit_service(serviceId=remoteservice['serviceId'], schema=json.dumps(localservice.schemas))
|
|
526
|
+
client.edit_service(serviceId=remoteservice['serviceId'], description=localservice.description, schema=json.dumps(localservice.schemas))
|
|
527
527
|
|
|
528
528
|
remoteconfig = {
|
|
529
529
|
"serviceId": remoteservice['serviceId'],
|
|
@@ -107,10 +107,12 @@ if args.workspace is not None:
|
|
|
107
107
|
try:
|
|
108
108
|
schema = json.loads(service['schema'])
|
|
109
109
|
if schema and isinstance(schema, dict):
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
tools = schema.get('tools', schema.get('execs', schema))
|
|
111
|
+
if isinstance(tools, dict):
|
|
112
|
+
for tool in tools.keys():
|
|
113
|
+
description = "No description"
|
|
114
|
+
if isinstance(tools[tool], dict) and 'description' in tools[tool]: description = tools[tool]['description']
|
|
115
|
+
rules+=f"\t\t- {tool} : {description}\n"
|
|
114
116
|
except (json.JSONDecodeError, TypeError) as e:
|
|
115
117
|
if args.verbose: print(f"Warning: Failed to parse schema for service {service['name']}: {e}")
|
|
116
118
|
pass
|