Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/sddb/_catalog_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
"n_members_total": "Int64",
"size_bytes": "Int64",
"members": "list[string]",
"abstract": "string",
"abstract_license": "string",
"abstract_source": "string",
"study_title": "string",
"study_authors": "string",
"study_year": "string",
"study_journal": "string",
}
COLLECTION_REQUIRED: tuple[str, ...] = ("slug", "name", "members")

Expand Down
5 changes: 3 additions & 2 deletions tests/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ def make_fixture_collections() -> pd.DataFrame:
"""Build a valid synthetic collections table (one row per collection)."""
rows = [
("c-smith", "Smith2023", "Smith 2023 atlas", "publication", "EpCAM atlas",
"10.1/smith", "DOI", "Xenium", "human", "lung", 2, 2, 180_000, ["uid0001", "uid0002"]),
"10.1/smith", "DOI", "Xenium", "human", "lung", 2, 2, 180_000, ["uid0001", "uid0002"],
*[None] * 7), # abstract/study_* columns are optional: null here
("c-lee", "Lee2022", "Lee 2022 brain", "replicates", None, None, None,
"Visium", "mouse", "brain", 1, 1, 4_000, ["uid0003"]),
"Visium", "mouse", "brain", 1, 1, 4_000, ["uid0003"], *[None] * 7),
]
df = pd.DataFrame(rows, columns=list(COLLECTION_COLUMNS))
return cast_scalars(df, COLLECTION_COLUMNS)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_catalog_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,17 @@ def test_new_producer_columns_validate_populated_and_null(tmp_path):
p = tmp_path / "c.parquet"
df.to_parquet(p)
cs.validate(pd.read_parquet(p)) # round-trips


def test_collection_columns_include_study_fields():
import sddb._catalog_schema as cs

expected = {
"abstract", "abstract_license", "abstract_source",
"study_title", "study_authors", "study_year", "study_journal",
}
assert expected <= set(cs.COLLECTION_COLUMNS)
# all are nullable string columns
assert all(cs.COLLECTION_COLUMNS[c] == "string" for c in expected)
# not newly required
assert expected.isdisjoint(set(cs.COLLECTION_REQUIRED))
Loading