Skip to content

Conversation

hoxbro
Copy link
Contributor

@hoxbro hoxbro commented Nov 27, 2022

All pull requests must have an associated issue in the issue tracker. If there
isn't one, please go open an issue describing the defect, deficiency or desired
feature. You can read more about our issue and PR processes in the
wiki.

@mattpap mattpap added this to the 3.1 milestone Nov 27, 2022
@codecov
Copy link

codecov bot commented Nov 27, 2022

Codecov Report

Merging #12650 (e17ac00) into branch-3.1 (8fa898b) will decrease coverage by 0.02%.
The diff coverage is 82.97%.

@@              Coverage Diff               @@
##           branch-3.1   #12650      +/-   ##
==============================================
- Coverage       92.16%   92.13%   -0.03%     
==============================================
  Files             313      313              
  Lines           19570    19584      +14     
==============================================
+ Hits            18036    18044       +8     
- Misses           1534     1540       +6     

@bryevdv
Copy link
Member

bryevdv commented Nov 27, 2022

Hi @hoxbro thanks for the PR! I do think this ought to go in a new module (e.g. bokeh.util.exceptions) since there are other things besides just deprecations that could benefit from this, e.g.

RuntimeWarning, stacklevel=2)

as well as several other places that use warnings.warn

Alternatively, we could move the warn function and find_stacklevel to a new bokeh.util.warning module, and then use our custom warn function everywhere we currently use warnings.warn. Let me know what you think!

@hoxbro
Copy link
Contributor Author

hoxbro commented Nov 27, 2022

I don't have a strong opinion about which of the opinions to do. Can do both and will update the rest of the code accordingly.

Though I will probably use bokeh.util.warnings instead of bokeh.util.warning. If that option is chosen.

@bryevdv
Copy link
Member

bryevdv commented Nov 27, 2022

@hoxbro that's fantastic, appreciate your help. Let's move the custom warn and the new find_stack_level to a bokeh.util.warnings module. There a quite a number of places that currently call warnings.warn. It's really up to you as to how many of these you want to tackle, but let's make a follow-up issue in case it's not all of them :)

bokeh/io/export.py
328:            warnings.warn("Export method called with width or height argument on a non-Plot model. The size values will be ignored.")

bokeh/io/notebook.py
312:        warn("No document to push")
319:        warn("Cannot find a last shown plot to update. Call output_notebook() and show(..., notebook_handle=True) before push_notebook()")

bokeh/io/saving.py
142:        warn("save() called but no resources were supplied and output_file(...) was never called, defaulting to resources.CDN")
154:        warn("save() called but no title was supplied and output_file(...) was never called, using default title 'Bokeh Plot'")

bokeh/settings.py
812:    warnings.warn("BOKEH_SECRET_KEY is recommended to have at least 32 bytes of entropy chosen with a cryptographically-random algorithm")
817:    warnings.warn("BOKEH_SECRET_KEY must be set if BOKEH_SIGN_SESSIONS is set to True")

bokeh/command/util.py
130:                warnings.warn(DIRSTYLE_MAIN_WARNING)

bokeh/plotting/_tools.py
156:        warnings.warn(f"{','.join(repeated_tools)} are being repeated")

