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-1625830: Fix circular import when calling to_snowpark_pandas without initializing Snowpark pandas #2097

Merged
merged 7 commits into from
Aug 27, 2024

Conversation

sfc-gh-joshi
Copy link
Contributor

@sfc-gh-joshi sfc-gh-joshi commented Aug 15, 2024

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1625830

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

Calling to_snowpark_pandas on a Snowpark Python DataFrame without first performing import snowflake.snowpark.modin.plugin currently raises an error (see attached JIRA for exact reproduction). This was not the case in previous releases, and this PR fixes internal imports such that performing this operation implicitly initializes Snowpark pandas.

After this PR, when to_snowpark_pandas is called without explicitly initializing Snowpark pandas, one of two things happens:

  1. If modin is not installed, Snowpark pandas will surface the following error:
ModuleNotFoundError: Modin is not installed. Run `pip install "snowflake-snowpark-python[modin]"` to resolve.

This is the same error as if the user had tried to import snowflake.snowpark.modin.plugin without installing the modin dependency.

  1. If modin is installed, Snowpark pandas will implicitly initialize Snowpark pandas by internally running import snowflake.snowpark.modin.plugin. If the user performs import modin.pandas as pd afterwards, the modin namespace will be set up with Snowpark pandas behavior.

@sfc-gh-joshi sfc-gh-joshi requested review from a team as code owners August 15, 2024 00:24
@sfc-gh-joshi sfc-gh-joshi changed the title SNOW-1625380: Fix circular import when calling to_snowpark_pandas without initializing Snowpark pandas SNOW-1625830: Fix circular import when calling to_snowpark_pandas without initializing Snowpark pandas Aug 15, 2024
@sfc-gh-yzou
Copy link
Collaborator

@sfc-gh-joshi it seems your test is failing, can you take a look? can you also start the snowpark python daily test for this change

@sfc-gh-joshi sfc-gh-joshi force-pushed the joshi-SNOW-1625380-to_snowpark_pandas-import branch from 195ba0a to cbd3d28 Compare August 20, 2024 19:29
@sfc-gh-joshi sfc-gh-joshi requested a review from a team as a code owner August 20, 2024 19:29
Copy link

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

1 similar comment
Copy link

Seems like your changes contain some Local Testing changes, please request review from @snowflakedb/local-testing

@sfc-gh-joshi
Copy link
Contributor Author

Daily job run in progress: #2132

Copy link
Contributor

@sfc-gh-helmeleegy sfc-gh-helmeleegy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Jonathan!

@sfc-gh-joshi sfc-gh-joshi force-pushed the joshi-SNOW-1625380-to_snowpark_pandas-import branch from 4457539 to 660365c Compare August 26, 2024 21:47
@sfc-gh-joshi sfc-gh-joshi merged commit 7a156a4 into main Aug 27, 2024
33 of 34 checks passed
@sfc-gh-joshi sfc-gh-joshi deleted the joshi-SNOW-1625380-to_snowpark_pandas-import branch August 27, 2024 00:22
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants