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

SNOW-1461192: Fix StringMethods and DatetimeProperties docs #1741

Merged
merged 7 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/snowflake/snowpark/modin/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@
DocModule.put(docstrings.__name__)


# We cannot call ModinDocModule.put directly because it will produce a call to `importlib.reload`
# that will overwrite our extensions. We instead directly call the _inherit_docstrings annotation
# See https://github.com/modin-project/modin/issues/7122
import modin.utils # type: ignore[import] # isort: skip # noqa: E402
import modin.pandas.series_utils # type: ignore[import] # isort: skip # noqa: E402

modin.utils._inherit_docstrings(
Copy link
Contributor

Choose a reason for hiding this comment

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

good solution!

docstrings.series_utils.StringMethods,
overwrite_existing=True,
)(modin.pandas.series_utils.StringMethods)

modin.utils._inherit_docstrings(
docstrings.series_utils.CombinedDatetimelikeProperties,
overwrite_existing=True,
)(modin.pandas.series_utils.DatetimeProperties)

# Don't warn the user about our internal usage of private preview pivot
# features. The user should have already been warned that Snowpark pandas
# is in public or private preview. They likely don't know or care that we are
Expand Down
25 changes: 24 additions & 1 deletion tests/unit/modin/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,32 @@
#

import modin.pandas as pd
import pandas as native_pd

import snowflake.snowpark.modin.plugin # noqa: F401
import snowflake.snowpark.modin.plugin as plugin


def test_base_property_snow_1305329():
assert "Snowpark pandas" in pd.base.BasePandasDataset.iloc.__doc__


def test_series_utils_snow_1461192():
# Checks that StringMethods and DatetimeProperties correctly inherit documentation
# Series.dt.date differs from pandas because we don't support DatetimeIndex
assert (
pd.series_utils.DatetimeProperties.date.__doc__
!= native_pd.core.indexes.accessors.DatetimeProperties.date.__doc__
)
assert (
pd.series_utils.DatetimeProperties.date.__doc__
== plugin.docstrings.CombinedDatetimelikeProperties.date.__doc__
)
# Series.str.split differs from pandas because we don't yet support the `regex` arg
assert (
pd.series_utils.StringMethods.split.__doc__
!= native_pd.core.strings.accessor.StringMethods.split.__doc__
)
assert (
pd.series_utils.StringMethods.split.__doc__
== plugin.docstrings.StringMethods.split.__doc__
)
Loading