DeepLearnPhysics / larcv3

Third version of larcv. This is a complete replacement for larcv2.
MIT License
11 stars 6 forks source link

Issue importing larcv #53

Open bear-is-asleep opened 2 years ago

bear-is-asleep commented 2 years ago

Hello again! I'm working on Linux Mint 19.1, python 3.10.4, and have installed larcv from the source. I get the the following error when running from larcv import larcv

File ~/larcv3/larcv/__init__.py:2, in <module>
----> [2] from . pylarcv import *

ModuleNotFoundError: No module named 'larcv.pylarcv'

I get the same error from larcv3 import larcv

File ~/larcv3/larcv/__init__.py:2, in <module>
----> [2] from . pylarcv import *

ModuleNotFoundError: No module named 'larcv3.larcv.pylarcv'

I don't see a pylarcv even in the github repository, so what is this line in __init__.py trying to do? Thanks!

coreyjadams commented 2 years ago

Where were you running this? Meaning, what folder?

Pylarcv is the dynamic library of python bindings.

Also, you should just do: import larcv.

bear-is-asleep commented 2 years ago

Sorry I should've provided more information. I'm running this in /home/bc1/Desktop/SBND/ML/ and larcv lives in my home directory /home/bc1 (in other words I would be trying to import /home/bc1/larcv/larcv). I've specified the path to this folder through sys.path.append('/home/bc1/'). Also, I'm attempting to complete the lartpc_mlreco3d tutorials and I'm currently on this page. Specifically, this step:

cfg=yaml.load(cfg,Loader=yaml.Loader)
# pre-process configuration (checks + certain non-specified default settings)
process_config(cfg)
# prepare function configures necessary "handlers"
hs=prepare(cfg)

In which the full error is:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/home/bc1/Desktop/SBND/ML/testing.ipynb Cell 6' in <cell line: 5>()
      3 process_config(cfg)
      4 # prepare function configures necessary "handlers"
----> 5 hs=prepare(cfg)

File ~/lartpc_mlreco3d/mlreco/main_funcs.py:157, in prepare(cfg, event_list)
    154 handlers.cfg = cfg
    156 # Instantiate DataLoader
--> 157 handlers.data_io = loader_factory(cfg, event_list=event_list)
    159 # IO iterator
    160 handlers.data_io_iter = iter(cycle(handlers.data_io))

File ~/lartpc_mlreco3d/mlreco/iotools/factories.py:55, in loader_factory(cfg, event_list)
     52 import mlreco.iotools.collates
     53 import mlreco.iotools.samplers
---> 55 ds = dataset_factory(cfg,event_list)
     56 sampler = None
     57 if 'sampler' in cfg['iotool']:

File ~/lartpc_mlreco3d/mlreco/iotools/factories.py:18, in dataset_factory(cfg, event_list)
      8 def dataset_factory(cfg,event_list=None):
      9     """
     10     Instantiates dataset based on type specified in configuration under
     11     `iotool.dataset.name`. The name must match the name of a class under
   (...)
     16     Currently the choice is limited to `LArCVDataset` only.
     17     """
---> 18     import mlreco.iotools.datasets
     19     params = cfg['iotool']['dataset']
     20     if event_list is not None:

File ~/lartpc_mlreco3d/mlreco/iotools/datasets.py:4, in <module>
      2 import numpy as np
      3 from torch.utils.data import Dataset
----> 4 import mlreco.iotools.parsers
      6 class LArCVDataset(Dataset):
 7     """
      8     A generic interface for LArCV data files.
      9 
   (...)
     14     LArCV event data objects. The assumption is that each data chunk respects the LArCV event boundary.
     15     """

File ~/lartpc_mlreco3d/mlreco/iotools/parsers/__init__.py:86, in <module>
      1 """
      2 I/O parsers are used to read data products from a LArCV ROOT file.
      3 
   (...)
     84 To be completed.
     85 """
---> 86 from mlreco.iotools.parsers.misc import (
     87     parse_meta2d,
     88     parse_meta3d,
     89     parse_dbscan,
     90     parse_run_info,
     91     parse_tensor3d
     92 )
     94 from mlreco.iotools.parsers.particles import (
     95     parse_particle_singlep_pdg,
     96     parse_particle_singlep_einit,
   (...)
    103     parse_particle_graph_corrected
    104 )
    106 from mlreco.iotools.parsers.sparse import (
    107     parse_sparse2d_scn,
    108     parse_sparse3d_scn,
   (...)
    112     parse_weights
    113 )

File ~/lartpc_mlreco3d/mlreco/iotools/parsers/misc.py:2, in <module>
      1 import numpy as np
----> 2 from larcv import larcv
      3 from mlreco.utils.dbscan import dbscan_types
      6 def parse_meta3d(data):

File ~/larcv/larcv/__init__.py:2, in <module>
----> 2 from . pylarcv import *
      4 import os
      5 from . _version import __version__

ModuleNotFoundError: No module named 'larcv.larcv.pylarcv'

However, if I should just call import larcv, it would seem that this is not an issue with the larcv import, right? I can raise this issue on that repository if this is the case. Thanks again!

coreyjadams commented 2 years ago

Oh, no, I have bad news for you. That tutorial still uses larcv2. You're on the repo for larcv3.

What's the difference? larcv2 uses ROOT as a backend, and is more experiment specific. larcv3 uses HDF5 instead, and is 100% experiment agnostic (and runs on supercomputers by design).

I suspect you need to go here: https://github.com/DeepLearnPhysics/larcv2.

@drinkingkazu is this correct? Or is the mlreco repo going to update ever?