-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_models.py
More file actions
31 lines (26 loc) · 768 Bytes
/
Copy pathtest_models.py
File metadata and controls
31 lines (26 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from orchestration.models import (
ServiceDefinition,
ServiceDefinitionProfile,
ServiceDefinitionVariety,
)
p1 = ServiceDefinitionProfile(name="p1", description="desc1")
v1 = ServiceDefinitionVariety(image="image1")
sd = ServiceDefinition(
service_name="myservice",
type="container",
profiles={"p1": p1},
varieties={"v1": v1},
)
print("As dict:")
sd_dict = sd.model_dump()
print(sd_dict)
print("\nProfiles type:", type(sd_dict["profiles"]))
print("Varieties type:", type(sd_dict["varieties"]))
profiles = sd_dict.get("profiles", [])
print("\nIterating profiles:")
for p in profiles:
print(f"p: {p}, type: {type(p)}")
try:
print(f"p.get('name'): {p.get('name')}")
except Exception as e:
print(f"Error: {e}")