Skip to content

Commit 650fc81

Browse files
svsgooglecopybara-github
authored andcommitted
Rename SchemaHelper.is_valid_data_slice_path() to SchemaHelper.exists().
This change makes the method name more concise and aligns with the common "exists" terminology used in data management contexts. PiperOrigin-RevId: 856108486 Change-Id: I7bc20cdd210cc931655e4a1dfcbc08b26c26fe3e
1 parent 13427c8 commit 650fc81

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

py/koladata/ext/persisted_data/bare_root_initial_data_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_data_slice_for_schema_node_names(
119119
return self._root_item
120120

121121
def exists(self, path: data_slice_path_lib.DataSlicePath) -> bool:
122-
return self._schema_helper.is_valid_data_slice_path(path)
122+
return self._schema_helper.exists(path)
123123

124124
def get_data_slice(
125125
self,

py/koladata/ext/persisted_data/persisted_incremental_data_slice_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def generate_paths(
463463

464464
def exists(self, path: data_slice_path_lib.DataSlicePath) -> bool:
465465
"""Returns whether the given data slice path exists for this manager."""
466-
return self._schema_helper.is_valid_data_slice_path(path)
466+
return self._schema_helper.exists(path)
467467

468468
def get_data_slice(
469469
self,

py/koladata/ext/persisted_data/persisted_incremental_data_slice_manager_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def is_loaded_data_slice_path(
136136
"""Returns whether the given data slice path is loaded."""
137137
return schema_helper_lib.SchemaHelper(
138138
get_loaded_schema(manager)
139-
).is_valid_data_slice_path(path)
139+
).exists(path)
140140

141141

142142
class PersistedIncrementalDataSliceManagerTest(parameterized.TestCase):

py/koladata/ext/persisted_data/schema_helper.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,7 @@ def generate_available_data_slice_paths(
776776
self._schema, max_depth=max_depth
777777
)
778778

779-
def is_valid_data_slice_path(
780-
self, data_slice_path: data_slice_path_lib.DataSlicePath
781-
) -> bool:
779+
def exists(self, data_slice_path: data_slice_path_lib.DataSlicePath) -> bool:
782780
try:
783781
self.get_schema_node_name_for_data_slice_path(data_slice_path)
784782
return True
@@ -804,12 +802,12 @@ def get_schema_node_names_needed_to(
804802
populate = set(populate or [])
805803
populate_including_descendants = set(populate_including_descendants or [])
806804
for path in populate:
807-
if not self.is_valid_data_slice_path(path):
805+
if not self.exists(path):
808806
raise ValueError(
809807
f"data slice path '{path}' passed in argument 'populate' is invalid"
810808
)
811809
for path in populate_including_descendants:
812-
if not self.is_valid_data_slice_path(path):
810+
if not self.exists(path):
813811
raise ValueError(
814812
f"data slice path '{path}' passed in argument"
815813
" 'populate_including_descendants' is invalid"

py/koladata/ext/persisted_data/schema_helper_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def test_generate_available_data_paths(self):
685685
)
686686

687687
for data_path in helper.generate_available_data_slice_paths(max_depth=7):
688-
self.assertTrue(helper.is_valid_data_slice_path(data_path))
688+
self.assertTrue(helper.exists(data_path))
689689

690690
def test_generate_available_data_paths_for_dict_schema(self):
691691
dict_schema = kd.dict_schema(kd.STRING, kd.STRING)
@@ -700,7 +700,7 @@ def test_generate_available_data_paths_for_dict_schema(self):
700700
)
701701

702702
for data_path in helper.generate_available_data_slice_paths(max_depth=7):
703-
self.assertTrue(helper.is_valid_data_slice_path(data_path))
703+
self.assertTrue(helper.exists(data_path))
704704

705705
def test_get_affected_schema_node_names(self):
706706
root = kd.new()
@@ -947,32 +947,32 @@ def test_schema_helper_is_valid_data_path(self):
947947
helper = schema_helper.SchemaHelper(schema)
948948

949949
self.assertTrue(
950-
helper.is_valid_data_slice_path(DataSlicePath.from_actions([]))
950+
helper.exists(DataSlicePath.from_actions([]))
951951
)
952952
self.assertTrue(
953-
helper.is_valid_data_slice_path(
953+
helper.exists(
954954
DataSlicePath.from_actions([GetAttr('foo')])
955955
)
956956
)
957957
self.assertTrue(
958-
helper.is_valid_data_slice_path(
958+
helper.exists(
959959
DataSlicePath.from_actions([GetAttr('bar')])
960960
)
961961
)
962962
self.assertTrue(
963-
helper.is_valid_data_slice_path(
963+
helper.exists(
964964
DataSlicePath.from_actions([GetAttr('bar'), ListExplode()])
965965
)
966966
)
967967

968968
# These are not valid data slice paths for the schema.
969969
self.assertFalse(
970-
helper.is_valid_data_slice_path(
970+
helper.exists(
971971
DataSlicePath.from_actions([GetAttr('foo'), ListExplode()])
972972
)
973973
)
974974
self.assertFalse(
975-
helper.is_valid_data_slice_path(
975+
helper.exists(
976976
DataSlicePath.from_actions(
977977
[GetAttr('bar'), ListExplode(), DictGetKeys()]
978978
)

py/koladata/ext/persisted_data/simple_in_memory_data_slice_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def generate_paths(
5050
)
5151

5252
def exists(self, path: data_slice_path_lib.DataSlicePath) -> bool:
53-
return self._schema_helper().is_valid_data_slice_path(path)
53+
return self._schema_helper().exists(path)
5454

5555
def get_data_slice(
5656
self,

0 commit comments

Comments
 (0)