Skip to content

Remove config import from init to fix scaffold usage#372

Merged
pjbull merged 3 commits intomasterfrom
370-config-imports
May 30, 2024
Merged

Remove config import from init to fix scaffold usage#372
pjbull merged 3 commits intomasterfrom
370-config-imports

Conversation

@pjbull
Copy link
Member

@pjbull pjbull commented May 30, 2024

  • Remove config import from __init__.py (not needed and also breaks since it is there in non-scaffold scenario)
  • Refactor some repeated code
  • Add import and import config tests
  • Add changelog

Closes #370

@pjbull pjbull requested a review from chrisjkuch May 30, 2024 15:50
@jayqi
Copy link
Member

jayqi commented May 30, 2024

not needed

The main thing that happens in config right now that is valuable to auto-execute is this bit:

# If tqdm is installed, configure loguru with tqdm.write
# https://github.com/Delgan/loguru/issues/135
try:
from tqdm import tqdm
logger.remove(0)
logger.add(lambda msg: tqdm.write(msg, end=""), colorize=True)
except ModuleNotFoundError:
pass

@pjbull
Copy link
Member Author

pjbull commented May 30, 2024

The main thing that happens in config right now that is valuable to auto-execute is this bit:

Ah, that's a good point. Added back in.

Copy link
Contributor

@chrisjkuch chrisjkuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Just summarizing for my own understanding / posterity:

  • We weren't appropriately removing import config from __init__.py when we removed all the boilerplate code, which failed at import time because config.py no longer existed
  • When the boilerplate was present, we weren't importing config from the right place leading to an import error
  • We now import the config from the right place and remove it when boilerplate is removed, and we test that both of those work as expected in the live tests

@pjbull
Copy link
Member Author

pjbull commented May 30, 2024

Just summarizing for my own understanding / posterity:

Nailed it! 🔨

@pjbull pjbull merged commit df254bc into master May 30, 2024
@pjbull pjbull deleted the 370-config-imports branch May 30, 2024 18:44
GatlenCulp pushed a commit to GatlenCulp/gatlens-opinionated-template that referenced this pull request Jan 29, 2025
* Update config imports and test

* reformat with latest black

* Add config back in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config import fails when using V2 scaffolding

3 participants