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

Suggestion: use absolute imports in app code to allow re-use #298

Closed
ml-evs opened this issue Jun 10, 2020 · 3 comments · Fixed by #483
Closed

Suggestion: use absolute imports in app code to allow re-use #298

ml-evs opened this issue Jun 10, 2020 · 3 comments · Fixed by #483
Assignees
Labels
good first issue Good for newcomers

Comments

@ml-evs
Copy link
Member

ml-evs commented Jun 10, 2020

As you can't import the app code, it could be nice to switch to absolute imports for the optimade.server imports in e.g. main.py so that the file can be easily copied and dropped into other projects, without having to fork optimade-python-tools. This will also make it easier to update to later versions of python-tools too (assuming the app code itself doesn't change much).

e.g.

from .entry_collections import MongoCollection
from .config import CONFIG
from .middleware import EnsureQueryParamIntegrity
from .routers import info, links, references, structures, landing
from .routers.utils import get_providers, BASE_URL_PREFIXES

would become from optimade.server.entry_collections import MongoCollection.

Thoughts? Can add good-first-issue tag to this if we think its a good idea.

@CasperWA
Copy link
Member

This is a great idea. We should use absolute imports all over. I agree.

@ml-evs
Copy link
Member Author

ml-evs commented Sep 1, 2020

I think we've done this everywhere I had in mind, so this was probably closed by #380.

@ml-evs ml-evs closed this as completed Sep 1, 2020
@CasperWA
Copy link
Member

CasperWA commented Sep 1, 2020

There are still some cases in the models module. I'll quickly create a PR for this.

@CasperWA CasperWA reopened this Sep 1, 2020
@CasperWA CasperWA self-assigned this Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants