octostar-python-client 0.1.759__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.
- octostar/__init__.py +9 -0
- octostar/api/__init__.py +1 -0
- octostar/api/apps/__init__.py +0 -0
- octostar/api/apps/deploy_app.py +210 -0
- octostar/api/apps/execute_app_job.py +188 -0
- octostar/api/apps/get_app_logs.py +210 -0
- octostar/api/apps/get_apps_url.py +188 -0
- octostar/api/apps/get_job_logs.py +210 -0
- octostar/api/apps/get_job_progress.py +162 -0
- octostar/api/apps/kill_job.py +160 -0
- octostar/api/apps/list_app_jobs.py +276 -0
- octostar/api/apps/list_apps.py +251 -0
- octostar/api/apps/set_job_progress.py +216 -0
- octostar/api/apps/undeploy_app.py +160 -0
- octostar/api/metadata/__init__.py +0 -0
- octostar/api/metadata/get_version.py +232 -0
- octostar/api/metadata/get_whoami.py +232 -0
- octostar/api/notifications/__init__.py +0 -0
- octostar/api/notifications/delete_stream.py +222 -0
- octostar/api/notifications/get_subscriptions.py +240 -0
- octostar/api/notifications/publish_notification.py +275 -0
- octostar/api/notifications/pull_events_from_stream.py +282 -0
- octostar/api/notifications/push_event_to_stream.py +265 -0
- octostar/api/notifications/toast.py +264 -0
- octostar/api/ontology/__init__.py +0 -0
- octostar/api/ontology/fetch_ontology_data.py +275 -0
- octostar/api/ontology/get_ontologies.py +237 -0
- octostar/api/ontology/multi_query.py +297 -0
- octostar/api/ontology/query.py +276 -0
- octostar/api/pipeline/__init__.py +1 -0
- octostar/api/pipeline/get_processing_status.py +185 -0
- octostar/api/pipeline/update_processing_status.py +164 -0
- octostar/api/search/__init__.py +0 -0
- octostar/api/search/get_annotations.py +153 -0
- octostar/api/workspace_data/__init__.py +0 -0
- octostar/api/workspace_data/delete_blob.py +212 -0
- octostar/api/workspace_data/delete_entities.py +326 -0
- octostar/api/workspace_data/download_blob.py +235 -0
- octostar/api/workspace_data/get_attachment.py +336 -0
- octostar/api/workspace_data/get_files_tree.py +397 -0
- octostar/api/workspace_data/upload_blob.py +235 -0
- octostar/api/workspace_data/upsert_entities.py +284 -0
- octostar/api/workspace_permissions/__init__.py +0 -0
- octostar/api/workspace_permissions/get_permissions.py +325 -0
- octostar/api/workspace_tags/__init__.py +0 -0
- octostar/api/workspace_tags/delete_tag_from_entities.py +141 -0
- octostar/api/workspace_tags/tag_entities.py +180 -0
- octostar/client.py +492 -0
- octostar/errors.py +50 -0
- octostar/models/__init__.py +249 -0
- octostar/models/acknowledgement.py +74 -0
- octostar/models/acknowledgement_with_data.py +82 -0
- octostar/models/app_status.py +239 -0
- octostar/models/app_status_annotations.py +66 -0
- octostar/models/app_status_labels.py +69 -0
- octostar/models/app_with_url.py +82 -0
- octostar/models/child_processing_status.py +118 -0
- octostar/models/delete_entities_response_401.py +74 -0
- octostar/models/delete_entities_response_409.py +82 -0
- octostar/models/delete_entities_response_500.py +82 -0
- octostar/models/delete_stream_response_401.py +74 -0
- octostar/models/delete_tag_from_entities_response_401.py +74 -0
- octostar/models/deploy_app_json_body.py +90 -0
- octostar/models/deploy_app_json_body_secrets.py +65 -0
- octostar/models/deploy_app_response_200.py +98 -0
- octostar/models/deploy_app_response_200_data.py +60 -0
- octostar/models/deploy_app_response_400.py +82 -0
- octostar/models/deploy_app_response_403.py +82 -0
- octostar/models/deploy_app_response_404.py +82 -0
- octostar/models/deploy_app_response_409.py +82 -0
- octostar/models/deploy_app_response_500.py +82 -0
- octostar/models/entity.py +80 -0
- octostar/models/entity_response.py +99 -0
- octostar/models/entity_response_s3_urls.py +93 -0
- octostar/models/entity_response_s3_urls_additional_property.py +105 -0
- octostar/models/entity_response_s3_urls_additional_property_fields.py +114 -0
- octostar/models/execute_app_job_json_body.py +151 -0
- octostar/models/execute_app_job_json_body_annotation.py +65 -0
- octostar/models/execute_app_job_response_401.py +74 -0
- octostar/models/fetch_ontology_data_response_200.py +60 -0
- octostar/models/fetch_ontology_data_response_401.py +74 -0
- octostar/models/fetch_ontology_data_response_500.py +82 -0
- octostar/models/get_app_logs_response_401.py +74 -0
- octostar/models/get_app_logs_response_404.py +74 -0
- octostar/models/get_app_logs_response_500.py +82 -0
- octostar/models/get_apps_url_json_body.py +76 -0
- octostar/models/get_apps_url_response_401.py +74 -0
- octostar/models/get_apps_url_response_500.py +82 -0
- octostar/models/get_attachment_response_200.py +74 -0
- octostar/models/get_attachment_response_401.py +74 -0
- octostar/models/get_files_tree_response_200.py +106 -0
- octostar/models/get_files_tree_response_200_status.py +8 -0
- octostar/models/get_files_tree_response_400.py +111 -0
- octostar/models/get_files_tree_response_400_data.py +60 -0
- octostar/models/get_files_tree_response_400_status.py +8 -0
- octostar/models/get_files_tree_response_401.py +74 -0
- octostar/models/get_files_tree_response_500.py +111 -0
- octostar/models/get_files_tree_response_500_data.py +60 -0
- octostar/models/get_files_tree_response_500_status.py +8 -0
- octostar/models/get_job_logs_response_401.py +74 -0
- octostar/models/get_job_logs_response_404.py +74 -0
- octostar/models/get_job_logs_response_500.py +82 -0
- octostar/models/get_job_progress_response_401.py +74 -0
- octostar/models/get_object_response_401.py +74 -0
- octostar/models/get_ontologies_response_401.py +74 -0
- octostar/models/get_ontologies_response_500.py +81 -0
- octostar/models/get_permissions_response_200.py +98 -0
- octostar/models/get_permissions_response_400.py +82 -0
- octostar/models/get_permissions_response_401.py +74 -0
- octostar/models/get_permissions_response_500.py +82 -0
- octostar/models/get_processing_status_response_200.py +104 -0
- octostar/models/get_processing_status_response_200_data.py +87 -0
- octostar/models/get_processing_status_response_400.py +82 -0
- octostar/models/get_processing_status_response_500.py +82 -0
- octostar/models/get_subscriptions_response_200_item.py +74 -0
- octostar/models/get_version_response_200.py +74 -0
- octostar/models/get_version_response_404.py +74 -0
- octostar/models/get_whoami_response_200.py +129 -0
- octostar/models/get_whoami_response_401.py +74 -0
- octostar/models/insert_entity.py +114 -0
- octostar/models/insert_entity_base.py +266 -0
- octostar/models/insert_entity_relationships_item.py +107 -0
- octostar/models/insert_entity_request.py +94 -0
- octostar/models/internal_server_error.py +82 -0
- octostar/models/job_execution_result.py +146 -0
- octostar/models/job_status.py +196 -0
- octostar/models/job_status_labels.py +60 -0
- octostar/models/job_with_url.py +82 -0
- octostar/models/kill_job_response_401.py +74 -0
- octostar/models/list_app_jobs_response_401.py +74 -0
- octostar/models/list_app_jobs_response_500.py +82 -0
- octostar/models/list_apps_response_401.py +74 -0
- octostar/models/list_apps_response_500.py +82 -0
- octostar/models/multi_query_json_body.py +100 -0
- octostar/models/multi_query_json_body_queries_item.py +80 -0
- octostar/models/multi_query_response_400.py +82 -0
- octostar/models/multi_query_response_401.py +74 -0
- octostar/models/not_found_error.py +74 -0
- octostar/models/octostar_event.py +96 -0
- octostar/models/octostar_event_octostar_payload.py +100 -0
- octostar/models/octostar_event_octostar_payload_level.py +11 -0
- octostar/models/os_notification.py +122 -0
- octostar/models/processing_status.py +262 -0
- octostar/models/processing_status_code.py +14 -0
- octostar/models/progress_request.py +73 -0
- octostar/models/publish_notification_response_401.py +74 -0
- octostar/models/pull_events_from_stream_response_401.py +74 -0
- octostar/models/push_event_to_stream_response_401.py +74 -0
- octostar/models/query_json_body.py +101 -0
- octostar/models/query_json_body_params.py +60 -0
- octostar/models/query_response_400.py +82 -0
- octostar/models/query_response_401.py +74 -0
- octostar/models/set_job_progress_response_401.py +74 -0
- octostar/models/string_to_value_label_map.py +99 -0
- octostar/models/string_to_value_label_map_data.py +89 -0
- octostar/models/string_to_value_label_map_data_additional_property.py +80 -0
- octostar/models/successful_get_tags.py +103 -0
- octostar/models/successful_insertion.py +98 -0
- octostar/models/tag_entities_response_401.py +74 -0
- octostar/models/toast_level.py +11 -0
- octostar/models/toast_response_401.py +74 -0
- octostar/models/undeploy_app_response_401.py +74 -0
- octostar/models/update_processing_status_response_200.py +82 -0
- octostar/models/update_processing_status_response_400.py +82 -0
- octostar/models/update_processing_status_response_500.py +82 -0
- octostar/models/upsert_entities_response_401.py +74 -0
- octostar/models/upsert_entity.py +114 -0
- octostar/models/upsert_entity_base.py +266 -0
- octostar/models/upsert_entity_relationships_item.py +107 -0
- octostar/py.typed +1 -0
- octostar/types.py +54 -0
- octostar/utils/__init__.py +15 -0
- octostar/utils/chat/__init__.py +0 -0
- octostar/utils/chat/chat.py +513 -0
- octostar/utils/chat/detokenize.py +105 -0
- octostar/utils/chat/get_default_model.py +50 -0
- octostar/utils/chat/list_models.py +91 -0
- octostar/utils/chat/tokenize.py +105 -0
- octostar/utils/commons.py +226 -0
- octostar/utils/exceptions.py +134 -0
- octostar/utils/jobs/__init__.py +0 -0
- octostar/utils/jobs/apps/__init__.py +0 -0
- octostar/utils/jobs/apps/deploy_app.py +81 -0
- octostar/utils/jobs/apps/execute_app_job.py +114 -0
- octostar/utils/jobs/apps/get_app_logs.py +113 -0
- octostar/utils/jobs/apps/get_app_secret.py +102 -0
- octostar/utils/jobs/apps/get_apps_url.py +73 -0
- octostar/utils/jobs/apps/list_app_jobs.py +62 -0
- octostar/utils/jobs/apps/list_apps.py +126 -0
- octostar/utils/jobs/apps/undeploy_app.py +48 -0
- octostar/utils/jobs/get_job_logs.py +113 -0
- octostar/utils/jobs/get_job_progress.py +76 -0
- octostar/utils/jobs/kill_job.py +47 -0
- octostar/utils/jobs/set_job_progress.py +67 -0
- octostar/utils/meta/__init__.py +0 -0
- octostar/utils/meta/get_version.py +30 -0
- octostar/utils/meta/get_whoami.py +30 -0
- octostar/utils/notifications/__init__.py +0 -0
- octostar/utils/notifications/delete_stream.py +58 -0
- octostar/utils/notifications/get_my_subscriptions.py +49 -0
- octostar/utils/notifications/publish_notification.py +73 -0
- octostar/utils/notifications/pull_event_from_stream.py +63 -0
- octostar/utils/notifications/pull_events_from_stream.py +64 -0
- octostar/utils/notifications/push_event_to_stream.py +109 -0
- octostar/utils/notifications/push_events_to_stream.py +137 -0
- octostar/utils/notifications/toast.py +92 -0
- octostar/utils/ontology/__init__.py +10 -0
- octostar/utils/ontology/fetch_ontology_data.py +141 -0
- octostar/utils/ontology/get_ontologies.py +55 -0
- octostar/utils/ontology/multiquery_ontology.py +287 -0
- octostar/utils/ontology/query_ontology.py +186 -0
- octostar/utils/pipeline/__init__.py +1 -0
- octostar/utils/pipeline/get_processing_status.py +230 -0
- octostar/utils/pipeline/update_processing_status.py +286 -0
- octostar/utils/search/__init__.py +11 -0
- octostar/utils/search/bulk_update.py +138 -0
- octostar/utils/search/count.py +117 -0
- octostar/utils/search/get_entity_annotations.py +304 -0
- octostar/utils/search/get_index_definition.py +111 -0
- octostar/utils/search/multi_search.py +129 -0
- octostar/utils/workspace/__init__.py +0 -0
- octostar/utils/workspace/delete_entities.py +247 -0
- octostar/utils/workspace/delete_entity.py +81 -0
- octostar/utils/workspace/delete_relationship.py +78 -0
- octostar/utils/workspace/delete_relationships.py +85 -0
- octostar/utils/workspace/delete_temporary_blob.py +85 -0
- octostar/utils/workspace/extract_entities.py +140 -0
- octostar/utils/workspace/get_filepath_from_item.py +85 -0
- octostar/utils/workspace/get_filepaths_from_items.py +100 -0
- octostar/utils/workspace/get_files_tree.py +102 -0
- octostar/utils/workspace/get_item_from_filepath.py +102 -0
- octostar/utils/workspace/get_items_from_filepaths.py +108 -0
- octostar/utils/workspace/linkcharts/__init__.py +0 -0
- octostar/utils/workspace/linkcharts/create_linkchart.py +241 -0
- octostar/utils/workspace/permissions/PermissionLevel.py +8 -0
- octostar/utils/workspace/permissions/__init__.py +1 -0
- octostar/utils/workspace/permissions/get_permissions.py +81 -0
- octostar/utils/workspace/read_attachment.py +284 -0
- octostar/utils/workspace/read_file.py +113 -0
- octostar/utils/workspace/read_temporary_blob.py +428 -0
- octostar/utils/workspace/saved_searches/__init__.py +0 -0
- octostar/utils/workspace/saved_searches/create_saved_search.py +183 -0
- octostar/utils/workspace/tags/__init__.py +0 -0
- octostar/utils/workspace/tags/delete_tag_from_entities.py +96 -0
- octostar/utils/workspace/tags/tag_entities.py +175 -0
- octostar/utils/workspace/upsert_entities.py +268 -0
- octostar/utils/workspace/upsert_entity.py +110 -0
- octostar/utils/workspace/upsert_relationship.py +128 -0
- octostar/utils/workspace/upsert_relationships.py +194 -0
- octostar/utils/workspace/write_attachment.py +263 -0
- octostar/utils/workspace/write_file.py +335 -0
- octostar/utils/workspace/write_temporary_blob.py +218 -0
- octostar_python_client-0.1.759.dist-info/METADATA +159 -0
- octostar_python_client-0.1.759.dist-info/RECORD +257 -0
- octostar_python_client-0.1.759.dist-info/WHEEL +5 -0
- octostar_python_client-0.1.759.dist-info/licenses/LICENSE +21 -0
- octostar_python_client-0.1.759.dist-info/top_level.txt +1 -0
octostar/__init__.py
ADDED
octostar/api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains methods for accessing the API"""
|
|
File without changes
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Deploy an app via the FastAPI backend."""
|
|
2
|
+
|
|
3
|
+
from http import HTTPStatus
|
|
4
|
+
from typing import Any, Dict, Optional, Union
|
|
5
|
+
from warnings import warn
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ...client import Client, get_default_client
|
|
10
|
+
from ...types import Response, UNSET, Unset
|
|
11
|
+
from ... import errors
|
|
12
|
+
from ...models.deploy_app_json_body import DeployAppJsonBody
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
|
|
16
|
+
Please create a client using octostar.client.make_client() and run the function via client.execute()."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _get_kwargs(
|
|
20
|
+
workspace: str,
|
|
21
|
+
os_entity_uid: str,
|
|
22
|
+
*,
|
|
23
|
+
client: Client = None,
|
|
24
|
+
json_body: DeployAppJsonBody = None,
|
|
25
|
+
) -> Dict[str, Any]:
|
|
26
|
+
if not client:
|
|
27
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
28
|
+
client = get_default_client()
|
|
29
|
+
|
|
30
|
+
base_url = client.get_base_url_v1()
|
|
31
|
+
url = f"{base_url}/api/v1/apps/deploy/{workspace}/{os_entity_uid}"
|
|
32
|
+
|
|
33
|
+
headers: Dict[str, str] = client.get_headers()
|
|
34
|
+
headers["Content-Type"] = "application/json"
|
|
35
|
+
cookies: Dict[str, Any] = client.get_cookies()
|
|
36
|
+
|
|
37
|
+
# Convert the old DeployAppJsonBody to the new format
|
|
38
|
+
json_data = None
|
|
39
|
+
if json_body:
|
|
40
|
+
body_dict = json_body.to_dict()
|
|
41
|
+
if body_dict.get("secrets"):
|
|
42
|
+
json_data = {"secrets": body_dict["secrets"]}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
"method": "post",
|
|
46
|
+
"url": url,
|
|
47
|
+
"headers": headers,
|
|
48
|
+
"cookies": cookies,
|
|
49
|
+
"timeout": client.get_timeout(),
|
|
50
|
+
"follow_redirects": client.follow_redirects,
|
|
51
|
+
"json": json_data,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _parse_response(
|
|
56
|
+
*, client: Client = None, response: httpx.Response
|
|
57
|
+
) -> Optional[Dict[str, Any]]:
|
|
58
|
+
if not client:
|
|
59
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
60
|
+
client = get_default_client()
|
|
61
|
+
|
|
62
|
+
if response.status_code == HTTPStatus.OK:
|
|
63
|
+
return response.json()
|
|
64
|
+
if client.raise_on_unexpected_status:
|
|
65
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _build_response(
|
|
70
|
+
*, client: Client = None, response: httpx.Response
|
|
71
|
+
) -> Response[Dict[str, Any]]:
|
|
72
|
+
if not client:
|
|
73
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
74
|
+
client = get_default_client()
|
|
75
|
+
|
|
76
|
+
return Response(
|
|
77
|
+
status_code=HTTPStatus(response.status_code),
|
|
78
|
+
content=response.content,
|
|
79
|
+
headers=response.headers,
|
|
80
|
+
parsed=_parse_response(client=client, response=response),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def sync_detailed(
|
|
85
|
+
workspace: str,
|
|
86
|
+
os_entity_uid: str,
|
|
87
|
+
*,
|
|
88
|
+
client: Client = None,
|
|
89
|
+
json_body: DeployAppJsonBody = None,
|
|
90
|
+
) -> Response[Dict[str, Any]]:
|
|
91
|
+
"""Deploy an app from a manifest.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
workspace: The workspace ID containing the app folder.
|
|
95
|
+
os_entity_uid: The entity ID of the app folder.
|
|
96
|
+
client: The Client with which to connect to Octostar.
|
|
97
|
+
json_body: Optional DeployAppJsonBody with secrets.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Response with deployment data including:
|
|
101
|
+
- status: "success" or "error"
|
|
102
|
+
- data: Updated app entity data
|
|
103
|
+
"""
|
|
104
|
+
if not client:
|
|
105
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
106
|
+
client = get_default_client()
|
|
107
|
+
|
|
108
|
+
kwargs = _get_kwargs(
|
|
109
|
+
workspace=workspace,
|
|
110
|
+
os_entity_uid=os_entity_uid,
|
|
111
|
+
client=client,
|
|
112
|
+
json_body=json_body,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
response = httpx.request(verify=client.verify_ssl, **kwargs)
|
|
116
|
+
if response.is_error:
|
|
117
|
+
print(
|
|
118
|
+
f"{response.status_code} Error: {response.text} for request",
|
|
119
|
+
str(kwargs),
|
|
120
|
+
)
|
|
121
|
+
return _build_response(client=client, response=response)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def sync(
|
|
125
|
+
workspace: str,
|
|
126
|
+
os_entity_uid: str,
|
|
127
|
+
*,
|
|
128
|
+
client: Client = None,
|
|
129
|
+
json_body: DeployAppJsonBody = None,
|
|
130
|
+
) -> Optional[Dict[str, Any]]:
|
|
131
|
+
"""Deploy an app from a manifest.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
workspace: The workspace ID containing the app folder.
|
|
135
|
+
os_entity_uid: The entity ID of the app folder.
|
|
136
|
+
client: The Client with which to connect to Octostar.
|
|
137
|
+
json_body: Optional DeployAppJsonBody with secrets.
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
Deployment data or None if request failed.
|
|
141
|
+
"""
|
|
142
|
+
return sync_detailed(
|
|
143
|
+
workspace=workspace,
|
|
144
|
+
os_entity_uid=os_entity_uid,
|
|
145
|
+
client=client,
|
|
146
|
+
json_body=json_body,
|
|
147
|
+
).parsed
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
async def asyncio_detailed(
|
|
151
|
+
workspace: str,
|
|
152
|
+
os_entity_uid: str,
|
|
153
|
+
*,
|
|
154
|
+
client: Client = None,
|
|
155
|
+
json_body: DeployAppJsonBody = None,
|
|
156
|
+
) -> Response[Dict[str, Any]]:
|
|
157
|
+
"""Deploy an app from a manifest asynchronously.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
workspace: The workspace ID containing the app folder.
|
|
161
|
+
os_entity_uid: The entity ID of the app folder.
|
|
162
|
+
client: The Client with which to connect to Octostar.
|
|
163
|
+
json_body: Optional DeployAppJsonBody with secrets.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
Response with deployment data.
|
|
167
|
+
"""
|
|
168
|
+
if not client:
|
|
169
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
170
|
+
client = get_default_client()
|
|
171
|
+
|
|
172
|
+
kwargs = _get_kwargs(
|
|
173
|
+
workspace=workspace,
|
|
174
|
+
os_entity_uid=os_entity_uid,
|
|
175
|
+
client=client,
|
|
176
|
+
json_body=json_body,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
|
180
|
+
response = await _client.request(**kwargs)
|
|
181
|
+
|
|
182
|
+
return _build_response(client=client, response=response)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
async def asyncio(
|
|
186
|
+
workspace: str,
|
|
187
|
+
os_entity_uid: str,
|
|
188
|
+
*,
|
|
189
|
+
client: Client = None,
|
|
190
|
+
json_body: DeployAppJsonBody = None,
|
|
191
|
+
) -> Optional[Dict[str, Any]]:
|
|
192
|
+
"""Deploy an app from a manifest asynchronously.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
workspace: The workspace ID containing the app folder.
|
|
196
|
+
os_entity_uid: The entity ID of the app folder.
|
|
197
|
+
client: The Client with which to connect to Octostar.
|
|
198
|
+
json_body: Optional DeployAppJsonBody with secrets.
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
Deployment data or None if request failed.
|
|
202
|
+
"""
|
|
203
|
+
return (
|
|
204
|
+
await asyncio_detailed(
|
|
205
|
+
workspace=workspace,
|
|
206
|
+
os_entity_uid=os_entity_uid,
|
|
207
|
+
client=client,
|
|
208
|
+
json_body=json_body,
|
|
209
|
+
)
|
|
210
|
+
).parsed
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Execute a job via the FastAPI backend."""
|
|
2
|
+
|
|
3
|
+
from http import HTTPStatus
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
|
+
from warnings import warn
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ...client import Client, get_default_client
|
|
10
|
+
from ...types import Response, UNSET, Unset
|
|
11
|
+
from ... import errors
|
|
12
|
+
from ...models.execute_app_job_json_body import ExecuteAppJobJsonBody
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
|
|
16
|
+
Please create a client using octostar.client.make_client() and run the function via client.execute()."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _get_kwargs(
|
|
20
|
+
*,
|
|
21
|
+
client: Client = None,
|
|
22
|
+
json_body: ExecuteAppJobJsonBody = None,
|
|
23
|
+
) -> Dict[str, Any]:
|
|
24
|
+
if not client:
|
|
25
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
26
|
+
client = get_default_client()
|
|
27
|
+
|
|
28
|
+
base_url = client.get_base_url_v1()
|
|
29
|
+
url = f"{base_url}/api/v1/apps/jobs/execute"
|
|
30
|
+
|
|
31
|
+
headers: Dict[str, str] = client.get_headers()
|
|
32
|
+
headers["Content-Type"] = "application/json"
|
|
33
|
+
cookies: Dict[str, Any] = client.get_cookies()
|
|
34
|
+
|
|
35
|
+
if not json_body:
|
|
36
|
+
raise ValueError("json_body is required for executing a job")
|
|
37
|
+
|
|
38
|
+
# Convert old ExecuteAppJobJsonBody to new JobExecuteRequest format
|
|
39
|
+
body_dict = json_body.to_dict()
|
|
40
|
+
|
|
41
|
+
# Map old format to new format
|
|
42
|
+
# Old: ancestor, ontology, image, is_frontend, archive, manifest, annotation, commands
|
|
43
|
+
# New: ancestor, commands, environment, annotations, timeout
|
|
44
|
+
|
|
45
|
+
commands = body_dict.get("commands", [])
|
|
46
|
+
if isinstance(commands, str):
|
|
47
|
+
commands = [commands]
|
|
48
|
+
|
|
49
|
+
json_data = {
|
|
50
|
+
"ancestor": body_dict["ancestor"],
|
|
51
|
+
"commands": commands,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Map annotation to annotations
|
|
55
|
+
if "annotation" in body_dict and body_dict["annotation"]:
|
|
56
|
+
json_data["annotations"] = body_dict["annotation"]
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
"method": "post",
|
|
60
|
+
"url": url,
|
|
61
|
+
"headers": headers,
|
|
62
|
+
"cookies": cookies,
|
|
63
|
+
"timeout": client.get_timeout(),
|
|
64
|
+
"follow_redirects": client.follow_redirects,
|
|
65
|
+
"json": json_data,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _parse_response(
|
|
70
|
+
*, client: Client = None, response: httpx.Response
|
|
71
|
+
) -> Optional[Dict[str, Any]]:
|
|
72
|
+
if not client:
|
|
73
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
74
|
+
client = get_default_client()
|
|
75
|
+
|
|
76
|
+
if response.status_code == HTTPStatus.OK:
|
|
77
|
+
return response.json()
|
|
78
|
+
if client.raise_on_unexpected_status:
|
|
79
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _build_response(
|
|
84
|
+
*, client: Client = None, response: httpx.Response
|
|
85
|
+
) -> Response[Dict[str, Any]]:
|
|
86
|
+
if not client:
|
|
87
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
88
|
+
client = get_default_client()
|
|
89
|
+
|
|
90
|
+
return Response(
|
|
91
|
+
status_code=HTTPStatus(response.status_code),
|
|
92
|
+
content=response.content,
|
|
93
|
+
headers=response.headers,
|
|
94
|
+
parsed=_parse_response(client=client, response=response),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def sync_detailed(
|
|
99
|
+
*,
|
|
100
|
+
client: Client = None,
|
|
101
|
+
json_body: ExecuteAppJobJsonBody = None,
|
|
102
|
+
) -> Response[Dict[str, Any]]:
|
|
103
|
+
"""Execute a new job.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
client: The Client with which to connect to Octostar.
|
|
107
|
+
json_body: ExecuteAppJobJsonBody with job configuration.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
Response with job execution data including:
|
|
111
|
+
- job_id: The generated job ID
|
|
112
|
+
- status: Job status
|
|
113
|
+
- ancestor: Parent app ID
|
|
114
|
+
- namespace: K8s namespace
|
|
115
|
+
"""
|
|
116
|
+
if not client:
|
|
117
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
118
|
+
client = get_default_client()
|
|
119
|
+
|
|
120
|
+
kwargs = _get_kwargs(client=client, json_body=json_body)
|
|
121
|
+
|
|
122
|
+
response = httpx.request(verify=client.verify_ssl, **kwargs)
|
|
123
|
+
if response.is_error:
|
|
124
|
+
print(
|
|
125
|
+
f"{response.status_code} Error: {response.text} for request",
|
|
126
|
+
str(kwargs),
|
|
127
|
+
)
|
|
128
|
+
return _build_response(client=client, response=response)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def sync(
|
|
132
|
+
*,
|
|
133
|
+
client: Client = None,
|
|
134
|
+
json_body: ExecuteAppJobJsonBody = None,
|
|
135
|
+
) -> Optional[Dict[str, Any]]:
|
|
136
|
+
"""Execute a new job.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
client: The Client with which to connect to Octostar.
|
|
140
|
+
json_body: ExecuteAppJobJsonBody with job configuration.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Job execution data or None if request failed.
|
|
144
|
+
"""
|
|
145
|
+
return sync_detailed(client=client, json_body=json_body).parsed
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
async def asyncio_detailed(
|
|
149
|
+
*,
|
|
150
|
+
client: Client = None,
|
|
151
|
+
json_body: ExecuteAppJobJsonBody = None,
|
|
152
|
+
) -> Response[Dict[str, Any]]:
|
|
153
|
+
"""Execute a new job asynchronously.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
client: The Client with which to connect to Octostar.
|
|
157
|
+
json_body: ExecuteAppJobJsonBody with job configuration.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Response with job execution data.
|
|
161
|
+
"""
|
|
162
|
+
if not client:
|
|
163
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
164
|
+
client = get_default_client()
|
|
165
|
+
|
|
166
|
+
kwargs = _get_kwargs(client=client, json_body=json_body)
|
|
167
|
+
|
|
168
|
+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
|
169
|
+
response = await _client.request(**kwargs)
|
|
170
|
+
|
|
171
|
+
return _build_response(client=client, response=response)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
async def asyncio(
|
|
175
|
+
*,
|
|
176
|
+
client: Client = None,
|
|
177
|
+
json_body: ExecuteAppJobJsonBody = None,
|
|
178
|
+
) -> Optional[Dict[str, Any]]:
|
|
179
|
+
"""Execute a new job asynchronously.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
client: The Client with which to connect to Octostar.
|
|
183
|
+
json_body: ExecuteAppJobJsonBody with job configuration.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
Job execution data or None if request failed.
|
|
187
|
+
"""
|
|
188
|
+
return (await asyncio_detailed(client=client, json_body=json_body)).parsed
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Get app logs from the FastAPI backend."""
|
|
2
|
+
|
|
3
|
+
from http import HTTPStatus
|
|
4
|
+
from typing import Any, Dict, Optional, Union
|
|
5
|
+
from warnings import warn
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from ...client import Client, get_default_client
|
|
10
|
+
from ...types import Response, UNSET, Unset
|
|
11
|
+
from ... import errors
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
client_missing_msg = """No client was passed to this function. The default admin client will be used, but this is deprecated and will be removed soon.
|
|
15
|
+
Please create a client using octostar.client.make_client() and run the function via client.execute()."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_kwargs(
|
|
19
|
+
app_id: str,
|
|
20
|
+
*,
|
|
21
|
+
client: Client = None,
|
|
22
|
+
since_seconds: Union[Unset, None, int] = UNSET,
|
|
23
|
+
tail_lines: Union[Unset, None, int] = UNSET,
|
|
24
|
+
) -> Dict[str, Any]:
|
|
25
|
+
if not client:
|
|
26
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
27
|
+
client = get_default_client()
|
|
28
|
+
|
|
29
|
+
base_url = client.get_base_url_v1()
|
|
30
|
+
url = f"{base_url}/api/v1/apps/logs/{app_id}"
|
|
31
|
+
|
|
32
|
+
headers: Dict[str, str] = client.get_headers()
|
|
33
|
+
cookies: Dict[str, Any] = client.get_cookies()
|
|
34
|
+
|
|
35
|
+
params: Dict[str, Any] = {}
|
|
36
|
+
if not isinstance(since_seconds, Unset) and since_seconds is not None:
|
|
37
|
+
params["since_seconds"] = since_seconds
|
|
38
|
+
if not isinstance(tail_lines, Unset) and tail_lines is not None:
|
|
39
|
+
params["tail_lines"] = tail_lines
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
"method": "get",
|
|
43
|
+
"url": url,
|
|
44
|
+
"headers": headers,
|
|
45
|
+
"cookies": cookies,
|
|
46
|
+
"params": params,
|
|
47
|
+
"timeout": client.get_timeout(),
|
|
48
|
+
"follow_redirects": client.follow_redirects,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _parse_response(
|
|
53
|
+
*, client: Client = None, response: httpx.Response
|
|
54
|
+
) -> Optional[bytes]:
|
|
55
|
+
"""Parse response - returns raw bytes for log content."""
|
|
56
|
+
if not client:
|
|
57
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
58
|
+
client = get_default_client()
|
|
59
|
+
|
|
60
|
+
if response.status_code == HTTPStatus.OK:
|
|
61
|
+
return response.content
|
|
62
|
+
if client.raise_on_unexpected_status:
|
|
63
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
64
|
+
return None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _build_response(
|
|
68
|
+
*, client: Client = None, response: httpx.Response
|
|
69
|
+
) -> Response[bytes]:
|
|
70
|
+
if not client:
|
|
71
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
72
|
+
client = get_default_client()
|
|
73
|
+
|
|
74
|
+
return Response(
|
|
75
|
+
status_code=HTTPStatus(response.status_code),
|
|
76
|
+
content=response.content,
|
|
77
|
+
headers=response.headers,
|
|
78
|
+
parsed=_parse_response(client=client, response=response),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def sync_detailed(
|
|
83
|
+
app_id: str,
|
|
84
|
+
*,
|
|
85
|
+
client: Client = None,
|
|
86
|
+
since_seconds: Union[Unset, None, int] = UNSET,
|
|
87
|
+
tail_lines: Union[Unset, None, int] = UNSET,
|
|
88
|
+
) -> Response[bytes]:
|
|
89
|
+
"""Get app logs.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
app_id: The app ID or alias to get logs for.
|
|
93
|
+
client: The Client with which to connect to Octostar.
|
|
94
|
+
since_seconds: Only return logs from the last N seconds.
|
|
95
|
+
tail_lines: Only return the last N lines.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Response with raw log content in bytes.
|
|
99
|
+
"""
|
|
100
|
+
if not client:
|
|
101
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
102
|
+
client = get_default_client()
|
|
103
|
+
|
|
104
|
+
kwargs = _get_kwargs(
|
|
105
|
+
app_id=app_id,
|
|
106
|
+
client=client,
|
|
107
|
+
since_seconds=since_seconds,
|
|
108
|
+
tail_lines=tail_lines,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
response = httpx.request(verify=client.verify_ssl, **kwargs)
|
|
112
|
+
if response.is_error:
|
|
113
|
+
print(
|
|
114
|
+
f"{response.status_code} Error: {response.text} for request",
|
|
115
|
+
str(kwargs),
|
|
116
|
+
)
|
|
117
|
+
return _build_response(client=client, response=response)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def sync(
|
|
121
|
+
app_id: str,
|
|
122
|
+
*,
|
|
123
|
+
client: Client = None,
|
|
124
|
+
since_seconds: Union[Unset, None, int] = UNSET,
|
|
125
|
+
tail_lines: Union[Unset, None, int] = UNSET,
|
|
126
|
+
) -> Optional[bytes]:
|
|
127
|
+
"""Get app logs.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
app_id: The app ID or alias to get logs for.
|
|
131
|
+
client: The Client with which to connect to Octostar.
|
|
132
|
+
since_seconds: Only return logs from the last N seconds.
|
|
133
|
+
tail_lines: Only return the last N lines.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
Raw log content or None if request failed.
|
|
137
|
+
"""
|
|
138
|
+
response = sync_detailed(
|
|
139
|
+
app_id=app_id,
|
|
140
|
+
client=client,
|
|
141
|
+
since_seconds=since_seconds,
|
|
142
|
+
tail_lines=tail_lines,
|
|
143
|
+
)
|
|
144
|
+
if response.status_code == HTTPStatus.OK:
|
|
145
|
+
return response.content
|
|
146
|
+
return None
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
async def asyncio_detailed(
|
|
150
|
+
app_id: str,
|
|
151
|
+
*,
|
|
152
|
+
client: Client = None,
|
|
153
|
+
since_seconds: Union[Unset, None, int] = UNSET,
|
|
154
|
+
tail_lines: Union[Unset, None, int] = UNSET,
|
|
155
|
+
) -> Response[bytes]:
|
|
156
|
+
"""Get app logs asynchronously.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
app_id: The app ID or alias to get logs for.
|
|
160
|
+
client: The Client with which to connect to Octostar.
|
|
161
|
+
since_seconds: Only return logs from the last N seconds.
|
|
162
|
+
tail_lines: Only return the last N lines.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Response with raw log content.
|
|
166
|
+
"""
|
|
167
|
+
if not client:
|
|
168
|
+
warn(client_missing_msg, FutureWarning, stacklevel=2)
|
|
169
|
+
client = get_default_client()
|
|
170
|
+
|
|
171
|
+
kwargs = _get_kwargs(
|
|
172
|
+
app_id=app_id,
|
|
173
|
+
client=client,
|
|
174
|
+
since_seconds=since_seconds,
|
|
175
|
+
tail_lines=tail_lines,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
|
|
179
|
+
response = await _client.request(**kwargs)
|
|
180
|
+
|
|
181
|
+
return _build_response(client=client, response=response)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
async def asyncio(
|
|
185
|
+
app_id: str,
|
|
186
|
+
*,
|
|
187
|
+
client: Client = None,
|
|
188
|
+
since_seconds: Union[Unset, None, int] = UNSET,
|
|
189
|
+
tail_lines: Union[Unset, None, int] = UNSET,
|
|
190
|
+
) -> Optional[bytes]:
|
|
191
|
+
"""Get app logs asynchronously.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
app_id: The app ID or alias to get logs for.
|
|
195
|
+
client: The Client with which to connect to Octostar.
|
|
196
|
+
since_seconds: Only return logs from the last N seconds.
|
|
197
|
+
tail_lines: Only return the last N lines.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
Raw log content or None if request failed.
|
|
201
|
+
"""
|
|
202
|
+
response = await asyncio_detailed(
|
|
203
|
+
app_id=app_id,
|
|
204
|
+
client=client,
|
|
205
|
+
since_seconds=since_seconds,
|
|
206
|
+
tail_lines=tail_lines,
|
|
207
|
+
)
|
|
208
|
+
if response.status_code == HTTPStatus.OK:
|
|
209
|
+
return response.content
|
|
210
|
+
return None
|