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

requests_cache is not optional on retry #107

Open
toslunar opened this issue May 26, 2023 · 1 comment
Open

requests_cache is not optional on retry #107

toslunar opened this issue May 26, 2023 · 1 comment
Labels

Comments

@toslunar
Copy link

Description

requests_cache is unconditionally imported at uncache_url, which is called by fetch_with_retries on retry.

Reproduce

pytest --check-links on a document containing a broken link that returns retry-after header, for example

<a href="https://zenodo.org/badge/latestdoi/11846/arose/nglview">

Stacktrace:

/.../site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/.../site-packages/_pytest/runner.py:262: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/.../site-packages/pluggy/_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
/.../site-packages/pluggy/_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/.../site-packages/pluggy/_callers.py:60: in _multicall
    return outcome.get_result()
/.../site-packages/pluggy/_result.py:60: in get_result
    raise ex[1].with_traceback(ex[2])
/.../site-packages/pluggy/_callers.py:39: in _multicall
    res = hook_impl.function(*args)
/.../site-packages/_pytest/runner.py:177: in pytest_runtest_call
    raise e
/.../site-packages/_pytest/runner.py:169: in pytest_runtest_call
    item.runtest()
/.../site-packages/pytest_check_links/plugin.py:375: in runtest
    response = self.fetch_with_retries(url)
/.../site-packages/pytest_check_links/plugin.py:344: in fetch_with_retries
    self.uncache_url(url_no_anchor)
/.../site-packages/pytest_check_links/plugin.py:353: in uncache_url
    from requests_cache import BaseCache
E   ModuleNotFoundError: No module named 'requests_cache'

Expected behavior

For the broken link, the test failure message should be

FAILED index.html::/.../index.html <a href=https://zenodo.org/badge/latestdoi/11846/arose/nglview>

instead of

FAILED index.html::/.../index.html <a href=https://zenodo.org/badge/latestdoi/11846/arose/nglview> - ModuleNotFoundError: No module named 'requests_cache'

Moreover, temporarily down links could be retried without requests_cache.

Context

  • Operating System and version:
  • Browser and version:
  • JupyterLab version:
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here, if applicable.
@toslunar toslunar added the bug label May 26, 2023
@welcome
Copy link

welcome bot commented May 26, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant