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

Remove pytest11 entrypoint and plugin, require tornado 6.1, remove asyncio patch, CI work #339

Merged
merged 27 commits into from
Nov 17, 2020

Conversation

bollwyvl
Copy link
Contributor

@bollwyvl bollwyvl commented Nov 13, 2020

@bollwyvl bollwyvl changed the title remote pytest11 entrypoint remove pytest11 entrypoint Nov 13, 2020
pytest_plugins = ['jupyter_server.pytest_plugin']
Copy link
Member

Choose a reason for hiding this comment

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

I guess I'm confused on when this is necessary. Given these tests will depend on pytest-jupyter's pytest_jupytercore and pytest_jupyterserver plugins, do consumers of those fixtures (including jupyter_server) require a pytest_plugins statement or is the extra-requires [test] dependency on pytest-jupyter sufficient?

In working with #335, it doesn't seem like this entry (referencing the now external plugins) makes any difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the pytest11 entry point in this repo is removed, there would be no particular way for pytest to know that it should use it, it wouldn't be imported, and the issue wouldn't occur for folk that have packages installed that try to actually .load their entrypoints.

Of the seven ways a plugin can be found, if it a test dependency doesn't use number 4, i'm a big fan of being explicit in conftest.py (number 7) or command line (number 1), but checked in as checked in inside a file that ends up in the distribution, e.g. pyproject.toml, or setup.cfg rather than rely on env vars, switches, etc.

do consumers of those fixtures (including jupyter_server) require a pytest_plugins statement

Once it's an explicit, real dependency, on a dedicated, test-time package, then everything is cool, and no pytest_plugin variable will be required, as number 4 will take care of it.

So generally: you'd never want anything referenced by Other People's Entry Points (what you might not control) to be behind an extra... depending on how they are used (e.g. have to be actually imported).

The whole prefix thing from #335? Yeah, well, that's just what a test regume is buying into with magic named functions. I'm not a huge fan, as the pattern (which, luckily, seems to be rather unique) doesn't play nice-nice with other tools (e.g. mypy, etc). But it's the only game in town, aside from the few little ecosystems where they felt they had to home-roll their own thing... noflo, robotframework, etc. have extremely unpythonic things they do, in the name of specific purposes.

