Skip to content

Commit 81a5844

Browse files
authored
Small improvements for re-imports (#600)
* Simplify the check for directory contents. * Mandate auto-generated provenance fields. * Don't need to check kwargs
1 parent c24a8e9 commit 81a5844

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/hats/catalog/dataset/table_properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,4 @@ def _estimate_dir_size(target_dir):
366366
properties["hats_estsize"] = int(_estimate_dir_size(path) / 1024) if path else 0
367367
properties["hats_release_date"] = "2025-08-22"
368368
properties["hats_version"] = "v1.0"
369-
return properties | kwargs
369+
return kwargs | properties

src/hats/io/file_io/file_pointer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,5 @@ def directory_has_contents(pointer: str | Path | UPath) -> bool:
152152
True if there are any files or subdirectories below this directory.
153153
"""
154154
pointer = get_upath(pointer)
155-
return len(find_files_matching_path(pointer, "*")) > 0
155+
156+
return next(pointer.rglob("*"), None) is not None

tests/hats/catalog/dataset/test_table_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ def test_provenance_dict(small_sky_dir, tmp_path):
202202
contents = ",".join(load_text_file(tmp_path / "hats.properties"))
203203
assert "\\" not in contents
204204

205-
# Test that we can override a property and add another.
205+
# Test that we can add other properties, but not override auto-generated ones.
206206
properties = TableProperties.new_provenance_dict(
207207
small_sky_dir, builder="lsdb v0.1", hats_estsize=1000, foo="bar"
208208
)
209209
assert properties["hats_builder"] == f"lsdb v0.1, hats v{version('hats')}"
210210
assert properties["hats_creation_date"].startswith("20")
211-
assert properties["hats_estsize"] == 1000
211+
assert properties["hats_estsize"] != 1000
212212
assert properties["hats_release_date"].startswith("20")
213213
assert properties["hats_version"].startswith("v")
214214
assert properties["foo"] == "bar"

0 commit comments

Comments
 (0)