-
Notifications
You must be signed in to change notification settings - Fork 53
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
MNT enable doctests #57
Conversation
Going to address #58 in this PR as well. I'll ping when ready. |
@@ -194,7 +194,7 @@ class Card: | |||
>>> from sklearn.linear_model import LogisticRegression | |||
>>> from skops import card | |||
>>> X, y = load_iris(return_X_y=True) | |||
>>> model = LogisticRegression(random_state=0).fit(X, y) | |||
>>> model = LogisticRegression(solver="liblinear", random_state=0).fit(X, y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the convergence warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, this LGTM and can be merged.
When testing this, I had, however, a problem I have not encountered yet. When running
HF_HUB_TOKEN=... pytest
I get this error:
_______________________________________________________________________________________________________________ ERROR collecting docs/auto_examples/plot_hf_hub.py _______________________________________________________________________________________________________________
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('plot_hf_hub', '/home/vinh/work/forks/skops/docs/_build/html/_downloads/2032e07369644f9c24738f10000c87c8/plot_hf_hub.py', PosixPath('/home/vinh/work/forks/skops/docs/auto_examples/plot_hf_hub.py'))
_____________________________________________________________________________________________________________ ERROR collecting docs/auto_examples/plot_model_card.py _____________________________________________________________________________________________________________
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('plot_model_card', '/home/vinh/work/forks/skops/docs/_build/html/_downloads/72a607ff8c7821f84fc735322deb04db/plot_model_card.py', PosixPath('/home/vinh/work/forks/skops/docs/auto_examples/plot_model_card.py'))
____________________________________________________________________________________________________________________ ERROR collecting examples/plot_hf_hub.py ____________________________________________________________________________________________________________________
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('plot_hf_hub', '/home/vinh/work/forks/skops/docs/_build/html/_downloads/2032e07369644f9c24738f10000c87c8/plot_hf_hub.py', PosixPath('/home/vinh/work/forks/skops/examples/plot_hf_hub.py'))
__________________________________________________________________________________________________________________ ERROR collecting examples/plot_model_card.py __________________________________________________________________________________________________________________
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:338: in from_call
result: Optional[TResult] = func()
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/runner.py:369: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/doctest.py:545: in collect
module = import_path(self.path, root=self.config.rootpath)
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/pathlib.py:556: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('plot_model_card', '/home/vinh/work/forks/skops/docs/_build/html/_downloads/72a607ff8c7821f84fc735322deb04db/plot_model_card.py', PosixPath('/home/vinh/work/forks/skops/examples/plot_model_card.py'))
____________________________________________________________________________________________________________________ ERROR collecting scripts/clean_skops.py _____________________________________________________________________________________________________________________
scripts/clean_skops.py:15: in <module>
answer = input(
../../../anaconda3/envs/skops/lib/python3.10/site-packages/_pytest/capture.py:192: in read
raise OSError(
E OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
The same does not happen on main. When running with -s
, I see the culprit, namely that the clean_skops.py
script is being called, which asks for user input and then waits, leading to the pytest error. It is unclear to me why running doctests calls the script.
Another point: The doctests are relatively slow. Is it possible to add an option to exclude them, like with -m "not network"
?
I'd ignore the On the speed, I don't notice anything too slow, and I'm quite happy with the speed. But I also don't run tests on save or anything. I'm happy if you want to add that marker if it's easy to add, in a separate PR. |
Yes, it was just surprising to me why the script is being called after enabling doctests. I was just lazy so far and skipped adding |
not sure. I feel like that's kinda taking control from the user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
True |
This PR makes sure we run doctests as well as normal tests.
doctests are the code we have in our documentation, such as docstrings' examples.
cc @skops-dev/maintainers
Fixes #58