Fix ModelVersion.load in Container Runtime notebooks: download via session.file.get - #241
Open
haoweiyu-kumo wants to merge 1 commit into
Open
Conversation
ModelVersionSQLClient.get_file's non-stored-procedure branch runs a raw `GET snow://model/... file://...` through DataFrame.collect(). In environments that wrap collect() -- e.g. Snowflake Container Runtime notebooks patch it into a cancellable async job -- a GET has no result set that can be replayed via result_scan, so ModelVersion.load() fails with `ProgrammingError 000710 (02000): Result for query <id> has expired`. Use session.file.get (the FileOperation API that mirrors the session.file.put used when logging a model); it goes through the connector file-transfer path and does not depend on collect(). This also makes upload/download symmetric. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
haoweiyu-kumo
force-pushed
the
fix/get-file-use-fileoperation
branch
from
July 28, 2026 18:12
7090bef to
c762b41
Compare
Collaborator
|
Thanks for the PR @haoweiyu-kumo . We will incorporate this fix into an upcoming release. |
Collaborator
|
@haoweiyu-kumo Out of curiosity, what is the reason for using mv.load in a container runtime environment? Are you trying to do inference in the container runtime instead of via the model registry (via mv.run or in SPCS), or is there some other reason? |
Author
|
Yeah, I am trying to do batch inference in side notebook. I can just launch a dedicated SPCS job ( via mv.run_batch ). I am not sure if that's the "standard" way of DS doing batch prediction during development cycle. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ModelVersion.load()fails inside a Snowflake Container Runtime notebook with:The notebook runtime monkeypatches
DataFrame.collect()into a cancellable async job (snowflake_notebook_utils.session_bootstrap), which re-fetches results viaresult_scan(<sfqid>).ModelVersionSQLClient.get_filedownloads model files in its non-stored-procedure branch by running a rawGET snow://model/... file://...throughsession.sql(...).collect(). AGETproduces no result set thatresult_scancan replay, so the async re-fetch returns "expired" andload()blows up.Notably, upload works (
log_model) because it usessession.file.put(file_utils.upload_directory_to_stage), which goes through the connector file-transfer path rather thancollect(). The download path was asymmetric.Fix
Download via
session.file.get— theFileOperationAPI symmetric to thesession.file.putused when logging a model. It uses the connector file-transfer path and does not depend oncollect(), so it is unaffected by the notebook's cancellable-collect patch.snow://is already an accepted GET prefix (SNOWURL_PREFIX), so the registry stage URL works unchanged.The stored-procedure branch (which already uses the low-level
cursor._download) is untouched. The previoushas_dimensions(expected_rows=1)assertion is preserved as an explicit check that exactly one file was downloaded.Impact
ModelVersion.load()/ model download in Container Runtime notebooks.FileOperationAPI.