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

Make LarvaDataset available for import in lib.reg #9

Open
bagjohn opened this issue Oct 20, 2024 · 1 comment
Open

Make LarvaDataset available for import in lib.reg #9

bagjohn opened this issue Oct 20, 2024 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@bagjohn
Copy link
Owner

bagjohn commented Oct 20, 2024

LarvaDataset is the main dataset class located in lib.process.dataset.py.
Ideally it should be available for import in various modules including in lib.reg in order to specify argument type in methods or functions that take a LarvaDataset object as an argument
BUT when trying to import it in eg lib.reg.parFunc.py there is an import error namely partially initialized module 'larvaworld.lib.reg'
See the failed test in the workflow

What refactoring should be done to make this possible?

@bagjohn bagjohn added the help wanted Extra attention is needed label Oct 20, 2024
@bagjohn bagjohn assigned bagjohn and almoehi and unassigned bagjohn Oct 20, 2024
@almoehi
Copy link
Collaborator

almoehi commented Oct 21, 2024

As the error suggests - to core issue is resolving circular dependencies.
dataset imports reg => reg imports dataset => circle

Probably the only way to resolve this is to refactor to keep the DataSet class pure (no dependencies to other modules).
It would basically just be an empty class to define the interface of "dataset" types. And then each actual dataset implementation us a sub-class of that parent type.

Then you would only use that pure DataSet class for type hinting method arguments / return types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants