DUNE-DAQ / minidaqapp

0 stars 1 forks source link

cannot import name 'trg_gen' from 'minidaqapp.nanorc #49

Open brettviren opened 3 years ago

brettviren commented 3 years ago

I'm trying to follow

https://dune-daq-sw.readthedocs.io/en/latest/packages/nanorc/

Using daq-buildtools dunedaq-v2.5.0 and nanorc master HEAD e2b94dd9bb3dfab857057075cbcb0c6e990141bc I get this error.

(dbt-pyvenv) (sing)bv@haiku:top> python -m minidaqapp.nanorc.mdapp_gen mdapp_fake
[14:21:29] Loading rudf config generator                                                                                                     mdapp_gen.py:115
[14:21:33] Loading trg config generator                                                                                                      mdapp_gen.py:117
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/bv/work/dune-daq/try2/top/build/minidaqapp/python/minidaqapp/nanorc/mdapp_gen.py:223 in    │
│ <module>                                                                                         │
│                                                                                                  │
│   220 if __name__ == '__main__':                                                                 │
│   221 │                                                                                          │
│   222 │   try:                                                                                   │
│ ❱ 223 │   │   cli(show_default=True, standalone_mode=True)                                       │
│   224 │   except Exception as e:                                                                 │
│   225 │   │   console.print_exception()                                                          │
│                                                                                                  │
│ /home/bv/work/dune-daq/try2/top/dbt-pyvenv/lib/python3.8/site-packages/click/core.py:829 in      │
│ __call__                                                                                         │
│                                                                                                  │
│    826 │                                                                                         │
│    827 │   def __call__(self, *args, **kwargs):                                                  │
│    828 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱  829 │   │   return self.main(*args, **kwargs)                                                 │
│    830                                                                                           │
│    831                                                                                           │
│    832 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ /home/bv/work/dune-daq/try2/top/dbt-pyvenv/lib/python3.8/site-packages/click/core.py:782 in main │
│                                                                                                  │
│    779 │   │   try:                                                                              │
│    780 │   │   │   try:                                                                          │
│    781 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ ❱  782 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│    783 │   │   │   │   │   if not standalone_mode:                                               │
│    784 │   │   │   │   │   │   return rv                                                         │
│    785 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ /home/bv/work/dune-daq/try2/top/dbt-pyvenv/lib/python3.8/site-packages/click/core.py:1066 in     │
│ invoke                                                                                           │
│                                                                                                  │
│   1063 │   │   """                                                                               │
│   1064 │   │   _maybe_show_deprecated_notice(self)                                               │
│   1065 │   │   if self.callback is not None:                                                     │
│ ❱ 1066 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1067                                                                                           │
│   1068                                                                                           │
│   1069 class MultiCommand(Command):                                                              │
│                                                                                                  │
│ /home/bv/work/dune-daq/try2/top/dbt-pyvenv/lib/python3.8/site-packages/click/core.py:610 in      │
│ invoke                                                                                           │
│                                                                                                  │
│    607 │   │   args = args[2:]                                                                   │
│    608 │   │   with augment_usage_errors(self):                                                  │
│    609 │   │   │   with ctx:                                                                     │
│ ❱  610 │   │   │   │   return callback(*args, **kwargs)                                          │
│    611 │                                                                                         │
│    612 │   def forward(*args, **kwargs):  # noqa: B902                                           │
│    613 │   │   """Similar to :meth:`invoke` but fills in default keyword                         │
│                                                                                                  │
│ /home/bv/work/dune-daq/try2/top/build/minidaqapp/python/minidaqapp/nanorc/mdapp_gen.py:118 in    │
│ cli                                                                                              │
│                                                                                                  │
│   115 │   console.log("Loading rudf config generator")                                           │
│   116 │   from . import rudf_gen                                                                 │
│   117 │   console.log("Loading trg config generator")                                            │
│ ❱ 118 │   from . import trg_gen                                                                  │
│   119 │   console.log(f"Generating configs for hosts trg={host_trgemu} rudf={host_rudf}")        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: cannot import name 'trg_gen' from 'minidaqapp.nanorc' (/home/bv/work/dune-daq/try2/top/build/minidaqapp/python/minidaqapp/nanorc/__init__.py)

A brute force shot in the dark:

(dbt-pyvenv) (sing)bv@haiku:top> grep tr_gen build -r

Comes up empty.

To get this far I had to go through a long sequence of trial and error with either the nanorc command above or dbt-build.sh --install in order to discover what DUNE-DAQ packages were missing. Here is what that resulted in:

