Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessModels Cannot Be Found Through Relative Imports #902

Open
kds300 opened this issue Dec 19, 2024 · 0 comments
Open

ProcessModels Cannot Be Found Through Relative Imports #902

kds300 opened this issue Dec 19, 2024 · 0 comments
Labels
0-needs-review For all new issues 1-bug Something isn't working

Comments

@kds300
Copy link
Contributor

kds300 commented Dec 19, 2024

Describe the bug
If a process model is defined using a relative import, the function ProcGroupDiGraphs._find_proc_models() fails to find it.

To reproduce current behavior
Steps to reproduce the behavior:

  • File structure:
package/
|- __init__.py
|- proc/
|      |- process.py
|      |- models.py

  • process.py
from lava.magma.core.process.process import AbstractProcess

class TestProcess(AbstractProcess):
    """Test process for proc-model search"""
  • models.py
from lava.magma.core.model.model import AbstractProcessModel
from lava.magma.core.decorator import implements
from lava.magma.core.sync.protocols.loihi_protocol import LoihiProtocol

from .process import TestProcess


@implements(proc=TestProcess, protocol=LoihiProtocol)
class TestModelRelative(AbstractProcessModel):
    """Process model defined using relative import of Process."""
  • When running a network with TestProcess,
Cannot import module 'modules' when searching ProcessModels for Process 'TestProcess'.

Expected behavior
The compiler finds the associated process model.

Environment (please complete the following information):

  • Device: Laptop
  • OS: Ubuntu
  • Lava version: 0.10.0

Additional context
I believe the issue stems from using file paths for importing the modules containing process models. When importing this way, relative imports do not work since the information about the parent module is lost. This can be avoided by importing the modules by name and adding the appropriate prefixes when iterating through submodules.

@kds300 kds300 added the 1-bug Something isn't working label Dec 19, 2024
@github-actions github-actions bot added the 0-needs-review For all new issues label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-needs-review For all new issues 1-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant