Skip to content

Commit

Permalink
No transact bug (#1178)
Browse files Browse the repository at this point in the history
* check for single entry population case

* fix typo

* typo fix
  • Loading branch information
samuelbray32 authored Nov 6, 2024
1 parent 92d9c35 commit dc08c25
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/spyglass/utils/dj_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def _nwb_table_tuple(self) -> tuple:
Used to determine fetch_nwb behavior. Also used in Merge.fetch_nwb.
Implemented as a cached_property to avoid circular imports."""
from spyglass.common.common_nwbfile import ( # noqa F401
from spyglass.common.common_nwbfile import (
AnalysisNwbfile,
Nwbfile,
)
) # noqa F401

table_dict = {
AnalysisNwbfile: "analysis_file_abs_path",
Expand Down Expand Up @@ -519,11 +519,12 @@ def _hash_upstream(self, keys):
List of keys for populating table.
"""
RestrGraph = self._graph_deps[1]

if not (parents := self.parents(as_objects=True, primary=True)):
# Should not happen, as this is only called from populated tables
raise RuntimeError("No upstream tables found for upstream hash.")

if isinstance(keys, dict):
keys = [keys] # case for single population key
leaves = { # Restriction on each primary parent
p.full_table_name: [
{k: v for k, v in key.items() if k in p.heading.names}
Expand All @@ -550,7 +551,7 @@ def populate(self, *restrictions, **kwargs):
processes = kwargs.pop("processes", 1)

# Decide if using transaction protection
use_transact = kwargs.pop("use_transation", None)
use_transact = kwargs.pop("use_transaction", None)
if use_transact is None: # if user does not specify, use class default
use_transact = self._use_transaction
if self._use_transaction is False: # If class default is off, warn
Expand Down

0 comments on commit dc08c25

Please sign in to comment.