rich icon indicating copy to clipboard operation
rich copied to clipboard

Detect Databricks as Jupyter environment

Open noklam opened this issue 1 year ago • 6 comments

Type of changes

Detect Databricks as Jupyter environment, although it is kind of a weird breed of Jupyter Notebook. This should make JUPYTER_LINES and JUPYTER_COLUMNS configurations useful for Databricks

  • [x] Bug fix
  • [ ] New feature
  • [x] Documentation / docstrings
  • [ ] Tests
  • [ ] Other

Checklist

  • [x] I've run the latest black with default args on new code.
  • [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • [ ] I've added tests for new code.
  • [x] I accept that @willmcgugan may be pedantic in the code review.

Description

Please describe your changes here. If this fixes a bug, please link to the issue, if possible. Added a condition to check for Databricks environment variable. Fix #2422

noklam avatar Jul 27 '22 15:07 noklam

Codecov Report

Merging #2424 (3a5f097) into master (19e518f) will decrease coverage by 0.03%. The diff coverage is 98.34%.

:exclamation: Current head 3a5f097 differs from pull request most recent head e054861. Consider uploading reports for the commit e054861 to get more accurate results

@@            Coverage Diff             @@
##           master    #2424      +/-   ##
==========================================
- Coverage   98.71%   98.67%   -0.04%     
==========================================
  Files          73       72       -1     
  Lines        7771     7767       -4     
==========================================
- Hits         7671     7664       -7     
- Misses        100      103       +3     
Flag Coverage Δ
unittests 98.67% <98.34%> (-0.04%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/default_styles.py 100.00% <ø> (ø)
rich/logging.py 100.00% <ø> (ø)
rich/progress.py 92.76% <ø> (ø)
rich/segment.py 98.72% <93.10%> (+<0.01%) :arrow_up:
rich/_inspect.py 100.00% <100.00%> (ø)
rich/box.py 100.00% <100.00%> (ø)
rich/cells.py 96.05% <100.00%> (-3.95%) :arrow_down:
rich/color.py 100.00% <100.00%> (ø)
rich/console.py 98.30% <100.00%> (+0.01%) :arrow_up:
rich/highlighter.py 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ee992b...e054861. Read the comment docs.

codecov-commenter avatar Jul 27 '22 15:07 codecov-commenter

I don't know if it's any better, but https://stackoverflow.com/questions/51329152/how-to-detect-databricks-environment-programmatically suggests using a different environment variable, DATABRICKS_RUNTIME_VERSION.

Thank you for doing this though! Definitely feels like the right fix to me from a kedro perspective. I thought I'd done _is_jupyter in Databricks before to test exactly this out, but obviously I was wrong.

antonymilne avatar Jul 28 '22 11:07 antonymilne

@AntonyMilneQB I can't find any documentation or guarantee about them, I tend to believe they are more or less the same. But I changed it anyway, let's stick with the StackOverflow answer.

noklam avatar Jul 28 '22 12:07 noklam

@willmcgugan Sorry for tagging you directly, do you need more to get this approved?

noklam avatar Aug 03 '22 09:08 noklam

Bear with me. Will review PRs within a week or two.

willmcgugan avatar Aug 03 '22 09:08 willmcgugan

Thank you!

noklam avatar Aug 03 '22 10:08 noklam

@willmcgugan Agree, unfortunately there aren't better way to detect a databricks environment. We have to include something similar because the Rich traceback hook interfere with Databricks notebook.

noklam avatar Sep 19 '22 10:09 noklam