Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 68b7d33

Browse files
committedJul 2, 2024
fix
Signed-off-by: Abhishek Kumar <abhishek22512@gmail.com>
1 parent fca8fa2 commit 68b7d33

File tree

6 files changed

+248
-424
lines changed

6 files changed

+248
-424
lines changed
 

‎config/systems.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@
252252
"handler.py",
253253
"storage.py"
254254
],
255-
"packages": []
255+
"packages": {
256+
"parliament-functions": "0.1.0"
257+
}
256258
}
257259
},
258260
"nodejs": {

‎sebs/knative/config.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
from typing import cast, Optional
77

88

9-
class KnativeCredentials(Credentials):
10-
@staticmethod
11-
def deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) -> Credentials:
12-
return KnativeCredentials()
13-
14-
def serialize(self) -> dict:
15-
return {}
16-
17-
189
class KnativeResources(Resources):
1910
def __init__(
2011
self,
@@ -164,24 +155,14 @@ def serialize(self) -> dict:
164155

165156
class KnativeConfig(Config):
166157
name: str
167-
shutdownStorage: bool
168158
cache: Cache
169159

170160
def __init__(self, config: dict, cache: Cache):
171161
super().__init__(name="knative")
172-
self._credentials = KnativeCredentials()
173162
self._resources = KnativeResources()
174-
self.shutdownStorage = config["shutdownStorage"]
175-
self.removeCluster = config["removeCluster"]
176163
self.knative_exec = config["knativeExec"]
177-
self.knative_bypass_security = config["knativeBypassSecurity"]
178-
self.experimentalManifest = config["experimentalManifest"]
179164
self.cache = cache
180165

181-
@property
182-
def credentials(self) -> KnativeCredentials:
183-
return self._credentials
184-
185166
@property
186167
def resources(self) -> KnativeResources:
187168
return self._resources
@@ -194,12 +175,7 @@ def serialize(self) -> dict:
194175
return {
195176
"name": self._name,
196177
"region": self._region,
197-
"shutdownStorage": self.shutdownStorage,
198-
"removeCluster": self.removeCluster,
199178
"knativeExec": self.knative_exec,
200-
"knativeBypassSecurity": self.knative_bypass_security,
201-
"experimentalManifest": self.experimentalManifest,
202-
"credentials": self._credentials.serialize(),
203179
"resources": self._resources.serialize(),
204180
}
205181

@@ -216,11 +192,5 @@ def deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) -> Config
216192
return res
217193

218194
def update_cache(self, cache: Cache):
219-
cache.update_config(val=self.shutdownStorage, keys=["knative", "shutdownStorage"])
220-
cache.update_config(val=self.removeCluster, keys=["knative", "removeCluster"])
221195
cache.update_config(val=self.knative_exec, keys=["knative", "knativeExec"])
222-
cache.update_config(val=self.knative_bypass_security, keys=["knative", "knativeBypassSecurity"])
223-
cache.update_config(
224-
val=self.experimentalManifest, keys=["knative", "experimentalManifest"]
225-
)
226196
self.resources.update_cache(cache)

‎sebs/knative/function.py

Lines changed: 6 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,142 +6,61 @@
66
from sebs.benchmark import Benchmark
77
from sebs.faas.function import Function, FunctionConfig, Runtime
88
from sebs.storage.config import MinioConfig
9-
from sebs.knative.trigger import LibraryTrigger, HTTPTrigger
10-
119

1210
@dataclass
1311
class KnativeFunctionConfig(FunctionConfig):
14-
"""
15-
Configuration class for Knative function specific configurations.
16-
17-
Attributes:
18-
docker_image (str): Docker image for the function.
19-
namespace (str): Kubernetes namespace where the function is deployed (default is 'default').
20-
storage (Optional[MinioConfig]): Optional MinioConfig object for storage configuration.
21-
"""
22-
2312
docker_image: str = ""
2413
namespace: str = "default"
2514
storage: Optional[MinioConfig] = None
15+
url: str = ""
2616

2717
@staticmethod
2818
def deserialize(data: dict) -> KnativeFunctionConfig:
29-
"""
30-
Deserialize data from dictionary into KnativeFunctionConfig object.
31-
32-
Args:
33-
data (dict): Dictionary containing serialized data.
34-
35-
Returns:
36-
KnativeFunctionConfig: Deserialized KnativeFunctionConfig object.
37-
"""
3819
keys = list(KnativeFunctionConfig.__dataclass_fields__.keys())
3920
data = {k: v for k, v in data.items() if k in keys}
4021
data["runtime"] = Runtime.deserialize(data["runtime"])
41-
if "storage" in data:
42-
data["storage"] = MinioConfig.deserialize(data["storage"])
22+
data["storage"] = MinioConfig.deserialize(data["storage"])
4323
return KnativeFunctionConfig(**data)
4424