bokeh/plotting/graph.py
83:            warn("Converting node attributes labeled 'index' are skipped. "
104:            warn("Converting edge attributes labeled 'start' or 'end' are skipped. "
122:                warn("Node keys in 'layout_function' don't match node keys in the graph. "

bokeh/models/sources.py
211:                 lambda obj, name, data: warnings.warn(
416:            warnings.warn("Unable to find column '%s' in data source" % name)

bokeh/util/deprecation.py
45:def warn(message: str, stacklevel: int = 2) -> None:
46:    warnings.warn(message, BokehDeprecationWarning, stacklevel=stacklevel)
78:    warn(message)

bokeh/util/terminal.py
96:def warn(msg: str | None = None, label: str = "WARN") -> None:

bokeh/util/token.py
260:        warnings.warn('A secure pseudo-random number generator is not available '
263:            warnings.warn('A secure pseudo-random number generator is not available '

bokeh/models/plots.py
954:            warnings.warn(_LEGEND_EMPTY_WARNING % attr)

bokeh/embed/bundle.py
174:            warn('No Bokeh CSS Resources provided to template. If required you will need to provide them manually.')
177:            warn('No Bokeh JS Resources provided to template. If required you will need to provide them manually.')

bokeh/models/formatters.py
399:        warnings.warn(f"DatetimeFormatter scales now only accept a single format. Using the first prodvided: {fmt[0]!r} ")

bokeh/core/has_props.py
215:            warn(f"Properties {redeclared!r} in class {cls.__name__} were previously declared on a parent "
223:            warn(f"Overrides of {unused_overrides} in class {cls.__name__} does not override anything.", RuntimeWarn

@hoxbro hoxbro force-pushed the add_stacklevel_detection branch from f4b9a5e to 4913df3 Compare November 28, 2022 18:08
@hoxbro hoxbro changed the title Added find_stack_level to util.deprecation Added find_stack_level to util.warnings Nov 28, 2022
@bryevdv
Copy link
Member

bryevdv commented Nov 29, 2022

Thanks for the comprehensive PR @hoxbro !

@bryevdv bryevdv merged commit 829a9d0 into bokeh:branch-3.1 Nov 29, 2022
@hoxbro hoxbro deleted the add_stacklevel_detection branch November 29, 2022 06:25
bryevdv pushed a commit that referenced this pull request Dec 6, 2022
* Added find_stack_level to util.deprecation

* Moving deprecation -> warnings

* Change to use internal warn

* Fix import

* Fix lint

* Fix failing test
@bryevdv bryevdv mentioned this pull request Dec 6, 2022
bryevdv added a commit that referenced this pull request Dec 7, 2022
* Neutral POV for install instructions (#12603)

* Neutral POV for install instructions

* Update README.md

Co-authored-by: Moritz Schreiber <68053396+mosc9575@users.noreply.github.com>

Co-authored-by: Moritz Schreiber <68053396+mosc9575@users.noreply.github.com>

* Fix export with fractional CSS lengths (#12613)

* Fix layout propagation in nested mixed layouts (#12612)

* Replace flake8 with ruff (#12605)

* apply fixes

* stricter, more fixes

* more fixes, check __init__.py better

* remove flake8

* add U amd W checks

* combine imports

* remove spurious # noqa

* Remove LGTM (#12620)

LGTM service will shut down in a few weeks. 

https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/#end-of-november-new-commits-and-pull-requests-are-no-longer-analyzed

* Added metadata to glyphs.py, multi_legend.py, multi_scale.py (#12547)

* Added metadata to glyphs.py, multi_legend.py, multi_scale.py

* Removed trailing whitespaces.

* Pared down apis to the most interesting and put it in a single line.

* Added the apis in a single line and updated the keywords.

* Bv/deprecated apis in tests (#12622)

* pydot -> pygraphviz

* remove publish_display_data source param

* Exlude tmp files from coverage (#12629)

* exlude tmp files from coverage

* silence linter

* Update CodeQL action (#12630)

* Update CodeQL action

* kick the tires

* Fix application of UI element styles in Firefox (#12634)

* Add CodeQL config (#12636)

* codeql config in proper job

* Updates to Docker image building and testing (#12351)

* Updates to docker image building

* Support all non-firefox tests in docker container

* Try ECR upload

* Update ECR region and repository

* Chromedriver version does not have to match chrome version

* Try ECR upload

* Try adding custom registry alias

* try default registry alias

* Try default alias take 2

* specify public registry login

* fix registry type config

* Try dockerhub

* fix typo

* Try multiple tags

* Option to push or save image

* Github action to run tests in docker container

* Temporarily force BokehJS-CI to run

* Try to get docker testing to run in CI

* Run docker in CI using wheel

* Use entrypoint script to install from wheel

* Final tweaks

* Switch to docker testing using image named branch-3.1

* Add test running chromium in Docker without required envvar

* Move test-in-docker to separate workflow

* Better docker CI names

Co-authored-by: Bryan Van de Ven <bryan@bokeh.org>

* Disable docker from wheel integration tests (#12639)

* Added find_stack_level to util.warnings (#12650)

* Added find_stack_level to util.deprecation

* Moving deprecation -> warnings

* Change to use internal warn

* Fix import

* Fix lint

* Fix failing test

* Resolve issues with code quality checks (#12654)

* Use type[T] instead of Type[T] where permitted

* Pin ruff to last working version (0.0.144)

* Compute layout for initially undisplayed components (#12653)

* Fix broken bokeh-tree links (#12644)

* fix broken bokeh-tree links

* fix broken metadata ref

* more versioned links

* lint

* CodeQL: remove import linter hack (#12645)

* remove API import lint hack in properties.py

* remove API import lint hack in plotting/__init__.py

* remove API import lint hack in sampledata/__init__.py

* remove API import lint hack in document/__init__.py

* remove API import lint hack in embed/util.py

* remove API import lint hack in top level __init__.py

* remove API import lint hack in model/util.py

* clean up doc event imports

* clean up defaults tests imports

* remove non-functional spec.py

* review changes

* Add default styles to FILE template (#12656)

* Add default styles to FILE template

* Don't ignore template files

* Skip stocks and surface3d examples

* Adapt Bokeh logo for dark theme and add docs badge in README.md (#12659)

Co-authored-by: Moritz Schreiber <68053396+mosc9575@users.noreply.github.com>
Co-authored-by: Mateusz Paprocki <mattpap@gmail.com>
Co-authored-by: Yash Pratapwar <65851650+Yash-Pratapwar@users.noreply.github.com>
Co-authored-by: Ian Thomas <ianthomas23@gmail.com>
Co-authored-by: Simon Høxbro Hansen <simon.hansen@me.com>
Co-authored-by: Pavithra Eswaramoorthy <pavithraes@outlook.com>
@bryevdv bryevdv modified the milestones: 3.1, 3.0.3 Dec 7, 2022
Chiemezuo pushed a commit to Chiemezuo/bokeh that referenced this pull request Aug 27, 2024
* Added find_stack_level to util.deprecation

* Moving deprecation -> warnings

* Change to use internal warn

* Fix import

* Fix lint

* Fix failing test
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a find_stack_level to deprecation.py
3 participants