@bollwyvl bollwyvl closed this Nov 13, 2020
@bollwyvl bollwyvl reopened this Nov 13, 2020
install_requires = [
'jupyter_server',
'jinja2',
],
extras_require = {
'test': ['pytest-jupyter'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not strictly required, but if the example is supposed to be illustrative...

@@ -34,11 +34,14 @@ def add_data_files(path):
version = VERSION,
description = 'Jupyter Server Example',
long_description = open('README.md').read(),
python_requires = '>=3.5',
python_requires = '>=3.6',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

☠️

Copy link
Member

Choose a reason for hiding this comment

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

I guess I'm not following the skull & crossbones commentary here, sorry about that. The change seems fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just meant 3.5 is EOL!

@kevin-bates
Copy link
Member

Thank you for your helpful responses and guidance on this Nick - it's much appreciated.

I missed the examples test, as you're now discovering - sorry about that. Looks like it's just the server_config and fetch references that require fp_ prefixes.

One of the commits in #338 I was interested in was: 288d579.
I've been finding that test_get_spec has been failing on my dev system and I'm curious if that failure is addressed by your commit? If so, are you able to include that here?

@bollwyvl
Copy link
Contributor Author

Re: 288d579 yeah, MANIFEST.in probably needs some gardening. It's yet another thing that doesn't really work the way anyone expects it would.

The only way to be sure on this particular gotcha:

  • have a test that exercises every file expected to appear
  • build the whl/sdist, install it, and test that, not whatever happens to be in the repo
    • tox actually does this by default, and a lot else... may be worth considering...

@bollwyvl
Copy link
Contributor Author

windows. ALWAYS WINDOWS. i think we have a winner here: smells like a ProactorLoop thing. Somebody may need to kill that job (don't think I can)...

@bollwyvl bollwyvl changed the title remove pytest11 entrypoint Remove pytest11 entrypoint and plugin, require tornado 6.1, remove asyncio patch, CI work Nov 14, 2020
@bollwyvl
Copy link
Contributor Author

Alright: codecov aside (didn't dig into what it was comparing against) this is ready for more serious review. Some of the changes to the test_file stuff could be reverted, but the parameterization is good for debuggability (e.g. what else would have broken, had the first thing tested not broken).

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

Thanks for the great work here Nick - it's much appreciated. I just had the few comments.

Regarding the empty tests/conftest.py file - is that necessary?

# fallback to the pre-3.8 default of Selector
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
"""no longer needed with tornado 6.1"""
warnings.warn(
Copy link
Member

Choose a reason for hiding this comment

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

Should this remain behind a windows-3.8 check or be removed altogether? I understand its purpose, but now folks not on Windows-py3.8 systems will get this warning when it never applied to them in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed entirely... but while hidden behind a "private" member, I wouldn't rule out people having used it to avoid The Condition. Could just be removed immediately, but a release with a warning seems reasonable vs Your Stuff Breaks Now.

Copy link
Member

Choose a reason for hiding this comment

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

Right on. I missed that the call server makes has been removed. This makes perfect sense - thanks.

@@ -6,7 +6,7 @@ include CHANGELOG.md
include setupbase.py

# include everything in package_data
include jupyter_server/**/*
recursive-include jupyter_server *
Copy link
Member

Choose a reason for hiding this comment

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

Good catch - thanks.

@@ -34,11 +34,14 @@ def add_data_files(path):
version = VERSION,
description = 'Jupyter Server Example',
long_description = open('README.md').read(),
python_requires = '>=3.5',
python_requires = '>=3.6',
Copy link
Member

Choose a reason for hiding this comment

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

I guess I'm not following the skull & crossbones commentary here, sorry about that. The change seems fine.


async def fetch_expect_404(jp_fetch, *path_parts):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
r = await jp_fetch('files', *path_parts, method='GET')
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice update - thank you.

Would you mind removing the unused variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in da0fef5

@bollwyvl
Copy link
Contributor Author

Hate that codecov ❌ ... trying to fix on this PR seems out of scope, though 😢 Otherwise back to green, review issues about addressed, hopefully...

assert tornado.version_info >= MIN_TORNADO
except (ImportError, AttributeError, AssertionError) as e: # pragma: no cover
raise ImportError(
_("The Jupyter Server requires tornado >=%s", ".".join(MIN_TORNADO))
Copy link
Member

Choose a reason for hiding this comment

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

The version info isn't getting formatted into the string prior to its translation. Do the tuple elements also need to be strings for the join to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! Fixed in e09ba05

# fallback to the pre-3.8 default of Selector
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
"""no longer needed with tornado 6.1"""
warnings.warn(
Copy link
Member

Choose a reason for hiding this comment

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

Right on. I missed that the call server makes has been removed. This makes perfect sense - thanks.

assert tornado.version_info >= MIN_TORNADO
except (ImportError, AttributeError, AssertionError) as e: # pragma: no cover
raise ImportError(
_("The Jupyter Server requires tornado >=%s.%s.%s", *MIN_TORNADO)
Copy link
Member

Choose a reason for hiding this comment

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

This still isn't handling things correctly. How about we just cut to the chase?

Suggested change
_("The Jupyter Server requires tornado >=%s.%s.%s", *MIN_TORNADO)
_(f"The Jupyter Server requires tornado >= {MIN_TORNADO[0]}.{MIN_TORNADO[1]}.{MIN_TORNADO[2]}")

@bollwyvl
Copy link
Contributor Author

bollwyvl commented Nov 16, 2020 via email

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

Thanks Nick!

Copy link
Member

@Zsailer Zsailer left a comment

Choose a reason for hiding this comment

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

Thanks, @bollwyvl! LGTM.

@Zsailer Zsailer merged commit 5c31111 into jupyter-server:master Nov 17, 2020
Zsailer added a commit that referenced this pull request Dec 8, 2020
Pin 1.0.x to tornado 6.1, remove asyncio patch [backport pieces of #339]
Zsailer added a commit to Zsailer/jupyter_server that referenced this pull request Nov 18, 2022
hMED22 pushed a commit to hMED22/jupyter_server that referenced this pull request Jan 23, 2023
-no-entrypoint

Remove pytest11 entrypoint and plugin, require tornado 6.1, remove asyncio patch, CI work
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.

pytest_tornasync becomes hard dependency if pytest is installed
3 participants