Skip to content

Commit 8de165c

Browse files
committed
added register secret flow
1 parent 1f705c5 commit 8de165c

6 files changed

Lines changed: 29 additions & 6 deletions

File tree

python-sdk/exospherehost/node/BaseNode.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class Outputs(BaseModel):
4242
"""
4343
pass
4444

45+
class Secrets(BaseModel):
46+
"""
47+
Secrets schema for the node.
48+
"""
49+
pass
50+
4551
async def _execute(self, inputs: Inputs) -> Outputs | List[Outputs]:
4652
"""
4753
Internal method to execute the node with validated inputs.

python-sdk/exospherehost/runtime.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ async def _register(self):
135135
"namespace": self._namespace,
136136
"inputs_schema": node.Inputs.model_json_schema(),
137137
"outputs_schema": node.Outputs.model_json_schema(),
138+
"secrets": [
139+
secret_name for secret_name in node.Secrets.model_fields.keys()
140+
]
138141
} for node in self._nodes
139142
]
140143
}
@@ -246,9 +249,17 @@ def _validate_nodes(self):
246249
if not hasattr(node, "Outputs"):
247250
errors.append(f"{node.__name__} does not have an Outputs class")
248251
if not issubclass(node.Inputs, BaseModel):
249-
errors.append(f"{node.__name__} does not have an Inputs class that inherits from pydantic.BaseModel")
252+
errors.append(f"{node.__name__} does not have an Inputs class that inherits from pydantic.BaseModel")
250253
if not issubclass(node.Outputs, BaseModel):
251254
errors.append(f"{node.__name__} does not have an Outputs class that inherits from pydantic.BaseModel")
255+
if not hasattr(node, "Secrets"):
256+
errors.append(f"{node.__name__} does not have an Secrets class")
257+
if not issubclass(node.Secrets, BaseModel):
258+
errors.append(f"{node.__name__} does not have an Secrets class that inherits from pydantic.BaseModel")
259+
260+
for field_name, field_info in node.Secrets.model_fields.items():
261+
if field_info.annotation != str:
262+
errors.append(f"{node.__name__}.Secrets field '{field_name}' must be of type str, got {field_info.annotation}")
252263

253264
# Find nodes with the same __class__.__name__
254265
class_names = [node.__name__ for node in self._nodes]

state-manager/app/controller/register_nodes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ async def register_nodes(namespace_name: str, body: RegisterNodesRequestModel, x
3030
RegisteredNode.runtime_name: body.runtime_name,
3131
RegisteredNode.runtime_namespace: namespace_name,
3232
RegisteredNode.inputs_schema: node_data.inputs_schema, # type: ignore
33-
RegisteredNode.outputs_schema: node_data.outputs_schema # type: ignore
33+
RegisteredNode.outputs_schema: node_data.outputs_schema, # type: ignore
34+
RegisteredNode.secrets: node_data.secrets # type: ignore
3435
}))
3536
logger.info(f"Updated existing node {node_data.name} in namespace {namespace_name}", x_exosphere_request_id=x_exosphere_request_id)
3637

@@ -42,7 +43,8 @@ async def register_nodes(namespace_name: str, body: RegisterNodesRequestModel, x
4243
runtime_name=body.runtime_name,
4344
runtime_namespace=namespace_name,
4445
inputs_schema=node_data.inputs_schema,
45-
outputs_schema=node_data.outputs_schema
46+
outputs_schema=node_data.outputs_schema,
47+
secrets=node_data.secrets
4648
)
4749
await new_node.insert()
4850
logger.info(f"Created new node {node_data.name} in namespace {namespace_name}", x_exosphere_request_id=x_exosphere_request_id)
@@ -51,7 +53,8 @@ async def register_nodes(namespace_name: str, body: RegisterNodesRequestModel, x
5153
RegisteredNodeModel(
5254
name=node_data.name,
5355
inputs_schema=node_data.inputs_schema,
54-
outputs_schema=node_data.outputs_schema
56+
outputs_schema=node_data.outputs_schema,
57+
secrets=node_data.secrets
5558
)
5659
)
5760

state-manager/app/models/db/registered_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ class RegisteredNode(BaseDatabaseModel):
99
runtime_name: str = Field(..., description="Name of the runtime that registered this node")
1010
runtime_namespace: str = Field(..., description="Namespace of the runtime that registered this node")
1111
inputs_schema: dict[str, Any] = Field(..., description="JSON schema for node inputs")
12-
outputs_schema: dict[str, Any] = Field(..., description="JSON schema for node outputs")
12+
outputs_schema: dict[str, Any] = Field(..., description="JSON schema for node outputs")
13+
secrets: list[str] = Field(..., description="List of secrets that the node uses")

state-manager/app/models/register_nodes_request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ class NodeRegistrationModel(BaseModel):
66
name: str = Field(..., description="Unique name of the node")
77
inputs_schema: dict[str, Any] = Field(..., description="JSON schema for node inputs")
88
outputs_schema: dict[str, Any] = Field(..., description="JSON schema for node outputs")
9+
secrets: List[str] = Field(..., description="List of secrets that the node uses")
910

1011

1112
class RegisterNodesRequestModel(BaseModel):
1213
runtime_name: str = Field(..., description="Name of the runtime registering the nodes")
13-
nodes: List[NodeRegistrationModel] = Field(..., description="List of nodes to register")
14+
nodes: List[NodeRegistrationModel] = Field(..., description="List of nodes to register")

state-manager/app/models/register_nodes_response.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class RegisteredNodeModel(BaseModel):
66
name: str = Field(..., description="Name of the registered node")
77
inputs_schema: dict[str, Any] = Field(..., description="Inputs for the registered node")
88
outputs_schema: dict[str, Any] = Field(..., description="Outputs for the registered node")
9+
secrets: List[str] = Field(..., description="List of secrets that the node uses")
910

1011

1112
class RegisterNodesResponseModel(BaseModel):

0 commit comments

Comments
 (0)