Skip to content

Commit 53f1dca

Browse files
authored
Rename cleanup_temp_tables to cleanup_tables in warehouse and catalog (#218)
1 parent 2ca19a4 commit 53f1dca

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

src/datachain/catalog/catalog.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,16 +1217,14 @@ def remove_dataset_version(
12171217
def get_temp_table_names(self) -> list[str]:
12181218
return self.warehouse.get_temp_table_names()
12191219

1220-
def cleanup_temp_tables(self, names: Iterable[str]) -> None:
1220+
def cleanup_tables(self, names: Iterable[str]) -> None:
12211221
"""
1222-
Drop tables created temporarily when processing datasets.
1222+
Drop tables passed.
12231223
1224-
This should be implemented even if temporary tables are used to
1225-
ensure that they are cleaned up as soon as they are no longer
1226-
needed. When running the same `DatasetQuery` multiple times we
1227-
may use the same temporary table names.
1224+
This should be implemented to ensure that the provided tables
1225+
are cleaned up as soon as they are no longer needed.
12281226
"""
1229-
self.warehouse.cleanup_temp_tables(names)
1227+
self.warehouse.cleanup_tables(names)
12301228
self.id_generator.delete_uris(names)
12311229

12321230
def create_dataset_from_sources(

src/datachain/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ def garbage_collect(catalog: "Catalog"):
910910
print("Nothing to clean up.")
911911
else:
912912
print(f"Garbage collecting {len(temp_tables)} tables.")
913-
catalog.cleanup_temp_tables(temp_tables)
913+
catalog.cleanup_tables(temp_tables)
914914

915915

916916
def completion(shell: str) -> str:

src/datachain/data_storage/metastore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def init(self, uri: StorageURI) -> None:
9797
def close(self) -> None:
9898
"""Closes any active database or HTTP connections."""
9999

100-
def cleanup_temp_tables(self, temp_table_names: list[str]) -> None:
100+
def cleanup_tables(self, temp_table_names: list[str]) -> None:
101101
"""Cleanup temp tables."""
102102

103103
def cleanup_for_tests(self) -> None:
@@ -457,7 +457,7 @@ def close(self) -> None:
457457
"""Closes any active database connections."""
458458
self.db.close()
459459

460-
def cleanup_temp_tables(self, temp_table_names: list[str]) -> None:
460+
def cleanup_tables(self, temp_table_names: list[str]) -> None:
461461
"""Cleanup temp tables."""
462462
self.id_generator.delete_uris(temp_table_names)
463463

src/datachain/data_storage/warehouse.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,14 +915,12 @@ def get_temp_table_names(self) -> list[str]:
915915
if self.is_temp_table_name(t)
916916
]
917917

918-
def cleanup_temp_tables(self, names: Iterable[str]) -> None:
918+
def cleanup_tables(self, names: Iterable[str]) -> None:
919919
"""
920-
Drop tables created temporarily when processing datasets.
920+
Drop tables passed.
921921
922-
This should be implemented even if temporary tables are used to
923-
ensure that they are cleaned up as soon as they are no longer
924-
needed. When running the same `DatasetQuery` multiple times we
925-
may use the same temporary table names.
922+
This should be implemented to ensure that the provided tables
923+
are cleaned up as soon as they are no longer needed.
926924
"""
927925
for name in names:
928926
self.db.drop_table(Table(name, self.db.metadata), if_exists=True)

src/datachain/query/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,10 +1201,10 @@ def cleanup(self) -> None:
12011201
# implementations, as errors may close or render unusable the existing
12021202
# connections.
12031203
metastore = self.catalog.metastore.clone(use_new_connection=True)
1204-
metastore.cleanup_temp_tables(self.temp_table_names)
1204+
metastore.cleanup_tables(self.temp_table_names)
12051205
metastore.close()
12061206
warehouse = self.catalog.warehouse.clone(use_new_connection=True)
1207-
warehouse.cleanup_temp_tables(self.temp_table_names)
1207+
warehouse.cleanup_tables(self.temp_table_names)
12081208
warehouse.close()
12091209
self.temp_table_names = []
12101210

tests/func/test_catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ def test_garbage_collect(cloud_test_catalog, from_cli, capsys):
11201120
captured = capsys.readouterr()
11211121
assert captured.out == "Garbage collecting 4 tables.\n"
11221122
else:
1123-
catalog.cleanup_temp_tables(temp_tables)
1123+
catalog.cleanup_tables(temp_tables)
11241124
assert catalog.get_temp_table_names() == []
11251125

11261126

0 commit comments

Comments
 (0)