4525
def serialize(self) -> dict:
46-
"""
47-
Serialize KnativeFunctionConfig object into dictionary.
48-
49-
Returns:
50-
dict: Dictionary containing serialized data.
51-
"""
5226
return self.__dict__
5327

5428
@staticmethod
5529
def from_benchmark(benchmark: Benchmark) -> KnativeFunctionConfig:
56-
"""
57-
Create KnativeFunctionConfig object from a benchmark.
58-
59-
Args:
60-
benchmark (Benchmark): Benchmark object.
61-
62-
Returns:
63-
KnativeFunctionConfig: Initialized KnativeFunctionConfig object.
64-
"""
6530
return super(KnativeFunctionConfig, KnativeFunctionConfig)._from_benchmark(
6631
benchmark, KnativeFunctionConfig
6732
)
6833

69-
7034
class KnativeFunction(Function):
71-
"""
72-
Class representing a Knative function.
73-
74-
Attributes:
75-
name (str): Name of the function.
76-
benchmark (str): Benchmark associated with the function.
77-
code_package_hash (str): Hash of the code package associated with the function.
78-
cfg (KnativeFunctionConfig): Configuration object for the function.
79-
"""
80-
8135
def __init__(
8236
self, name: str, benchmark: str, code_package_hash: str, cfg: KnativeFunctionConfig
8337
):
84-
"""
85-
Initialize KnativeFunction object.
86-
87-
Args:
88-
name (str): Name of the function.
89-
benchmark (str): Benchmark associated with the function.
90-
code_package_hash (str): Hash of the code package associated with the function.
91-
cfg (KnativeFunctionConfig): Configuration object for the function.
92-
"""
9338
super().__init__(benchmark, name, code_package_hash, cfg)
9439

9540
@property
9641
def config(self) -> KnativeFunctionConfig:
97-
"""
98-
Get the configuration object of the function.
99-
100-
Returns:
101-
KnativeFunctionConfig: Configuration object of the function.
102-
"""
10342
return cast(KnativeFunctionConfig, self._cfg)
10443

10544
@staticmethod
10645
def typename() -> str:
107-
"""
108-
Return the typename of the KnativeFunction class.
109-
110-
Returns:
111-
str: Typename of the KnativeFunction class.
112-
"""
11346
return "Knative.Function"
11447

11548
def serialize(self) -> dict:
116-
"""
117-
Serialize KnativeFunction object into dictionary.
118-
119-
Returns:
120-
dict: Dictionary containing serialized data.
121-
"""
122-
serialized_data = super().serialize()
123-
serialized_data["config"] = self._cfg.serialize()
124-
return serialized_data
49+
return {**super().serialize(), "config": self._cfg.serialize()}
12550

12651
@staticmethod
12752
def deserialize(cached_config: dict) -> KnativeFunction:
128-
"""
129-
Deserialize dictionary into KnativeFunction object.
130-
131-
Args:
132-
cached_config (dict): Dictionary containing serialized data.
53+
from sebs.faas.function import Trigger
54+
from sebs.knative.triggers import KnativeLibraryTrigger, KnativeHTTPTrigger
13355

134-
Returns:
135-
KnativeFunction: Deserialized KnativeFunction object.
136-
"""
13756
cfg = KnativeFunctionConfig.deserialize(cached_config["config"])
13857
ret = KnativeFunction(
13958
cached_config["name"], cached_config["benchmark"], cached_config["hash"], cfg
14059
)
14160
for trigger in cached_config["triggers"]:
14261
trigger_type = cast(
14362
Trigger,
144-
{"Library": LibraryTrigger, "HTTP": HTTPTrigger}.get(trigger["type"]),
63+
{"Library": KnativeLibraryTrigger, "HTTP": KnativeHTTPTrigger}.get(trigger["type"]),
14564
)
14665
assert trigger_type, "Unknown trigger type {}".format(trigger["type"])
14766
ret.add_trigger(trigger_type.deserialize(trigger))

0 commit comments

Comments
 (0)
Please sign in to comment.