blaxel 0.1.9rc35__py3-none-any.whl → 0.1.9rc37__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.
- blaxel/agents/__init__.py +53 -16
- blaxel/authentication/__init__.py +3 -4
- blaxel/client/api/compute/__init__.py +0 -0
- blaxel/client/api/compute/create_sandbox.py +166 -0
- blaxel/client/api/compute/delete_sandbox.py +154 -0
- blaxel/client/api/compute/get_sandbox.py +154 -0
- blaxel/client/api/compute/list_sandboxes.py +135 -0
- blaxel/client/api/compute/start_sandbox.py +157 -0
- blaxel/client/api/compute/stop_sandbox.py +157 -0
- blaxel/client/api/compute/update_sandbox.py +179 -0
- blaxel/client/api/default/list_sandbox_hub_definitions.py +123 -0
- blaxel/client/api/functions/list_function_revisions.py +16 -11
- blaxel/client/api/knowledgebases/list_knowledgebase_revisions.py +16 -11
- blaxel/client/api/models/list_model_revisions.py +16 -11
- blaxel/client/api/templates/list_templates.py +16 -11
- blaxel/client/models/__init__.py +32 -2
- blaxel/client/models/agent_spec.py +25 -69
- blaxel/client/models/core_spec.py +1 -45
- blaxel/client/models/function_spec.py +1 -45
- blaxel/client/models/last_n_requests_metric.py +18 -0
- blaxel/client/models/metrics.py +20 -0
- blaxel/client/models/model_spec.py +1 -45
- blaxel/client/models/{agent_chain.py → port.py} +23 -32
- blaxel/client/models/request_total_metric.py +12 -1
- blaxel/client/models/request_total_response_data.py +97 -0
- blaxel/client/models/resource_log.py +9 -0
- blaxel/client/models/resource_metrics.py +144 -0
- blaxel/client/models/resource_metrics_request_total_per_code_previous.py +45 -0
- blaxel/client/models/resource_metrics_rps_per_code_previous.py +45 -0
- blaxel/client/models/runtime.py +83 -7
- blaxel/client/models/runtime_configuration.py +45 -0
- blaxel/client/models/sandbox.py +129 -0
- blaxel/client/models/sandbox_definition.py +181 -0
- blaxel/client/models/sandbox_spec.py +208 -0
- blaxel/client/models/sandboxes.py +129 -0
- blaxel/client/models/serverless_config.py +29 -1
- blaxel/client/models/serverless_config_configuration.py +45 -0
- blaxel/client/models/start_sandbox.py +94 -0
- blaxel/client/models/stop_sandbox.py +94 -0
- blaxel/client/models/trigger.py +98 -0
- blaxel/client/models/trigger_configuration.py +45 -0
- blaxel/client/models/workspace.py +20 -0
- blaxel/client/models/workspace_runtime.py +61 -0
- blaxel/common/autoload.py +0 -4
- blaxel/common/internal.py +75 -0
- blaxel/common/settings.py +6 -1
- blaxel/instrumentation/exporters.py +3 -6
- blaxel/instrumentation/manager.py +5 -3
- blaxel/mcp/client.py +1 -3
- blaxel/mcp/server.py +4 -4
- blaxel/models/__init__.py +2 -1
- blaxel/models/custom/langchain/gemini.py +41 -18
- blaxel/models/custom/llamaindex/cohere.py +25 -16
- blaxel/models/custom/pydantic/gemini.py +0 -1
- blaxel/models/livekit.py +1 -1
- blaxel/tools/__init__.py +63 -22
- blaxel/tools/langchain.py +1 -2
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/METADATA +1 -4
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/RECORD +61 -37
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/WHEEL +0 -0
- {blaxel-0.1.9rc35.dist-info → blaxel-0.1.9rc37.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,14 @@
|
|
1
|
-
from typing import Any, TypeVar, Union
|
1
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
2
2
|
|
3
3
|
from attrs import define as _attrs_define
|
4
4
|
from attrs import field as _attrs_field
|
5
5
|
|
6
6
|
from ..types import UNSET, Unset
|
7
7
|
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from ..models.serverless_config_configuration import ServerlessConfigConfiguration
|
10
|
+
|
11
|
+
|
8
12
|
T = TypeVar("T", bound="ServerlessConfig")
|
9
13
|
|
10
14
|
|
@@ -13,18 +17,30 @@ class ServerlessConfig:
|
|
13
17
|
"""Configuration for a serverless deployment
|
14
18
|
|
15
19
|
Attributes:
|
20
|
+
configuration (Union[Unset, ServerlessConfigConfiguration]): The configuration for the deployment
|
16
21
|
max_scale (Union[Unset, int]): The minimum number of replicas for the deployment. Can be 0 or 1 (in which case
|
17
22
|
the deployment is always running in at least one location).
|
18
23
|
min_scale (Union[Unset, int]): The maximum number of replicas for the deployment.
|
19
24
|
timeout (Union[Unset, int]): The timeout for the deployment in seconds
|
20
25
|
"""
|
21
26
|
|
27
|
+
configuration: Union[Unset, "ServerlessConfigConfiguration"] = UNSET
|
22
28
|
max_scale: Union[Unset, int] = UNSET
|
23
29
|
min_scale: Union[Unset, int] = UNSET
|
24
30
|
timeout: Union[Unset, int] = UNSET
|
25
31
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
26
32
|
|
27
33
|
def to_dict(self) -> dict[str, Any]:
|
34
|
+
configuration: Union[Unset, dict[str, Any]] = UNSET
|
35
|
+
if (
|
36
|
+
self.configuration
|
37
|
+
and not isinstance(self.configuration, Unset)
|
38
|
+
and not isinstance(self.configuration, dict)
|
39
|
+
):
|
40
|
+
configuration = self.configuration.to_dict()
|
41
|
+
elif self.configuration and isinstance(self.configuration, dict):
|
42
|
+
configuration = self.configuration
|
43
|
+
|
28
44
|
max_scale = self.max_scale
|
29
45
|
|
30
46
|
min_scale = self.min_scale
|
@@ -34,6 +50,8 @@ class ServerlessConfig:
|
|
34
50
|
field_dict: dict[str, Any] = {}
|
35
51
|
field_dict.update(self.additional_properties)
|
36
52
|
field_dict.update({})
|
53
|
+
if configuration is not UNSET:
|
54
|
+
field_dict["configuration"] = configuration
|
37
55
|
if max_scale is not UNSET:
|
38
56
|
field_dict["maxScale"] = max_scale
|
39
57
|
if min_scale is not UNSET:
|
@@ -45,9 +63,18 @@ class ServerlessConfig:
|
|
45
63
|
|
46
64
|
@classmethod
|
47
65
|
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
66
|
+
from ..models.serverless_config_configuration import ServerlessConfigConfiguration
|
67
|
+
|
48
68
|
if not src_dict:
|
49
69
|
return None
|
50
70
|
d = src_dict.copy()
|
71
|
+
_configuration = d.pop("configuration", UNSET)
|
72
|
+
configuration: Union[Unset, ServerlessConfigConfiguration]
|
73
|
+
if isinstance(_configuration, Unset):
|
74
|
+
configuration = UNSET
|
75
|
+
else:
|
76
|
+
configuration = ServerlessConfigConfiguration.from_dict(_configuration)
|
77
|
+
|
51
78
|
max_scale = d.pop("maxScale", UNSET)
|
52
79
|
|
53
80
|
min_scale = d.pop("minScale", UNSET)
|
@@ -55,6 +82,7 @@ class ServerlessConfig:
|
|
55
82
|
timeout = d.pop("timeout", UNSET)
|
56
83
|
|
57
84
|
serverless_config = cls(
|
85
|
+
configuration=configuration,
|
58
86
|
max_scale=max_scale,
|
59
87
|
min_scale=min_scale,
|
60
88
|
timeout=timeout,
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from typing import Any, TypeVar
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
T = TypeVar("T", bound="ServerlessConfigConfiguration")
|
7
|
+
|
8
|
+
|
9
|
+
@_attrs_define
|
10
|
+
class ServerlessConfigConfiguration:
|
11
|
+
"""The configuration for the deployment"""
|
12
|
+
|
13
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
14
|
+
|
15
|
+
def to_dict(self) -> dict[str, Any]:
|
16
|
+
field_dict: dict[str, Any] = {}
|
17
|
+
field_dict.update(self.additional_properties)
|
18
|
+
|
19
|
+
return field_dict
|
20
|
+
|
21
|
+
@classmethod
|
22
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
23
|
+
if not src_dict:
|
24
|
+
return None
|
25
|
+
d = src_dict.copy()
|
26
|
+
serverless_config_configuration = cls()
|
27
|
+
|
28
|
+
serverless_config_configuration.additional_properties = d
|
29
|
+
return serverless_config_configuration
|
30
|
+
|
31
|
+
@property
|
32
|
+
def additional_keys(self) -> list[str]:
|
33
|
+
return list(self.additional_properties.keys())
|
34
|
+
|
35
|
+
def __getitem__(self, key: str) -> Any:
|
36
|
+
return self.additional_properties[key]
|
37
|
+
|
38
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
39
|
+
self.additional_properties[key] = value
|
40
|
+
|
41
|
+
def __delitem__(self, key: str) -> None:
|
42
|
+
del self.additional_properties[key]
|
43
|
+
|
44
|
+
def __contains__(self, key: str) -> bool:
|
45
|
+
return key in self.additional_properties
|
@@ -0,0 +1,94 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from ..models.metadata import Metadata
|
10
|
+
|
11
|
+
|
12
|
+
T = TypeVar("T", bound="StartSandbox")
|
13
|
+
|
14
|
+
|
15
|
+
@_attrs_define
|
16
|
+
class StartSandbox:
|
17
|
+
"""Response when starting a Sandbox
|
18
|
+
|
19
|
+
Attributes:
|
20
|
+
message (Union[Unset, str]): Human readable message about the start operation
|
21
|
+
metadata (Union[Unset, Metadata]): Metadata
|
22
|
+
status (Union[Unset, str]): Status of the Sandbox start operation
|
23
|
+
"""
|
24
|
+
|
25
|
+
message: Union[Unset, str] = UNSET
|
26
|
+
metadata: Union[Unset, "Metadata"] = UNSET
|
27
|
+
status: Union[Unset, str] = UNSET
|
28
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
29
|
+
|
30
|
+
def to_dict(self) -> dict[str, Any]:
|
31
|
+
message = self.message
|
32
|
+
|
33
|
+
metadata: Union[Unset, dict[str, Any]] = UNSET
|
34
|
+
if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
|
35
|
+
metadata = self.metadata.to_dict()
|
36
|
+
elif self.metadata and isinstance(self.metadata, dict):
|
37
|
+
metadata = self.metadata
|
38
|
+
|
39
|
+
status = self.status
|
40
|
+
|
41
|
+
field_dict: dict[str, Any] = {}
|
42
|
+
field_dict.update(self.additional_properties)
|
43
|
+
field_dict.update({})
|
44
|
+
if message is not UNSET:
|
45
|
+
field_dict["message"] = message
|
46
|
+
if metadata is not UNSET:
|
47
|
+
field_dict["metadata"] = metadata
|
48
|
+
if status is not UNSET:
|
49
|
+
field_dict["status"] = status
|
50
|
+
|
51
|
+
return field_dict
|
52
|
+
|
53
|
+
@classmethod
|
54
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
55
|
+
from ..models.metadata import Metadata
|
56
|
+
|
57
|
+
if not src_dict:
|
58
|
+
return None
|
59
|
+
d = src_dict.copy()
|
60
|
+
message = d.pop("message", UNSET)
|
61
|
+
|
62
|
+
_metadata = d.pop("metadata", UNSET)
|
63
|
+
metadata: Union[Unset, Metadata]
|
64
|
+
if isinstance(_metadata, Unset):
|
65
|
+
metadata = UNSET
|
66
|
+
else:
|
67
|
+
metadata = Metadata.from_dict(_metadata)
|
68
|
+
|
69
|
+
status = d.pop("status", UNSET)
|
70
|
+
|
71
|
+
start_sandbox = cls(
|
72
|
+
message=message,
|
73
|
+
metadata=metadata,
|
74
|
+
status=status,
|
75
|
+
)
|
76
|
+
|
77
|
+
start_sandbox.additional_properties = d
|
78
|
+
return start_sandbox
|
79
|
+
|
80
|
+
@property
|
81
|
+
def additional_keys(self) -> list[str]:
|
82
|
+
return list(self.additional_properties.keys())
|
83
|
+
|
84
|
+
def __getitem__(self, key: str) -> Any:
|
85
|
+
return self.additional_properties[key]
|
86
|
+
|
87
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
88
|
+
self.additional_properties[key] = value
|
89
|
+
|
90
|
+
def __delitem__(self, key: str) -> None:
|
91
|
+
del self.additional_properties[key]
|
92
|
+
|
93
|
+
def __contains__(self, key: str) -> bool:
|
94
|
+
return key in self.additional_properties
|
@@ -0,0 +1,94 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from ..models.metadata import Metadata
|
10
|
+
|
11
|
+
|
12
|
+
T = TypeVar("T", bound="StopSandbox")
|
13
|
+
|
14
|
+
|
15
|
+
@_attrs_define
|
16
|
+
class StopSandbox:
|
17
|
+
"""Response when stopping a Sandbox
|
18
|
+
|
19
|
+
Attributes:
|
20
|
+
message (Union[Unset, str]): Human readable message about the stop operation
|
21
|
+
metadata (Union[Unset, Metadata]): Metadata
|
22
|
+
status (Union[Unset, str]): Status of the Sandbox stop operation
|
23
|
+
"""
|
24
|
+
|
25
|
+
message: Union[Unset, str] = UNSET
|
26
|
+
metadata: Union[Unset, "Metadata"] = UNSET
|
27
|
+
status: Union[Unset, str] = UNSET
|
28
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
29
|
+
|
30
|
+
def to_dict(self) -> dict[str, Any]:
|
31
|
+
message = self.message
|
32
|
+
|
33
|
+
metadata: Union[Unset, dict[str, Any]] = UNSET
|
34
|
+
if self.metadata and not isinstance(self.metadata, Unset) and not isinstance(self.metadata, dict):
|
35
|
+
metadata = self.metadata.to_dict()
|
36
|
+
elif self.metadata and isinstance(self.metadata, dict):
|
37
|
+
metadata = self.metadata
|
38
|
+
|
39
|
+
status = self.status
|
40
|
+
|
41
|
+
field_dict: dict[str, Any] = {}
|
42
|
+
field_dict.update(self.additional_properties)
|
43
|
+
field_dict.update({})
|
44
|
+
if message is not UNSET:
|
45
|
+
field_dict["message"] = message
|
46
|
+
if metadata is not UNSET:
|
47
|
+
field_dict["metadata"] = metadata
|
48
|
+
if status is not UNSET:
|
49
|
+
field_dict["status"] = status
|
50
|
+
|
51
|
+
return field_dict
|
52
|
+
|
53
|
+
@classmethod
|
54
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
55
|
+
from ..models.metadata import Metadata
|
56
|
+
|
57
|
+
if not src_dict:
|
58
|
+
return None
|
59
|
+
d = src_dict.copy()
|
60
|
+
message = d.pop("message", UNSET)
|
61
|
+
|
62
|
+
_metadata = d.pop("metadata", UNSET)
|
63
|
+
metadata: Union[Unset, Metadata]
|
64
|
+
if isinstance(_metadata, Unset):
|
65
|
+
metadata = UNSET
|
66
|
+
else:
|
67
|
+
metadata = Metadata.from_dict(_metadata)
|
68
|
+
|
69
|
+
status = d.pop("status", UNSET)
|
70
|
+
|
71
|
+
stop_sandbox = cls(
|
72
|
+
message=message,
|
73
|
+
metadata=metadata,
|
74
|
+
status=status,
|
75
|
+
)
|
76
|
+
|
77
|
+
stop_sandbox.additional_properties = d
|
78
|
+
return stop_sandbox
|
79
|
+
|
80
|
+
@property
|
81
|
+
def additional_keys(self) -> list[str]:
|
82
|
+
return list(self.additional_properties.keys())
|
83
|
+
|
84
|
+
def __getitem__(self, key: str) -> Any:
|
85
|
+
return self.additional_properties[key]
|
86
|
+
|
87
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
88
|
+
self.additional_properties[key] = value
|
89
|
+
|
90
|
+
def __delitem__(self, key: str) -> None:
|
91
|
+
del self.additional_properties[key]
|
92
|
+
|
93
|
+
def __contains__(self, key: str) -> bool:
|
94
|
+
return key in self.additional_properties
|
@@ -0,0 +1,98 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from ..models.trigger_configuration import TriggerConfiguration
|
10
|
+
|
11
|
+
|
12
|
+
T = TypeVar("T", bound="Trigger")
|
13
|
+
|
14
|
+
|
15
|
+
@_attrs_define
|
16
|
+
class Trigger:
|
17
|
+
"""Trigger configuration
|
18
|
+
|
19
|
+
Attributes:
|
20
|
+
configuration (Union[Unset, TriggerConfiguration]): The configuration of the trigger
|
21
|
+
id (Union[Unset, str]): The id of the trigger
|
22
|
+
type_ (Union[Unset, str]): The type of trigger, can be http or http-async
|
23
|
+
"""
|
24
|
+
|
25
|
+
configuration: Union[Unset, "TriggerConfiguration"] = UNSET
|
26
|
+
id: Union[Unset, str] = UNSET
|
27
|
+
type_: Union[Unset, str] = UNSET
|
28
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
29
|
+
|
30
|
+
def to_dict(self) -> dict[str, Any]:
|
31
|
+
configuration: Union[Unset, dict[str, Any]] = UNSET
|
32
|
+
if (
|
33
|
+
self.configuration
|
34
|
+
and not isinstance(self.configuration, Unset)
|
35
|
+
and not isinstance(self.configuration, dict)
|
36
|
+
):
|
37
|
+
configuration = self.configuration.to_dict()
|
38
|
+
elif self.configuration and isinstance(self.configuration, dict):
|
39
|
+
configuration = self.configuration
|
40
|
+
|
41
|
+
id = self.id
|
42
|
+
|
43
|
+
type_ = self.type_
|
44
|
+
|
45
|
+
field_dict: dict[str, Any] = {}
|
46
|
+
field_dict.update(self.additional_properties)
|
47
|
+
field_dict.update({})
|
48
|
+
if configuration is not UNSET:
|
49
|
+
field_dict["configuration"] = configuration
|
50
|
+
if id is not UNSET:
|
51
|
+
field_dict["id"] = id
|
52
|
+
if type_ is not UNSET:
|
53
|
+
field_dict["type"] = type_
|
54
|
+
|
55
|
+
return field_dict
|
56
|
+
|
57
|
+
@classmethod
|
58
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
59
|
+
from ..models.trigger_configuration import TriggerConfiguration
|
60
|
+
|
61
|
+
if not src_dict:
|
62
|
+
return None
|
63
|
+
d = src_dict.copy()
|
64
|
+
_configuration = d.pop("configuration", UNSET)
|
65
|
+
configuration: Union[Unset, TriggerConfiguration]
|
66
|
+
if isinstance(_configuration, Unset):
|
67
|
+
configuration = UNSET
|
68
|
+
else:
|
69
|
+
configuration = TriggerConfiguration.from_dict(_configuration)
|
70
|
+
|
71
|
+
id = d.pop("id", UNSET)
|
72
|
+
|
73
|
+
type_ = d.pop("type", UNSET)
|
74
|
+
|
75
|
+
trigger = cls(
|
76
|
+
configuration=configuration,
|
77
|
+
id=id,
|
78
|
+
type_=type_,
|
79
|
+
)
|
80
|
+
|
81
|
+
trigger.additional_properties = d
|
82
|
+
return trigger
|
83
|
+
|
84
|
+
@property
|
85
|
+
def additional_keys(self) -> list[str]:
|
86
|
+
return list(self.additional_properties.keys())
|
87
|
+
|
88
|
+
def __getitem__(self, key: str) -> Any:
|
89
|
+
return self.additional_properties[key]
|
90
|
+
|
91
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
92
|
+
self.additional_properties[key] = value
|
93
|
+
|
94
|
+
def __delitem__(self, key: str) -> None:
|
95
|
+
del self.additional_properties[key]
|
96
|
+
|
97
|
+
def __contains__(self, key: str) -> bool:
|
98
|
+
return key in self.additional_properties
|
@@ -0,0 +1,45 @@
|
|
1
|
+
from typing import Any, TypeVar
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
T = TypeVar("T", bound="TriggerConfiguration")
|
7
|
+
|
8
|
+
|
9
|
+
@_attrs_define
|
10
|
+
class TriggerConfiguration:
|
11
|
+
"""The configuration of the trigger"""
|
12
|
+
|
13
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
14
|
+
|
15
|
+
def to_dict(self) -> dict[str, Any]:
|
16
|
+
field_dict: dict[str, Any] = {}
|
17
|
+
field_dict.update(self.additional_properties)
|
18
|
+
|
19
|
+
return field_dict
|
20
|
+
|
21
|
+
@classmethod
|
22
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
23
|
+
if not src_dict:
|
24
|
+
return None
|
25
|
+
d = src_dict.copy()
|
26
|
+
trigger_configuration = cls()
|
27
|
+
|
28
|
+
trigger_configuration.additional_properties = d
|
29
|
+
return trigger_configuration
|
30
|
+
|
31
|
+
@property
|
32
|
+
def additional_keys(self) -> list[str]:
|
33
|
+
return list(self.additional_properties.keys())
|
34
|
+
|
35
|
+
def __getitem__(self, key: str) -> Any:
|
36
|
+
return self.additional_properties[key]
|
37
|
+
|
38
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
39
|
+
self.additional_properties[key] = value
|
40
|
+
|
41
|
+
def __delitem__(self, key: str) -> None:
|
42
|
+
del self.additional_properties[key]
|
43
|
+
|
44
|
+
def __contains__(self, key: str) -> bool:
|
45
|
+
return key in self.additional_properties
|
@@ -7,6 +7,7 @@ from ..types import UNSET, Unset
|
|
7
7
|
|
8
8
|
if TYPE_CHECKING:
|
9
9
|
from ..models.workspace_labels import WorkspaceLabels
|
10
|
+
from ..models.workspace_runtime import WorkspaceRuntime
|
10
11
|
|
11
12
|
|
12
13
|
T = TypeVar("T", bound="Workspace")
|
@@ -26,6 +27,7 @@ class Workspace:
|
|
26
27
|
labels (Union[Unset, WorkspaceLabels]): Workspace labels
|
27
28
|
name (Union[Unset, str]): Workspace name
|
28
29
|
region (Union[Unset, str]): Workspace write region
|
30
|
+
runtime (Union[Unset, WorkspaceRuntime]): Workspace runtime
|
29
31
|
"""
|
30
32
|
|
31
33
|
created_at: Union[Unset, str] = UNSET
|
@@ -37,6 +39,7 @@ class Workspace:
|
|
37
39
|
labels: Union[Unset, "WorkspaceLabels"] = UNSET
|
38
40
|
name: Union[Unset, str] = UNSET
|
39
41
|
region: Union[Unset, str] = UNSET
|
42
|
+
runtime: Union[Unset, "WorkspaceRuntime"] = UNSET
|
40
43
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
41
44
|
|
42
45
|
def to_dict(self) -> dict[str, Any]:
|
@@ -62,6 +65,12 @@ class Workspace:
|
|
62
65
|
|
63
66
|
region = self.region
|
64
67
|
|
68
|
+
runtime: Union[Unset, dict[str, Any]] = UNSET
|
69
|
+
if self.runtime and not isinstance(self.runtime, Unset) and not isinstance(self.runtime, dict):
|
70
|
+
runtime = self.runtime.to_dict()
|
71
|
+
elif self.runtime and isinstance(self.runtime, dict):
|
72
|
+
runtime = self.runtime
|
73
|
+
|
65
74
|
field_dict: dict[str, Any] = {}
|
66
75
|
field_dict.update(self.additional_properties)
|
67
76
|
field_dict.update({})
|
@@ -83,12 +92,15 @@ class Workspace:
|
|
83
92
|
field_dict["name"] = name
|
84
93
|
if region is not UNSET:
|
85
94
|
field_dict["region"] = region
|
95
|
+
if runtime is not UNSET:
|
96
|
+
field_dict["runtime"] = runtime
|
86
97
|
|
87
98
|
return field_dict
|
88
99
|
|
89
100
|
@classmethod
|
90
101
|
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
91
102
|
from ..models.workspace_labels import WorkspaceLabels
|
103
|
+
from ..models.workspace_runtime import WorkspaceRuntime
|
92
104
|
|
93
105
|
if not src_dict:
|
94
106
|
return None
|
@@ -116,6 +128,13 @@ class Workspace:
|
|
116
128
|
|
117
129
|
region = d.pop("region", UNSET)
|
118
130
|
|
131
|
+
_runtime = d.pop("runtime", UNSET)
|
132
|
+
runtime: Union[Unset, WorkspaceRuntime]
|
133
|
+
if isinstance(_runtime, Unset):
|
134
|
+
runtime = UNSET
|
135
|
+
else:
|
136
|
+
runtime = WorkspaceRuntime.from_dict(_runtime)
|
137
|
+
|
119
138
|
workspace = cls(
|
120
139
|
created_at=created_at,
|
121
140
|
updated_at=updated_at,
|
@@ -126,6 +145,7 @@ class Workspace:
|
|
126
145
|
labels=labels,
|
127
146
|
name=name,
|
128
147
|
region=region,
|
148
|
+
runtime=runtime,
|
129
149
|
)
|
130
150
|
|
131
151
|
workspace.additional_properties = d
|
@@ -0,0 +1,61 @@
|
|
1
|
+
from typing import Any, TypeVar, Union
|
2
|
+
|
3
|
+
from attrs import define as _attrs_define
|
4
|
+
from attrs import field as _attrs_field
|
5
|
+
|
6
|
+
from ..types import UNSET, Unset
|
7
|
+
|
8
|
+
T = TypeVar("T", bound="WorkspaceRuntime")
|
9
|
+
|
10
|
+
|
11
|
+
@_attrs_define
|
12
|
+
class WorkspaceRuntime:
|
13
|
+
"""Workspace runtime
|
14
|
+
|
15
|
+
Attributes:
|
16
|
+
generation (Union[Unset, str]): Workspace generation
|
17
|
+
"""
|
18
|
+
|
19
|
+
generation: Union[Unset, str] = UNSET
|
20
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
21
|
+
|
22
|
+
def to_dict(self) -> dict[str, Any]:
|
23
|
+
generation = self.generation
|
24
|
+
|
25
|
+
field_dict: dict[str, Any] = {}
|
26
|
+
field_dict.update(self.additional_properties)
|
27
|
+
field_dict.update({})
|
28
|
+
if generation is not UNSET:
|
29
|
+
field_dict["generation"] = generation
|
30
|
+
|
31
|
+
return field_dict
|
32
|
+
|
33
|
+
@classmethod
|
34
|
+
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
35
|
+
if not src_dict:
|
36
|
+
return None
|
37
|
+
d = src_dict.copy()
|
38
|
+
generation = d.pop("generation", UNSET)
|
39
|
+
|
40
|
+
workspace_runtime = cls(
|
41
|
+
generation=generation,
|
42
|
+
)
|
43
|
+
|
44
|
+
workspace_runtime.additional_properties = d
|
45
|
+
return workspace_runtime
|
46
|
+
|
47
|
+
@property
|
48
|
+
def additional_keys(self) -> list[str]:
|
49
|
+
return list(self.additional_properties.keys())
|
50
|
+
|
51
|
+
def __getitem__(self, key: str) -> Any:
|
52
|
+
return self.additional_properties[key]
|
53
|
+
|
54
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
55
|
+
self.additional_properties[key] = value
|
56
|
+
|
57
|
+
def __delitem__(self, key: str) -> None:
|
58
|
+
del self.additional_properties[key]
|
59
|
+
|
60
|
+
def __contains__(self, key: str) -> bool:
|
61
|
+
return key in self.additional_properties
|
blaxel/common/autoload.py
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
import base64
|
2
|
+
import hashlib
|
3
|
+
import os
|
4
|
+
import re
|
5
|
+
from typing import Optional
|
6
|
+
from logging import getLogger
|
7
|
+
|
8
|
+
logger = getLogger(__name__)
|
9
|
+
|
10
|
+
def get_alphanumeric_limited_hash(input_str, max_size):
|
11
|
+
# Create SHA-256 hash of the input string
|
12
|
+
hash_obj = hashlib.sha256(input_str.encode('utf-8'))
|
13
|
+
|
14
|
+
# Get the hash digest in base64 format
|
15
|
+
hash_base64 = base64.b64encode(hash_obj.digest()).decode('utf-8')
|
16
|
+
|
17
|
+
# Remove non-alphanumeric characters and convert to lowercase
|
18
|
+
alphanumeric = re.sub(r'[^a-zA-Z0-9]', '', hash_base64).lower()
|
19
|
+
|
20
|
+
# Skip the first character to match the Node.js crypto output
|
21
|
+
alphanumeric = alphanumeric[1:]
|
22
|
+
|
23
|
+
# Limit to max_size characters
|
24
|
+
return alphanumeric[:max_size] if len(alphanumeric) > max_size else alphanumeric
|
25
|
+
|
26
|
+
|
27
|
+
def get_global_unique_hash(workspace: str, type: str, name: str) -> str:
|
28
|
+
"""
|
29
|
+
Generate a unique hash for a combination of workspace, type, and name.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
workspace: The workspace identifier
|
33
|
+
type: The type identifier
|
34
|
+
name: The name identifier
|
35
|
+
|
36
|
+
Returns:
|
37
|
+
A unique alphanumeric hash string of maximum length 48
|
38
|
+
"""
|
39
|
+
global_unique_name = f"{workspace}-{type}-{name}"
|
40
|
+
hash = get_alphanumeric_limited_hash(global_unique_name, 48)
|
41
|
+
return hash
|
42
|
+
|
43
|
+
class Agent:
|
44
|
+
def __init__(self, agent_name: str, workspace: str, run_internal_protocol: str, run_internal_hostname: str):
|
45
|
+
self.agent_name = agent_name
|
46
|
+
self.workspace = workspace
|
47
|
+
self.run_internal_protocol = run_internal_protocol
|
48
|
+
self.run_internal_hostname = run_internal_hostname
|
49
|
+
|
50
|
+
@property
|
51
|
+
def internal_url(self) -> str:
|
52
|
+
"""
|
53
|
+
Generate the internal URL for the agent using a unique hash.
|
54
|
+
|
55
|
+
Returns:
|
56
|
+
The internal URL as a string
|
57
|
+
"""
|
58
|
+
hash_value = get_global_unique_hash(
|
59
|
+
self.workspace,
|
60
|
+
"agent",
|
61
|
+
self.agent_name
|
62
|
+
)
|
63
|
+
return f"{self.run_internal_protocol}://{hash_value}.{self.run_internal_hostname}"
|
64
|
+
|
65
|
+
@property
|
66
|
+
def forced_url(self) -> Optional[str]:
|
67
|
+
"""
|
68
|
+
Check for a forced URL in environment variables.
|
69
|
+
|
70
|
+
Returns:
|
71
|
+
The forced URL if found in environment variables, None otherwise
|
72
|
+
"""
|
73
|
+
env_var = self.agent_name.replace("-", "_").upper()
|
74
|
+
env_key = f"BL_AGENT_{env_var}_URL"
|
75
|
+
return os.environ.get(env_key)
|