Skip to content

Commit f690b1f

Browse files
Georgi RusevGeorgi Rusev
Georgi Rusev
authored and
Georgi Rusev
committed
addressed comments
1 parent 2ca6f0a commit f690b1f

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

python/arcticdb/util/environment_setup.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -331,19 +331,37 @@ def get_library(self, library_suffix: Union[str, int] = None) -> Library:
331331
Returns a library on persistent space. (created if do not exist)
332332
The name is constructed internally, but user can add a suffix (index)
333333
Uses `get_library_name` to construct the name
334+
335+
IMPORTANT: `get_library` will always return Library even if none exist will be created new!
334336
"""
335337
return self._get_lib(self.get_arctic_client_persistent(),
336338
self.get_library_name(LibraryType.PERSISTENT, library_suffix))
337-
339+
340+
def has_library(self, library_suffix: Union[str, int] = None) -> bool:
341+
"""
342+
checks if there is a library with that suffix on persistent storage space
343+
"""
344+
return self.get_arctic_client_persistent().has_library(self.get_library_name(LibraryType.PERSISTENT,
345+
library_suffix))
346+
338347
def get_modifiable_library(self, library_suffix: Union[str, int] = None) -> Library:
339348
"""
340349
Returns library to read write and delete after done. (create if not exist is on!)
341350
The name is constructed internally, but user can add a suffix (index)
342351
Uses `get_library_name` to construct the name
352+
353+
IMPORTANT: `get_modifiable_library` will always return Library even if none exist will be created new!
343354
"""
344355
return self._get_lib(self.get_arctic_client_modifiable(),
345356
self.get_library_name(LibraryType.MODIFIABLE, library_suffix))
346357

358+
def has_modifiable_library(self, library_suffix: Union[str, int] = None) -> bool:
359+
"""
360+
checks if there is a library with that suffix on persistent storage space
361+
"""
362+
return self.get_arctic_client_persistent().has_library(self.get_library_name(LibraryType.MODIFIABLE,
363+
library_suffix))
364+
347365
def delete_modifiable_library(self, library_suffix: Union[str, int] = None):
348366
"""
349367
Use this method to delete previously created library on modifiable storage
@@ -532,6 +550,8 @@ def check_ok(self):
532550
if OK, setting things up can be skipped
533551
"""
534552
(list_rows, list_cols) = self._get_symbol_bounds()
553+
if not self.has_library():
554+
return False
535555
lib = self.get_library()
536556
symbols = set(lib.list_symbols())
537557
self.logger().info(f"Symbols {symbols}")
@@ -664,6 +684,8 @@ def setup_all(self):
664684
def check_ok(self) -> bool:
665685

666686
for num_symbols in self.get_parameter_list():
687+
if not self.has_library(num_symbols):
688+
return False
667689
lib = self.get_library(num_symbols)
668690
symbols = set(lib.list_symbols())
669691
self.logger().info(f"Check library: {lib}")
@@ -995,6 +1017,8 @@ def check_ok(self):
9951017
(list_rows, list_cols) = self._get_symbol_bounds()
9961018

9971019
for num_symbols in self._params[self.param_index_num_symbols]:
1020+
if not self.has_library(num_symbols):
1021+
return False
9981022
lib = self.get_library(num_symbols)
9991023
self.logger().debug(f"Library {lib}")
10001024
for num_symbol in range(num_symbols):
@@ -1089,6 +1113,7 @@ def test_setup_versions_and_snapshots(cls):
10891113
#Delete-setup-all-check
10901114
cls.delete_test_store(setup)
10911115
setup.setup_environment()
1116+
setup.logger().info(setup.get_arctic_client_persistent().list_libraries())
10921117
assert setup.check_ok()
10931118

10941119
#Changing parameters should trigger not ok for setup

python/arcticdb/util/utils.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,17 @@ def generate_random_float_dataframe(cls, start_name_prefix: str, num_rows: int,
609609

610610
@classmethod
611611
def generate_random_strings_dataframe(cls, start_name_prefix: str, num_rows: int, num_cols: int,
612-
column_sizes=None, seed: int = 4543):
612+
string_sizes: List[int] = None, seed: int = 4543):
613613
"""
614614
To be used to generate large number of same type columns, when generation time is
615615
critical
616-
If `column_sizes` not supplied default 10 will be used
616+
If `string_sizes` not supplied default 10 will be used for all columns as size of strings,
617+
otherwise the list will indicate for each string column what string size to be generated
617618
"""
618-
if column_sizes is None:
619-
column_sizes = [10] * num_cols
619+
if string_sizes is None:
620+
string_sizes = [10] * num_cols
620621
np.random.seed(seed=seed)
621-
data = [[random_string(column_sizes[col])
622+
data = [[random_string(string_sizes[col])
622623
for col in range(num_cols)]
623624
for _ in range(num_rows)]
624625

0 commit comments

Comments
 (0)