question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot instantiate sfaira universe when sfaira is not installed in editable mode

See original GitHub issue

When running an editable install of the latest release branch of sfaira u = sfaira.data.Universe(data_path="/some/empty/dir/") runs without problems. if the same is done on a non-editable install (pip install sfaira), the below error is raised.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-683a72d34073> in <module>
----> 1 sfaira.data.Universe(data_path="/home/leander.dony/sfaira_data_test")

~/.local/lib/python3.8/site-packages/sfaira/data/dataloaders/super_group.py in __init__(self, data_path, meta_path, cache_path, exclude_databases)
     29         """
     30         dsgs = [
---> 31             DatasetSuperGroupLoaders(
     32                 data_path=data_path,
     33                 meta_path=meta_path,

~/.local/lib/python3.8/site-packages/sfaira/data/dataloaders/loaders/super_group.py in __init__(self, data_path, meta_path, cache_path)
     37                     if path_dsg is not None:
     38                         try:
---> 39                             dsg = DatasetGroupDirectoryOriented(
     40                                 file_base=path_dsg,
     41                                 data_path=data_path,

~/.local/lib/python3.8/site-packages/sfaira/data/dataloaders/base/dataset_group.py in __init__(self, file_base, data_path, meta_path, cache_path)
    767                         datasets.extend(datasets_f)
    768 
--> 769         keys = [x.id for x in datasets]
    770         super().__init__(datasets=dict(zip(keys, datasets)), collection_id=collection_id)
    771 

~/.local/lib/python3.8/site-packages/sfaira/data/dataloaders/base/dataset_group.py in <listcomp>(.0)
    767                         datasets.extend(datasets_f)
    768 
--> 769         keys = [x.id for x in datasets]
    770         super().__init__(datasets=dict(zip(keys, datasets)), collection_id=collection_id)
    771 

~/.local/lib/python3.8/site-packages/sfaira/data/dataloaders/base/dataset.py in id(self)
   1710             return self._id
   1711         else:
-> 1712             raise AttributeError(f"Dataset ID was not set in dataloader in {self.doi_main}, please ensure the "
   1713                                  f"dataloader constructor of this dataset contains a call to self.set_dataset_id()")
   1714 

AttributeError: Dataset ID was not set in dataloader in None, please ensure the dataloader constructor of this dataset contains a call to self.set_dataset_id()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Zethsoncommented, Nov 29, 2021

Okay, I think I found the problem: when sfaira is installed just using pip, all .yaml or .tsv files are skipped. @Zethson do you know how we can force pip to install all files that we have in the package, not just .py files?

Yeah. Been there done that. This is by the way builtin with Poetry 😃

The proper way to do this: https://packaging.python.org/guides/using-manifest-in/ But I never really managed to make it work although it should be trivial. But my attempts are quite in the past.

Here’s some old shit code of mine: https://github.com/Zethson/promoe/blob/master/setup.py#L67 The walker function is in the same setup.py file. This works for sure.

For both solutions note: all files specified by the package_data and data_files setup() arguments

so don’t forget package_data in setup.py (see my old code)

1reaction
davidsebfischercommented, Nov 29, 2021

Thanks a lot Lukas! I’ll give the manifest a try. @davidsebfischer do you think recursive-include sfaira/data/dataloaders/loaders/d* *.tsv *.yaml ie. any tsv or yaml file under sfaira/data/dataloaders/loaders/d* should cover any non-python file that is in sfaira? or is there more (eg. on the ontologies or genome side)? i remember we had some csv files in there as well at some point?

recursive-include sfaira/data/dataloaders/loaders/d* *.tsv *.yaml should be enough! Ontologies and genomes both directly cache from public servers now to make this transparent!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors during installation · Issue #377 · theislab/sfaira - GitHub
So I just installed tensorflow prior to installing sfaira and repeated the installation via pip, i.e. conda install tensorflow then pip install ......
Read more >
How to install a package using pip in editable mode with ...
Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that...
Read more >
sfaira - PyPI
sfaira is a model and a data repository for single-cell data in a single python package.
Read more >
Unresolved references to editable packages (pip install
This causes all kinds of module not found errors trying to edit a file that imports a module from this library. The most...
Read more >
Development Mode (a.k.a. “Editable Installs”) - Setuptools
You can enter this “development mode” by performing an editable installation inside of a virtual environment, using pip's -e/--editable flag, as shown below ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found