Skip to content

Make explicit that users should use alibylite

Summary

TypeError raised when dataloader.load() is invoked.

Steps to reproduce

Code:

from wela.dataloader import dataloader
h5dir = "/home/jupyter-arin/data/"
wdir = "./wela_tsv_data/"

dl = dataloader(
    h5dir = h5dir,
    wdir = wdir,
)
dataname = "19972_2021_05_28_flavin_htb2_glucose_limitation_hard_Delft_01_01"
dl.load(dataname, key_index="flavin")

This error occurred with different values of the variables h5dir, wdir, and dataname (verified with @v1jhurba).

What is the current bug behaviour?

TypeError, see stack trace below.

What is the expected correct behaviour?

dataloader.load() should load data without this error.

Logs/Traceback

Stack trace:

TypeError                                 Traceback (most recent call last)
Cell In[3], line 3
      1 #dataname = "26643_2022_05_23_flavin_htb2_glucose_20gpL_01_00"
      2 dataname = "19972_2021_05_28_flavin_htb2_glucose_limitation_hard_Delft_01_01"
----> 3 dl.load(dataname, key_index="flavin")

File ~/git/wela/dataloader.py:232, in dataloader.load(self, dataname, key_index, cutoff, interpolate_list, extra_g2a_dict, pxsize, use_tsv, over_write_dict, hours, bud_fluorescence)
    230 self.a2g_dict = {v: k for (k, v) in self.g2a_dict.items()}
    231 # create instance of grouper
--> 232 grouper = self.get_grouper(dataname)
    233 print("\n---\n" + dataname + "\n---")
    234 if bud_fluorescence:

File ~/git/wela/dataloader.py:154, in dataloader.get_grouper(self, dataname)
    152 if dataname[-4:] == ".tsv":
    153     dataname = dataname[:-4]
--> 154 grouper = Grouper(self.h5dirpath / dataname)
    155 return grouper

TypeError: Can't instantiate abstract class Grouper with abstract methods positions_groups

Possible fixes

I suspect that the error arose because Grouper is used instead of NameGrouper, see 655a07e5.

Grouper has a blank property called positions_groups():

    @abstractproperty
    def positions_groups(self):
        pass

(see https://gitlab.com/aliby/aliby/-/blob/dev/src/postprocessor/grouper.py?ref_type=heads#L76)

In contrast, this property is defined in NameGrouper, which inherits Grouper:

    @property
    def positions_groups(self) -> t.Dict[str, str]:
        """Get a dictionary with the positions as keys and groups as items."""
        if not hasattr(self, "_positions_groups"):
            self._positions_groups = {}
            for name in self.chainers.keys():
                self._positions_groups[name] = name[
                    self.name_inds[0] : self.name_inds[1]
                ]
        return self._positions_groups

https://gitlab.com/aliby/aliby/-/blob/dev/src/postprocessor/grouper.py?ref_type=heads#L303

So, I think an easy fix would be switching back to using NameGrouper.