from spyglass.decoding.v1.core import DecodingParameters
DecodingParameters().insert_default()
Error Stack
```python
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 DecodingParameters().insert_default()
File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:59, in DecodingParameters.insert_default(cls)
56 @classmethod
57 def insert_default(cls):
58 """Insert default decoding parameters"""
---> 59 cls.insert(cls.contents, skip_duplicates=True)
File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:68, in DecodingParameters.insert(self, rows, *args, **kwargs)
62 """Override insert to convert classes to dict before inserting"""
63 for row in rows:
64 # params = row["decoding_params"] # my edits
65 # if hasattr(params, "__dict__"):
66 # params = vars(params)
67 row["decoding_params"] = convert_classes_to_dict(
---> 68 vars(row["decoding_params"])
69 )
70 super().insert(rows, *args, **kwargs)
TypeError: vars() argument must have __dict__ attribute
```
It seems vars is being attempted on a dict.
Skipping `vars`...
```python
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 DecodingParameters().insert_default()
File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:59, in DecodingParameters.insert_default(cls)
56 @classmethod
57 def insert_default(cls):
58 """Insert default decoding parameters"""
---> 59 cls.insert(cls.contents, skip_duplicates=True)
File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:67, in DecodingParameters.insert(self, rows, *args, **kwargs)
65 if hasattr(params, "__dict__"):
66 params = vars(params)
---> 67 row["decoding_params"] = convert_classes_to_dict(params)
68 super().insert(rows, *args, **kwargs)
File ~/wrk/spyglass/src/spyglass/decoding/v1/dj_decoder_conversion.py:185, in convert_classes_to_dict(params)
183 params = copy.deepcopy(params)
184 try:
--> 185 params["environments"] = [
186 _convert_environment_to_dict(env) for env in params["environments"]
187 ]
188 except TypeError:
189 params["environments"] = [
190 _convert_environment_to_dict(params["environments"])
191 ]
File ~/wrk/spyglass/src/spyglass/decoding/v1/dj_decoder_conversion.py:186, in (.0)
183 params = copy.deepcopy(params)
184 try:
185 params["environments"] = [
--> 186 _convert_environment_to_dict(env) for env in params["environments"]
187 ]
188 except TypeError:
189 params["environments"] = [
190 _convert_environment_to_dict(params["environments"])
191 ]
File ~/wrk/spyglass/src/spyglass/decoding/v1/dj_decoder_conversion.py:158, in _convert_environment_to_dict(env)
156 def _convert_environment_to_dict(env: Environment) -> dict:
157 """Converts an Environment instance into a dictionary so that datajoint can store it"""
--> 158 if env.track_graph is not None:
159 track_graph = env.track_graph
160 env.track_graph = {
161 "node_positions": [
162 v["pos"] for v in dict(track_graph.nodes).values()
163 ],
164 "edges": list(track_graph.edges),
165 }
AttributeError: 'dict' object has no attribute 'track_graph'
```
Editing the insert to detect the utility of vars, there's still an issue with the environment-to-dict process on a contents stored as dict
Given that this tables is already a lookup, the inclusion of insert_default is just for parity with other params tables, and could be removed. Or it could super().insert
From a new database, I ran
Error Stack
```python --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[2], line 1 ----> 1 DecodingParameters().insert_default() File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:59, in DecodingParameters.insert_default(cls) 56 @classmethod 57 def insert_default(cls): 58 """Insert default decoding parameters""" ---> 59 cls.insert(cls.contents, skip_duplicates=True) File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:68, in DecodingParameters.insert(self, rows, *args, **kwargs) 62 """Override insert to convert classes to dict before inserting""" 63 for row in rows: 64 # params = row["decoding_params"] # my edits 65 # if hasattr(params, "__dict__"): 66 # params = vars(params) 67 row["decoding_params"] = convert_classes_to_dict( ---> 68 vars(row["decoding_params"]) 69 ) 70 super().insert(rows, *args, **kwargs) TypeError: vars() argument must have __dict__ attribute ```It seems
vars
is being attempted on a dict.Skipping `vars`...
```python --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[2], line 1 ----> 1 DecodingParameters().insert_default() File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:59, in DecodingParameters.insert_default(cls) 56 @classmethod 57 def insert_default(cls): 58 """Insert default decoding parameters""" ---> 59 cls.insert(cls.contents, skip_duplicates=True) File ~/wrk/spyglass/src/spyglass/decoding/v1/core.py:67, in DecodingParameters.insert(self, rows, *args, **kwargs) 65 if hasattr(params, "__dict__"): 66 params = vars(params) ---> 67 row["decoding_params"] = convert_classes_to_dict(params) 68 super().insert(rows, *args, **kwargs) File ~/wrk/spyglass/src/spyglass/decoding/v1/dj_decoder_conversion.py:185, in convert_classes_to_dict(params) 183 params = copy.deepcopy(params) 184 try: --> 185 params["environments"] = [ 186 _convert_environment_to_dict(env) for env in params["environments"] 187 ] 188 except TypeError: 189 params["environments"] = [ 190 _convert_environment_to_dict(params["environments"]) 191 ] File ~/wrk/spyglass/src/spyglass/decoding/v1/dj_decoder_conversion.py:186, inEditing the insert to detect the utility of
vars
, there's still an issue with the environment-to-dict process on a contents stored as dictGiven that this tables is already a lookup, the inclusion of
insert_default
is just for parity with other params tables, and could be removed. Or it couldsuper().insert