Skip to content

Commit

Permalink
Bind the dataframe.create with the timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv committed Apr 3, 2024
1 parent 4243537 commit fc35aba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def create(
plt_cfg.consolidate_and_vacuum = ops.consolidate_and_vacuum

# TODO add as kw args
timestamp_ms = context._open_timestamp_ms(tiledb_timestamp)
clib.SOMADataFrame.create(
uri,
schema,
Expand All @@ -276,6 +277,7 @@ def create(
extents,
context.native_context,
plt_cfg,
(0, timestamp_ms)
)

handle = cls._wrapper_type.open(uri, "w", context, tiledb_timestamp)
Expand Down
6 changes: 4 additions & 2 deletions apis/python/src/tiledbsoma/soma_dataframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void load_soma_dataframe(py::module& m) {
py::object py_domains,
py::object py_extents,
std::shared_ptr<SOMAContext> context,
std::optional<PlatformConfig> platform_config) {
std::optional<PlatformConfig> platform_config,
std::optional<std::pair<uint64_t, uint64_t>> timestamp) {
ArrowSchema schema;
uintptr_t schema_ptr = (uintptr_t)(&schema);
py_schema.attr("_export_to_c")(schema_ptr);
Expand Down Expand Up @@ -96,7 +97,8 @@ void load_soma_dataframe(py::module& m) {
std::make_shared<ArrowArray>(domains),
std::make_shared<ArrowArray>(extents)),
context,
platform_config);
platform_config,
timestamp);
} catch (const std::out_of_range& e) {
throw py::type_error(e.what());
} catch (const std::exception& e) {
Expand Down
3 changes: 2 additions & 1 deletion apis/python/tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def test_issue919(tmp_path):
expt.add_new_dataframe(
"df", schema=schema, index_column_names=["soma_joinid"]
)
assert expt["df"].tiledb_timestamp_ms == 100

with soma.Collection.open(uri, context=context) as c:
assert "df" in c["expt"] and "causes_bug" in c["expt"]
Expand Down Expand Up @@ -518,4 +519,4 @@ def test_context_timestamp(tmp_path: pathlib.Path):
assert coll.tiledb_timestamp_ms == 234
sub_1 = coll["sub_1"]
assert sub_1.tiledb_timestamp_ms == 234
assert sub_1["sub_sub"].tiledb_timestamp_ms == 234
assert sub_1["sub_sub"].tiledb_timestamp_ms == 234

0 comments on commit fc35aba

Please sign in to comment.