Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __enter__/__exit__ for TileDB Groups #1124

Merged
merged 3 commits into from
May 25, 2022
Merged

Conversation

@johnkerl johnkerl requested a review from nguyenv May 24, 2022 16:35
@nguyenv
Copy link
Collaborator

nguyenv commented May 24, 2022

Thanks! Would just like this added in test_group.py. Just one in area like this should be sufficient:

(tiledb-3.10) vivian@mangonada:~/TileDB-Py$ git diff
diff --git a/tiledb/tests/test_group.py b/tiledb/tests/test_group.py
index a4cc6f3..734a1d7 100644
--- a/tiledb/tests/test_group.py
+++ b/tiledb/tests/test_group.py
@@ -200,10 +200,9 @@ class GroupTest(GroupTestCase):
         assert grp["subgroup"].type == tiledb.Group
         grp.close()

-        grp.open("w")
-        del grp["subarray"]
-        grp.remove("subgroup")
-        grp.close()
+        with grp.open("w") as g:
+            del g["subarray"]
+            g.remove("subgroup")

         grp.open("r")
         assert len(grp) == 0

@nguyenv
Copy link
Collaborator

nguyenv commented May 24, 2022

Opps sorry. Told you the wrong thing before. This will work -->

(tiledb-3.10) vivian@mangonada:~/TileDB-Py$ git diff
diff --git a/tiledb/tests/test_group.py b/tiledb/tests/test_group.py
index d092595..b65387c 100644
--- a/tiledb/tests/test_group.py
+++ b/tiledb/tests/test_group.py
@@ -197,9 +197,9 @@ class GroupTest(GroupTestCase):
         assert grp["subgroup"].type == tiledb.Group
         grp.close()

-        with grp.open("w") as g: # test __enter__ and __exit__
-            del g["subarray"]
-            g.remove("subgroup")
+        with tiledb.Group(grp_path, "w") as grp:  # test __enter__ and __exit__
+            del grp["subarray"]
+            grp.remove("subgroup")

         grp.open("r")
         assert len(grp) == 0
(tiledb-3.10) vivian@mangonada:~/TileDB-Py$ pytest tiledb/tests/test_group.py
================================================ test session starts ================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/vivian/TileDB-Py, configfile: pyproject.toml
plugins: hypothesis-6.46.6
collected 9 items

tiledb/tests/test_group.py .........                                                                          [100%]

================================================= 9 passed in 0.25s =================================================

@johnkerl
Copy link
Contributor Author

@nguyenv can you please merge this? 🙏

Screen Shot 2022-05-25 at 2 51 38 PM

@nguyenv nguyenv merged commit 07d3f5e into dev May 25, 2022
@nguyenv nguyenv deleted the kerl/with-open-group-as branch May 25, 2022 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants