Repository: cogent3/cogent3
Pull request #1218 (2022-12-06 02:49:19)

MAINT: changed repr of data store instances


Patch:
diff --git a/src/cogent3/app/data_store_new.py b/src/cogent3/app/data_store_new.py
index bd394d780..9738edf99 100644
--- a/src/cogent3/app/data_store_new.py
+++ b/src/cogent3/app/data_store_new.py
@@ -115,6 +115,11 @@ class DataStoreABC(ABC):
         ...
 
     def __repr__(self):
+        name = self.__class__.__name__
+        construction = ", ".join(f"{k}={v}" for k, v in self._init_vals.items())
+        return f"{name}({construction})"
+
+    def __str__(self):
         num = len(self.members)
         name = self.__class__.__name__
         sample = f"{list(self[:2])}..." if num > 2 else list(self)
diff --git a/src/cogent3/app/sqlite_data_store.py b/src/cogent3/app/sqlite_data_store.py
index 47c34dece..c80384cb3 100644
--- a/src/cogent3/app/sqlite_data_store.py
+++ b/src/cogent3/app/sqlite_data_store.py
@@ -32,7 +32,7 @@ __maintainer__ = "Gavin Huttley"
 __email__ = "Gavin.Huttley@anu.edu.au"
 __status__ = "Alpha"
 
-_RESULT_TABLE = "result_table"
+_RESULT_TABLE = "results"
 _MEMORY = ":memory:"
 _mem_pattern = re.compile(r"^\s*[:]{0,1}memory[:]{0,1}\s*$")
 
@@ -43,9 +43,9 @@ def open_sqlite_db_rw(path: Union[str, Path]):
 
     Notes
     -----
-    This function embeds the schema. There are four tables:
-    - complete: completed analysis objects
-    - incomplete: NotCompleted objects
+    This function embeds the schema. There are three tables:
+
+    - results: analysis objects, may be completed or not completed
     - logs: log-file contents
     - state: whether db is locked to a process
 


Test patch:
diff --git a/tests/test_app/test_data_store_new.py b/tests/test_app/test_data_store_new.py
index 2ce5acd9f..0c3311aed 100644
--- a/tests/test_app/test_data_store_new.py
+++ b/tests/test_app/test_data_store_new.py
@@ -334,15 +334,15 @@ def test_append(w_dstore):
 
 def test_no_not_completed_subdir(nc_dstore):
     expect = f"{len(nc_dstore.completed)+len(nc_dstore.not_completed)}x member"
-    assert repr(nc_dstore).startswith(expect)
+    assert str(nc_dstore).startswith(expect)
     # first remove not_completed directory
     nc_dstore.drop_not_completed()
     # test repr work without not_completed directory
     assert not Path(nc_dstore.source / _NOT_COMPLETED_TABLE).exists()
     expect = f"{len(nc_dstore.completed)}x member"
-    assert repr(nc_dstore).startswith(expect)
+    assert str(nc_dstore).startswith(expect)
     expect = f"{len(nc_dstore)}x member"
-    assert repr(nc_dstore).startswith(expect)
+    assert str(nc_dstore).startswith(expect)
     assert len(nc_dstore) == len(nc_dstore.completed)
     not_dir = nc_dstore.source / _NOT_COMPLETED_TABLE
     not_dir.mkdir(exist_ok=True)
diff --git a/tests/test_app/test_sqlite_data_store.py b/tests/test_app/test_sqlite_data_store.py
index 02239e4dd..23a978d81 100644
--- a/tests/test_app/test_sqlite_data_store.py
+++ b/tests/test_app/test_sqlite_data_store.py
@@ -344,14 +344,14 @@ def test_summary_not_completed(full_dstore_sqlite):
 
 def test_no_not_completed_subdir(full_dstore_sqlite):
     expect = f"{len(full_dstore_sqlite.completed)+len(full_dstore_sqlite.not_completed)}x member"
-    assert repr(full_dstore_sqlite).startswith(expect)
+    assert str(full_dstore_sqlite).startswith(expect)
     # first remove not_completed directory
     full_dstore_sqlite.drop_not_completed()
     # test repr work without not_completed directory
     expect = f"{len(full_dstore_sqlite.completed)}x member"
-    assert repr(full_dstore_sqlite).startswith(expect)
+    assert str(full_dstore_sqlite).startswith(expect)
     expect = f"{len(full_dstore_sqlite)}x member"
-    assert repr(full_dstore_sqlite).startswith(expect)
+    assert str(full_dstore_sqlite).startswith(expect)
     assert len(full_dstore_sqlite) == len(full_dstore_sqlite.completed)