cellarium-ai / cellarium-ml

Distributed single-cell data analysis.
BSD 3-Clause "New" or "Revised" License
22 stars 3 forks source link

Handle methods when CellariumPipelines are added #227

Closed sjfleming closed 3 months ago

sjfleming commented 3 months ago

Minimal demo:

>>> from cellarium.ml import CellariumPipeline
>>> m = CellariumPipeline(None) + CellariumPipeline(None)
>>> m.forward()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sfleming/miniconda3/envs/cellarium/lib/python3.10/site-packages/torch/nn/modules/module.py", line 374, in _forward_unimplemented
    raise NotImplementedError(f"Module [{type(self).__name__}] is missing the required \"forward\" function")
NotImplementedError: Module [ModuleList] is missing the required "forward" function

but this is fine as expected:

>>> from cellarium.ml import CellariumPipeline
>>> m = CellariumPipeline(None)
>>> m.forward(None)

(runs fine)

I think this points at a bug, where we really need to override __add__ in CellariumPipeline or something? Right now, it seems that the behavior of adding CellariumPipelines is not properly handled.

Originally posted by @sjfleming in https://github.com/cellarium-ai/cellarium-ml/issues/223#issuecomment-2273843347