Created
October 11, 2022 22:22
-
-
Save johnkerl/f93ad47c4bfa29fbb929f4e2d3cd83f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu@ip-172-31-20-78[prod][kerl/lib-sdf][python]$ ttsv tests/test_soma_dataframe.py | |
============================================================= test session starts ============================================================= | |
platform linux -- Python 3.10.4, pytest-7.1.3, pluggy-1.0.0 -- /usr/bin/python | |
cachedir: .pytest_cache | |
rootdir: /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python | |
plugins: typeguard-2.13.3 | |
collected 19 items | |
tests/test_soma_dataframe.py::test_soma_dataframe_non_indexed FAILED [ 5%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names0-None] PASSED [ 10%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names0-ids1] PASSED [ 15%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names0-ids2] PASSED [ 21%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names1-None] PASSED [ 26%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names1-ids1] PASSED [ 31%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names1-ids2] PASSED [ 36%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names2-None] PASSED [ 42%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names2-ids1] PASSED [ 47%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names2-ids2] PASSED [ 52%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names3-None] PASSED [ 57%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names3-ids1] PASSED [ 63%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names3-ids2] PASSED [ 68%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names4-None] PASSED [ 73%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names4-ids1] PASSED [ 78%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[col_names4-ids2] PASSED [ 84%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[None-None] PASSED [ 89%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[None-ids1] PASSED [ 94%] | |
tests/test_soma_dataframe.py::test_SOMADataFrame_read_column_names[None-ids2] PASSED [100%] | |
================================================================== FAILURES =================================================================== | |
_______________________________________________________ test_soma_dataframe_non_indexed _______________________________________________________ | |
tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-48/test_soma_dataframe_non_indexe0') | |
def test_soma_dataframe_non_indexed(tmp_path): | |
sdf = t.SOMADataFrame(uri=tmp_path.as_posix()) | |
# Create | |
asch = pa.schema( | |
[ | |
("foo", pa.int32()), | |
("bar", pa.float64()), | |
("baz", pa.large_string()), | |
] | |
) | |
sdf.create(schema=asch) | |
# ---------------------------------------------------------------- | |
# Write | |
for _i in range(3): | |
pydict = {} | |
pydict["soma_rowid"] = [0, 1, 2, 3, 4] | |
pydict["foo"] = [10, 20, 30, 40, 50] | |
pydict["bar"] = [4.1, 5.2, 6.3, 7.4, 8.5] | |
pydict["baz"] = ["apple", "ball", "cat", "dog", "egg"] | |
rb = pa.Table.from_pydict(pydict) | |
sdf.write(rb) | |
# ---------------------------------------------------------------- | |
# Read all | |
table = sdf.read_all() | |
assert table.num_rows == 5 | |
# We should be getting back the soma_rowid column as well | |
# If sparse dataframe: | |
assert table.num_columns == 4 | |
# If dense dataframe: | |
# assert table.num_columns == 3 | |
# TODO assert [e.as_py() for e in list(table['soma_rowid'])] == [0,1,2,3,4] | |
assert [e.as_py() for e in list(table["foo"])] == pydict["foo"] | |
assert [e.as_py() for e in list(table["bar"])] == pydict["bar"] | |
assert [e.as_py() for e in list(table["baz"])] == pydict["baz"] | |
# ---------------------------------------------------------------- | |
# Read by ids | |
table = sdf.read_all(ids=[1, 2]) | |
assert table.num_rows == 2 | |
# We should be getting back the soma_rowid column as well | |
# If sparse dataframe: | |
assert table.num_columns == 4 | |
# If dense dataframe: | |
# assert table.num_columns == 3 | |
# TODO assert [e.as_py() for e in list(table['soma_rowid'])] == [0,1,2,3,4] | |
assert sorted([e.as_py() for e in list(table["foo"])]) == [20, 30] | |
assert sorted([e.as_py() for e in list(table["bar"])]) == [5.2, 6.3] | |
assert sorted([e.as_py() for e in list(table["baz"])]) == ["ball", "cat"] | |
# ---------------------------------------------------------------- | |
# Read by ids | |
table = sdf.read_all(ids=slice(1, 2)) | |
assert table.num_rows == 2 | |
# We should be getting back the soma_rowid column as well | |
# If sparse dataframe: | |
assert table.num_columns == 4 | |
# If dense dataframe: | |
# assert table.num_columns == 3 | |
# TODO assert [e.as_py() for e in list(table['soma_rowid'])] == [0,1,2,3,4] | |
assert sorted([e.as_py() for e in list(table["foo"])]) == [20, 30] | |
assert sorted([e.as_py() for e in list(table["bar"])]) == [5.2, 6.3] | |
assert sorted([e.as_py() for e in list(table["baz"])]) == ["ball", "cat"] | |
# ---------------------------------------------------------------- | |
# Read by value_filter | |
> table = sdf.read_all(value_filter="foo == 40 or foo == 20") | |
tests/test_soma_dataframe.py:82: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py:1033: in wrapper | |
retval = func(*args, **kwargs) | |
src/tiledbsoma/soma_dataframe.py:234: in read_all | |
return pa.concat_tables( | |
pyarrow/table.pxi:5139: in pyarrow.lib.concat_tables | |
??? | |
/home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py:897: in __next__ | |
return self.send(None) | |
/home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py:915: in send | |
value = self.__wrapped.send(obj) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = SOMADataFrame(uri="/tmp/pytest-of-ubuntu/pytest-48/test_soma_dataframe_non_indexe0") | |
def read( | |
self, | |
*, | |
# TODO: find the right syntax to get the typechecker to accept args like ``ids=slice(0,10)`` | |
# ids: Optional[Union[Sequence[int], Slice]] = None, | |
ids: Optional[Any] = None, | |
value_filter: Optional[str] = None, | |
column_names: Optional[Sequence[str]] = None, | |
result_order: Optional[SOMAResultOrder] = None, | |
# TODO: batch_size | |
# TODO: partition, | |
# TODO: platform_config, | |
) -> Iterator[pa.Table]: | |
""" | |
Read a user-defined subset of data, addressed by the dataframe indexing column, optionally filtered, and return results as one or more ``Arrow.Table``. | |
:param ids: Which rows to read. Defaults to ``None``, meaning no constraint -- all rows. | |
:param column_names: the named columns to read and return. Defaults to ``None``, meaning no constraint -- all column names. | |
:param partitions: an optional ``SOMAReadPartitions`` hint to indicate how results should be organized. | |
:param result_order: order of read results. This can be one of 'row-major', 'col-major', or 'unordered'. | |
:param value_filter: an optional [value filter] to apply to the results. Defaults to no filter. | |
**Indexing**: the ``ids`` parameter will support, per dimension: a row offset (uint), a row-offset range (slice), or a list of both. | |
""" | |
with self._tiledb_open("r") as A: | |
dim_names, attr_names = util_tiledb.split_column_names( | |
A.schema, column_names | |
) | |
query_condition = None | |
if value_filter is not None: | |
# query_condition = tiledb.QueryCondition(value_filter) | |
query_condition = QueryCondition(value_filter) | |
# As an arg to this method, `column_names` is optional-None. For the pybind11 | |
# code it's optional-[]. | |
lib_column_names = [] if column_names is None else column_names | |
> sr = clib.SOMAReader( | |
self._uri, | |
name=self.__class__.__name__, | |
schema=A.schema, # query_condition needs this | |
column_names=lib_column_names, | |
query_condition=query_condition, | |
) | |
E RuntimeError: TypeError: type of argument "node" must be a type; got ast.Compare instead | |
E | |
E At: | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(875): check_argument_types | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(1032): wrapper | |
E /usr/lib/python3.10/ast.py(410): visit | |
E /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/query_condition.py(415): visit_BoolOp | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(1033): wrapper | |
E /usr/lib/python3.10/ast.py(410): visit | |
E /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/query_condition.py(135): init_query_condition | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(1033): wrapper | |
E /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/soma_dataframe.py(193): read | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(915): send | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(897): __next__ | |
E /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python/src/tiledbsoma/soma_dataframe.py(234): read_all | |
E /home/ubuntu/.local/lib/python3.10/site-packages/typeguard/__init__.py(1033): wrapper | |
E /home/ubuntu/git/single-cell-data/TileDB-SOMA/apis/python/tests/test_soma_dataframe.py(82): test_soma_dataframe_non_indexed | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/python.py(192): pytest_pyfunc_call | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_callers.py(39): _multicall | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_manager.py(80): _hookexec | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_hooks.py(265): __call__ | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/python.py(1761): runtest | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(166): pytest_runtest_call | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_callers.py(39): _multicall | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_manager.py(80): _hookexec | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_hooks.py(265): __call__ | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(259): <lambda> | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(338): from_call | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(258): call_runtest_hook | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(219): call_and_report | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(130): runtestprotocol | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/runner.py(111): pytest_runtest_protocol | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_callers.py(39): _multicall | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_manager.py(80): _hookexec | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_hooks.py(265): __call__ | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/main.py(347): pytest_runtestloop | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_callers.py(39): _multicall | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_manager.py(80): _hookexec | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_hooks.py(265): __call__ | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/main.py(322): _main | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/main.py(268): wrap_session | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/main.py(315): pytest_cmdline_main | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_callers.py(39): _multicall | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_manager.py(80): _hookexec | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pluggy/_hooks.py(265): __call__ | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/config/__init__.py(164): main | |
E /home/ubuntu/.local/lib/python3.10/site-packages/_pytest/config/__init__.py(187): console_main | |
E /home/ubuntu/.local/lib/python3.10/site-packages/pytest/__main__.py(5): <module> | |
E /usr/lib/python3.10/runpy.py(86): _run_code | |
E /usr/lib/python3.10/runpy.py(196): _run_module_as_main | |
src/tiledbsoma/soma_dataframe.py:193: RuntimeError | |
=========================================================== short test summary info =========================================================== | |
FAILED tests/test_soma_dataframe.py::test_soma_dataframe_non_indexed - RuntimeError: TypeError: type of argument "node" must be a type; got ... | |
======================================================== 1 failed, 18 passed in 2.44s ========================================================= | |
ubuntu@ip-172-31-20-78[prod][kerl/lib-sdf][python]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment