Skip to content

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

Merged
sfc-gh-aling merged 13 commits intomainfrom
SNOW-3034995-add-cloudpickle-for-artifact-repo
Feb 5, 2026
Merged

SNOW-3034995: Add cloudpickle automatically when using artifact_repository with packages#4068
sfc-gh-aling merged 13 commits intomainfrom
SNOW-3034995-add-cloudpickle-for-artifact-repo

Conversation

@sfc-gh-aling
Copy link
Contributor

@sfc-gh-aling sfc-gh-aling commented Feb 3, 2026

  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 prefix match
  • 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

Copy link
Contributor

@sfc-gh-bkogan sfc-gh-bkogan left a comment

Choose a reason for hiding this comment

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

Thanks

@sfc-gh-aling sfc-gh-aling merged commit d2e7450 into main Feb 5, 2026
26 of 29 checks passed
@sfc-gh-aling sfc-gh-aling deleted the SNOW-3034995-add-cloudpickle-for-artifact-repo branch February 5, 2026 21:52
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2026
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.

4 participants