Skip to content

Commit ca79618

Browse files
authored
Remove unnecessary crawler API: Mounts.inventorize_mounts() (#2535)
## Changes This PR removes the `Mounts.inventorize_mounts()` method; it was only used by unit tests that could use the `.snapshot()` API instead. This was noted as part of #2404, and is part of general cleanup of patterns we use for the crawlers: https://github.com/databrickslabs/ucx/blob/68ecb02df0f02fcef1b5dc44a8421ccf480431c6/src/databricks/labs/ucx/hive_metastore/locations.py#L240 ### Linked issues Relates to #2404. ### Tests - updated unit tests
1 parent f7d793d commit ca79618

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/databricks/labs/ucx/hive_metastore/locations.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ def _deduplicate_mounts(self, mounts: list) -> list:
320320
deduplicated_mounts.append(obj)
321321
return deduplicated_mounts
322322

323-
def inventorize_mounts(self):
324-
self._append_records(self._list_mounts())
325-
326323
def _list_mounts(self) -> Iterable[Mount]:
327324
mounts = []
328325
for mount_point, source, _ in self._dbutils.fs.mounts():

tests/unit/hive_metastore/test_locations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_location_trie_tables():
7575
assert c_node.tables == tables
7676

7777

78-
def test_list_mounts_should_return_a_list_of_mount_without_encryption_type():
78+
def test_mounts_inventory_should_contain_mounts_without_encryption_type():
7979
client = create_autospec(WorkspaceClient)
8080
client.dbutils.fs.mounts.return_value = [
8181
MountInfo("mp_1", "path_1", "info_1"),
@@ -86,7 +86,7 @@ def test_list_mounts_should_return_a_list_of_mount_without_encryption_type():
8686
backend = MockBackend()
8787
instance = Mounts(backend, client, "test")
8888

89-
instance.inventorize_mounts()
89+
instance.snapshot()
9090

9191
assert [
9292
Row(name="mp_1", source="path_1"),
@@ -95,7 +95,7 @@ def test_list_mounts_should_return_a_list_of_mount_without_encryption_type():
9595
] == backend.rows_written_for("hive_metastore.test.mounts", "append")
9696

9797

98-
def test_list_mounts_should_return_a_deduped_list_of_mount_without_encryption_type():
98+
def test_mounts_inventory_should_contain_deduped_mounts_without_encryption_type():
9999
client = create_autospec(WorkspaceClient)
100100
client.dbutils.fs.mounts.return_value = [
101101
MountInfo("mp_1", "path_1", "info_1"),
@@ -106,15 +106,15 @@ def test_list_mounts_should_return_a_deduped_list_of_mount_without_encryption_ty
106106
backend = MockBackend()
107107
instance = Mounts(backend, client, "test")
108108

109-
instance.inventorize_mounts()
109+
instance.snapshot()
110110

111111
assert [
112112
Row(name="mp_1", source="path_1"),
113113
Row(name="mp_2", source="path_2"),
114114
] == backend.rows_written_for("hive_metastore.test.mounts", "append")
115115

116116

117-
def test_list_mounts_should_return_a_deduped_list_of_mount_without_variable_volume_names():
117+
def test_mounts_inventory_should_contain_deduped_mounts_without_variable_volume_names():
118118
client = create_autospec(WorkspaceClient)
119119
client.dbutils.fs.mounts.return_value = [
120120
MountInfo("/Volume", "DbfsReserved", "info_1"),
@@ -129,7 +129,7 @@ def test_list_mounts_should_return_a_deduped_list_of_mount_without_variable_volu
129129
backend = MockBackend()
130130
instance = Mounts(backend, client, "test")
131131

132-
instance.inventorize_mounts()
132+
instance.snapshot()
133133

134134
expected = [
135135
Row(name="/Volume", source="DbfsReserved"),

0 commit comments

Comments
 (0)