Skip to content

SNOW-3034995: Add cloudpickle automatically when using artifact_repository with packages#4067

Closed
sfc-gh-aling wants to merge 1 commit intomainfrom
SNOW-3034995-verisk-analytics-add-support-for-artifact-repo-packages-in-snowpark-connect
Closed

SNOW-3034995: Add cloudpickle automatically when using artifact_repository with packages#4067
sfc-gh-aling wants to merge 1 commit intomainfrom
SNOW-3034995-verisk-analytics-add-support-for-artifact-repo-packages-in-snowpark-connect

Conversation

@sfc-gh-aling
Copy link
Contributor

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

    Fixes SNOW-3034995

  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.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
    • If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: AST Support Guidelines
  3. Please describe how your code solves the related issue.

Problem
When using artifact_repository with custom packages, cloudpickle was not automatically added to the package list, causing ModuleNotFoundError: No module named 'cloudpickle' at runtime in UDF execution.
Root Cause
In src/snowflake/snowpark/_internal/udf_utils.py (lines 1232-1237), when both artifact_repository and packages were provided, the code directly assigned resolved_packages = packages without calling session._resolve_packages(), which meant cloudpickle was never added to the dependency list.
Solution
Added logic to automatically include cloudpickle when using artifact repositories with custom packages:

  • Check for cloudpickle: After assigning the packages list, check if cloudpickle is already present using Requirement(pkg).name.lower() to handle all version specifiers (==, >=, <=, ~=, etc.)
  • Auto-add if missing: If cloudpickle is not found, append cloudpickle=={version} to the package list
  • Preserve user choice: If user already specified cloudpickle with any version constraint, respect it and don't duplicate

@sfc-gh-aling sfc-gh-aling requested review from a team as code owners February 3, 2026 00:37
@sfc-gh-aling sfc-gh-aling changed the title SNOW-3034995: SNOW-3034995: Add cloudpickle automatically when using artifact_repository with packages Feb 3, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
@sfc-gh-aling sfc-gh-aling deleted the SNOW-3034995-verisk-analytics-add-support-for-artifact-repo-packages-in-snowpark-connect branch February 3, 2026 00:38
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.

1 participant