Skip to content

Commit faa14aa

Browse files
committed
Python: Allow configuration of storage thresholds.
Signed-off-by: Pascal Spörri <[email protected]>
1 parent e1a433e commit faa14aa

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/python/geds_smart_open/src/geds_smart_open/geds.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,15 @@ def init_geds(cls):
225225
if BLOCK_SIZE is not None:
226226
config.cache_block_size = int(BLOCK_SIZE)
227227

228-
# Init GEDS
228+
GEDS_AVAILABLE_STORAGE = os.environ.get("GEDS_AVAILABLE_STORAGE")
229+
if GEDS_AVAILABLE_STORAGE is not None:
230+
config.available_local_storage = int(GEDS_AVAILABLE_STORAGE)
231+
232+
GEDS_AVAILABLE_MEMORY = os.environ.get("GEDS_AVAILABLE_MEMORY")
233+
if GEDS_AVAILABLE_MEMORY is not None:
234+
config.available_local_memory = int(GEDS_AVAILABLE_MEMORY)
229235

236+
# Init GEDS
230237
cls._geds = pygeds.GEDS(config)
231238
try:
232239
cls._geds.start()
@@ -266,10 +273,12 @@ def register_object_store(
266273
def object_store_mapped(cls, bucket: str) -> bool:
267274
return bucket in cls._known_s3_buckets
268275

276+
269277
@atexit.register
270278
def handle_shutdown():
271279
GEDSInstance.handle_shutdown()
272280

281+
273282
def register_object_store(
274283
bucket: str, endpoint_url: str, access_key: str, secret_key: str
275284
):

src/python/wrapper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ PYBIND11_MODULE(pygeds, m) {
4545
.def_readwrite("port_http_server", &GEDSConfig::portHttpServer)
4646
.def_readwrite("local_storage_path", &GEDSConfig::localStoragePath)
4747
.def_readwrite("cache_block_size", &GEDSConfig::cacheBlockSize)
48-
.def_readwrite("cache_objects_from_s3", &GEDSConfig::cache_objects_from_s3);
48+
.def_readwrite("cache_objects_from_s3", &GEDSConfig::cache_objects_from_s3)
49+
.def_readwrite("available_local_storage", &GEDSConfig::available_local_storage)
50+
.def_readwrite("available_local_memory", &GEDSConfig::available_local_memory);
4951

5052
py::class_<GEDS, std::shared_ptr<GEDS>>(m, "GEDS")
5153
.def_property_readonly_static(

0 commit comments

Comments
 (0)