Skip to content

Commit d82ca9b

Browse files
committed
[local] Store port information in the cache
1 parent df3a54f commit d82ca9b

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

sebs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,6 @@ def start(benchmark, benchmark_input_size, output, deployments, storage_configur
457457
# Otherwise we want to clean up as much as possible
458458
deployment_client.shutdown_storage = False
459459

460-
deployment_client.config.serialize()
461-
462460
result.serialize(output)
463461
sebs_client.logging.info(f"Save results to {os.path.abspath(output)}")
464462

sebs/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def typename() -> str:
5959

6060
def load_config(self):
6161
with self._lock:
62-
for cloud in ["azure", "aws", "gcp", "openwhisk"]:
62+
for cloud in ["azure", "aws", "gcp", "openwhisk", "local"]:
6363
cloud_config_file = os.path.join(self.cache_dir, "{}.json".format(cloud))
6464
if os.path.exists(cloud_config_file):
6565
self.cached_config[cloud] = json.load(open(cloud_config_file, "r"))
@@ -86,7 +86,7 @@ def unlock(self):
8686

8787
def shutdown(self):
8888
if self.config_updated:
89-
for cloud in ["azure", "aws", "gcp", "openwhisk"]:
89+
for cloud in ["azure", "aws", "gcp", "openwhisk", "local"]:
9090
if cloud in self.cached_config:
9191
cloud_config_file = os.path.join(self.cache_dir, "{}.json".format(cloud))
9292
self.logging.info("Update cached config {}".format(cloud_config_file))

sebs/local/config.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,47 @@ def __init__(self, storage_cfg: Optional[MinioConfig] = None):
3434
def storage_config(self) -> Optional[MinioConfig]:
3535
return self._storage
3636

37-
@property
38-
def path(self) -> str:
39-
return self._path
40-
4137
@property
4238
def allocated_ports(self) -> set:
4339
return self._allocated_ports
4440

4541
def serialize(self) -> dict:
4642
out = {
47-
"allocated_ports": list(self._allocated_ports)
43+
"allocated_ports": list(self._allocated_ports),
44+
"storage": self._storage.serialize()
4845
}
4946
return out
5047

5148
@staticmethod
52-
def initialize(res: Resources, cfg: dict):
53-
pass
49+
def initialize(res: Resources, config: dict):
5450

55-
@staticmethod
56-
def deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) -> Resources:
57-
ret = LocalResources()
58-
ret._path = config["path"]
5951
# Check for new config
6052
if "storage" in config:
61-
ret._storage = MinioConfig.deserialize(config["storage"])
62-
ret.logging.info("Using user-provided configuration of storage for local containers.")
53+
res._storage = MinioConfig.deserialize(config["storage"])
54+
res.logging.info("Using user-provided configuration of storage for local containers.")
6355

6456
if "allocated_ports" in config:
65-
ret._allocated_ports = set(config["allocated_ports"])
57+
res._allocated_ports = set(config["allocated_ports"])
58+
59+
def update_cache(self, cache: Cache):
60+
super().update_cache(cache)
61+
cache.update_config(val=list(self._allocated_ports), keys=["local", "resources", "allocated_ports"])
62+
self._storage.update_cache(["local", "resources", "storage"], cache)
63+
64+
@staticmethod
65+
def deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) -> Resources:
66+
ret = LocalResources()
67+
68+
cached_config = cache.get_config("local")
69+
# Load cached values
70+
if cached_config and "resources" in cached_config:
71+
LocalResources.initialize(ret, cached_config["resources"])
72+
ret.logging_handlers = handlers
73+
ret.logging.info("Using cached resources for Local")
74+
else:
75+
# Check for new config
76+
ret.logging_handlers = handlers
77+
LocalResources.initialize(ret, config)
6678

6779
return ret
6880

@@ -104,13 +116,12 @@ def deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) -> Config
104116
return config_obj
105117

106118
def serialize(self) -> dict:
107-
with open(self.resources.path, "r+") as out:
108-
config = json.load(out)
109-
config["deployment"]["local"].update(self.resources.serialize())
110-
out.seek(0)
111-
out.write(serialize(config))
112-
113-
return {}
119+
out = {
120+
"name": "local",
121+
"region": self._region,
122+
"resources": self._resources.serialize()
123+
}
124+
return out
114125

115126
def update_cache(self, cache: Cache):
116-
pass
127+
self.resources.update_cache(cache)

sebs/local/local.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ def get_storage(self, replace_existing: bool = False) -> PersistentStorage:
103103
self.storage.replace_existing = replace_existing
104104
return self.storage
105105

106-
"""
107-
Shut down minio storage instance.
108-
"""
109-
110106
def shutdown(self):
111-
pass
107+
super().shutdown()
112108

113109
"""
114110
It would be sufficient to just pack the code and ship it as zip to AWS.

0 commit comments

Comments
 (0)