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

Find project root when run from a wheel (logger module) #43

Closed
wants to merge 3 commits into from

Conversation

sundarshankar89
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (655fff6) 77.08% compared to head (540d3a0) 76.80%.

Files Patch % Lines
src/databricks/labs/blueprint/entrypoint.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #43      +/-   ##
==========================================
- Coverage   77.08%   76.80%   -0.28%     
==========================================
  Files          13       13              
  Lines        1270     1272       +2     
  Branches      230      231       +1     
==========================================
- Hits          979      977       -2     
- Misses        201      204       +3     
- Partials       90       91       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

for leaf in ("pyproject.toml", "setup.py"):
root = find_dir_with_leaf(this_path, leaf)
if root is not None:
return root
# Wheel installation is under site-packages hence return the parent of site-packages
if "site-packages" in __file:
return Path(__file.split("site-packages")[0] + "site-packages/")
Copy link
Contributor

Choose a reason for hiding this comment

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

And what if there are many modules with "about.py"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is presenting a workaround since we don't do anything with PROJECT_ROOT variables, to answer your question it doesn't matter, the path is going to be set from Python env location where wheel file is installed.

Ideally just rewriting the get_logger to get module name directly would make sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please take a look at the usages of this function in the library.

As for remoph - logging.get_logger(name) might be enough. The utility of blueprint is to help only when name is main

@nfx
Copy link
Contributor

nfx commented Mar 9, 2024

use logging.getLogger(__name__) when you're not installing

@nfx nfx closed this Mar 9, 2024
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.

2 participants