-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SaturnDynamicTopology that allows to dynamic topology generation …
…from python code
- Loading branch information
Mathieu Gascon-Lefebvre
committed
Jul 30, 2024
1 parent
b731f12
commit c699010
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/saturn_engine/worker_manager/config/declarative_dynamic_topology.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import typing as t | ||
|
||
import dataclasses | ||
|
||
from saturn_engine.utils import inspect as extra_inspect | ||
from saturn_engine.utils.declarative_config import BaseObject | ||
from saturn_engine.worker_manager.config.static_definitions import StaticDefinitions | ||
|
||
|
||
@dataclasses.dataclass | ||
class DynamicTopologySpec: | ||
module: str | ||
|
||
|
||
@dataclasses.dataclass | ||
class DynamicTopology(BaseObject): | ||
spec: DynamicTopologySpec | ||
|
||
def to_static_definitions(self) -> StaticDefinitions: | ||
return t.cast( | ||
t.Callable[[], StaticDefinitions], | ||
extra_inspect.import_name(self.spec.module), | ||
)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from saturn_engine.utils.declarative_config import ObjectMetadata | ||
from saturn_engine.worker_manager.config.declarative_inventory import Inventory | ||
from saturn_engine.worker_manager.config.declarative_inventory import InventorySpec | ||
from saturn_engine.worker_manager.config.static_definitions import StaticDefinitions | ||
|
||
|
||
def build() -> StaticDefinitions: | ||
return StaticDefinitions( | ||
inventories={ | ||
"test-inventory": Inventory( | ||
metadata=ObjectMetadata(name="test-inventory"), | ||
apiVersion="saturn.flared.io/v1alpha1", | ||
kind="SaturnInventory", | ||
spec=InventorySpec(type="testtype"), | ||
).to_core_object() | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters