Repository: mapping-commons/sssom-py

Issue:
SSSOM code broken
It's really frustrating to rely on this package. Sometimes it just breaks and then my builds that are relying on it don't work. This makes me want to make my own SSSOM package, which I won't have time to maintain either, but at least I will be able to know how it works...

Can someone help figure out what's going on in https://github.com/biopragmatics/biomappings/actions/runs/4075209444/jobs/7021308103?

Comments:

Patch:
diff --git a/setup.cfg b/setup.cfg
index 595b94a..f61ded4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -49,6 +49,7 @@ keywords =
 
 [options]
 install_requires =
+    sqlalchemy<2.0.0
     pyparsing
     bioregistry
     click
diff --git a/sssom/io.py b/sssom/io.py
index 69bf759..b47cd2a 100644
--- a/sssom/io.py
+++ b/sssom/io.py
@@ -141,7 +141,6 @@ def split_file(input_path: str, output_directory: Union[str, Path]) -> None:
 
 
 def _get_prefix_map(metadata: Metadata, prefix_map_mode: str = None):
-
     if prefix_map_mode is None:
         prefix_map_mode = PREFIX_MAP_MODE_METADATA_ONLY
 
diff --git a/sssom/parsers.py b/sssom/parsers.py
index 99abc60..3c29adb 100644
--- a/sssom/parsers.py
+++ b/sssom/parsers.py
@@ -307,10 +307,11 @@ def _init_mapping_set(meta: Optional[MetadataType]) -> MappingSet:
 def _get_mdict_ms_and_bad_attrs(
     row: pd.Series, ms: MappingSet, bad_attrs: Counter
 ) -> Tuple[dict, MappingSet, Counter]:
-
     mdict = {}
     sssom_schema_object = (
-        SSSOMSchemaView.instance if SSSOMSchemaView.instance else SSSOMSchemaView()
+        SSSOMSchemaView.instance
+        if hasattr(SSSOMSchemaView, "instance")
+        else SSSOMSchemaView()
     )
     for k, v in row.items():
         if v and v == v:
diff --git a/sssom/util.py b/sssom/util.py
index a336950..87ed0ae 100644
--- a/sssom/util.py
+++ b/sssom/util.py
@@ -400,15 +400,16 @@ def assign_default_confidence(
     """
     # Get rows having numpy.NaN as confidence
     if df is not None:
-        if CONFIDENCE not in df.columns:
-            df[CONFIDENCE] = np.NaN
-            nan_df = pd.DataFrame(columns=df.columns)
+        new_df = df.copy()
+        if CONFIDENCE not in new_df.columns:
+            new_df[CONFIDENCE] = np.NaN
+            nan_df = pd.DataFrame(columns=new_df.columns)
         else:
-            df = df[~df[CONFIDENCE].isna()]
+            new_df = df[~df[CONFIDENCE].isna()]
             nan_df = df[df[CONFIDENCE].isna()]
     else:
         ValueError("DataFrame cannot be empty to 'assign_default_confidence'.")
-    return df, nan_df
+    return new_df, nan_df
 
 
 def remove_unmatched(df: pd.DataFrame) -> pd.DataFrame:
@@ -1496,7 +1497,6 @@ def are_params_slots(params: dict) -> bool:
 
 
 def _get_sssom_schema_object() -> SSSOMSchemaView:
-
     sssom_sv_object = (
         SSSOMSchemaView.instance
         if hasattr(SSSOMSchemaView, "instance")
diff --git a/tox.ini b/tox.ini
index e8518b8..9b4caff 100644
--- a/tox.ini
+++ b/tox.ini
@@ -34,7 +34,7 @@ description = Run code formatters and linters.
 [testenv:flake8]
 skip_install = true
 commands =
-    flake8 sssom/ tests/ setup.py
+    flake8 sssom/ tests/ 
 deps =
     flake8<5.0.0
     flake8-black


Test patch:
diff --git a/tests/test_collapse.py b/tests/test_collapse.py
index 9cfe58b..bd05869 100644
--- a/tests/test_collapse.py
+++ b/tests/test_collapse.py
@@ -44,7 +44,7 @@ class TestCollapse(unittest.TestCase):
     def test_filter(self):
         """Test the row count after filtering redundant rows."""
         df = filter_redundant_rows(self.df)
-        self.assertEqual(len(df), 91)
+        self.assertEqual(len(df), 92)
 
     def test_ptable(self):
         """Test the row count of the ptable export."""