(dbt-pyvenv) (sing)bv@haiku:top> ls -l sourcecode/
total 60
-rw-r--r--  1 bv bv   66 May 21 13:34 CMakeGraphVizOptions.cmake
-rw-r--r--  1 bv bv  415 May 21 13:34 CMakeLists.txt
drwxr-xr-x 13 bv bv 4096 May 21 13:41 appfwk
drwxr-xr-x 11 bv bv 4096 May 21 13:41 cmdlib
drwxr-xr-x 13 bv bv 4096 May 21 14:12 dataformats
-rw-r--r--  1 bv bv  792 May 21 13:34 dbt-build-order.cmake
drwxr-xr-x 10 bv bv 4096 May 21 14:11 dfmessages
drwxr-xr-x 13 bv bv 4096 May 21 14:10 dfmodules
drwxr-xr-x 11 bv bv 4096 May 21 14:18 flxlibs
drwxr-xr-x 12 bv bv 4096 May 21 14:13 ipm
drwxr-xr-x  7 bv bv 4096 May 21 14:07 minidaqapp
drwxr-xr-x 13 bv bv 4096 May 21 14:13 nwqueueadapters
drwxr-xr-x 14 bv bv 4096 May 21 14:19 readout
drwxr-xr-x 11 bv bv 4096 May 21 13:46 restcmd
drwxr-xr-x  9 bv bv 4096 May 21 14:12 serialization

With that in place, this following runs with no errors.

(dbt-pyvenv) (sing)bv@haiku:top> dbt-build.sh --install
(dbt-pyvenv) (sing)bv@haiku:top> dbt-workarea-env

So, what provides trg_gen?

brettviren commented 3 years ago

My grep had a typo.

(dbt-pyvenv) (sing)bv@haiku:top> grep -r trg_gen build/
Binary file build/minidaqapp/python/minidaqapp/nanorc/__pycache__/mdapp_gen.cpython-38.pyc matches
build/minidaqapp/python/minidaqapp/nanorc/mdapp_gen.py:    from . import trg_gen
build/minidaqapp/python/minidaqapp/nanorc/mdapp_gen.py:    cmd_data_trg = trg_gen.generate(

But, I still need guidance as to what provides trg_gen.

brettviren commented 3 years ago

This may be an issue with the build system. Very mysteriously:

(dbt-pyvenv) (sing)bv@haiku:top> grep -r trg_gen sourcecode/minidaqapp/
(dbt-pyvenv) (sing)bv@haiku:top> grep -r trg_gen install/minidaqapp/   
install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py:    from . import trg_gen
install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py:    cmd_data_trg = trg_gen.generate(
(dbt-pyvenv) (sing)bv@haiku:top> dbt-build.sh --install
...
-- Up-to-date: /home/bv/work/dune-daq/try2/top/install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py
(dbt-pyvenv) (sing)bv@haiku:top> grep trg_gen /home/bv/work/dune-daq/try2/top/install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py
    from . import trg_gen
    cmd_data_trg = trg_gen.generate(
(dbt-pyvenv) (sing)bv@haiku:top> rm /home/bv/work/dune-daq/try2/top/install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py
(dbt-pyvenv) (sing)bv@haiku:top> dbt-build.sh --install
...
-- Installing: /home/bv/work/dune-daq/try2/top/install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py
(dbt-pyvenv) (sing)bv@haiku:top> grep trg_gen /home/bv/work/dune-daq/try2/top/install/minidaqapp/lib64/python/minidaqapp/nanorc/mdapp_gen.py
    from . import trg_gen
    cmd_data_trg = trg_gen.generate(
(dbt-pyvenv) (sing)bv@haiku:top> grep -r trg_gen sourcecode/minidaqapp/

The principle of least surprise is maximally violated.

alessandrothea commented 3 years ago

Hi @brettviren, The generator module is part of minidaqapp. Let me transfer the issue there. What minidaqapp version are you using?

alessandrothea commented 3 years ago

Looks like trg_gen was renamed trigger_gen but mdapp_gen was not updated.

alessandrothea commented 3 years ago

@bieryAtFnal Any insight?

bieryAtFnal commented 3 years ago

My bad. Updating mdapp_gen.py got onto my to-do list, but I haven't made it back to that yet. Part of the reason for my lack of urgency is that I think that folks are tending to use mdapp_multiru_gen.py. Also, I wondered whether we wanted to update the list of supported mdapp system configurations... I'll dust off my notes to remind myself what is needed in mdapp_gen.py...

brettviren commented 3 years ago

I followed the official documentation and took the command from the nanorc docs. dunedaq-v2.5.0

I'm going to nuke my area and restart following Kurt's wiki instructions for 2.6.0 as suggested by Phil on slack. I think a link to the latest-greatest setup guide should be the very first line in dune-daq/docs/README.

I personally don't care about mdapp_gen.py per se so no need to revisit this on my account. I'm just trying to get something/anything to work so I can start to understand the implications for the config web UI.

bieryAtFnal commented 3 years ago

I'll need to confer with others to see whether trg_gen should be replaced by trigger_gen and hsi_gen, so changes to mdapp_gen.py will take a little while.

Brett, sorry for the trouble. mdapp_multiru_gen.py is fairly well tested, so I'm hopeful that it works for you with no issues.