1212from absl import logging
1313
1414from snowflake import connector , snowpark
15+ from snowflake .ml ._internal import file_utils
1516from snowflake .ml ._internal .utils import formatting , query_result_checker , uri
1617from snowflake .ml .model import (
1718 _deployer ,
2122)
2223from snowflake .ml .registry import _schema
2324from snowflake .ml .utils import telemetry
24- from snowflake .snowpark ._internal import utils
2525
2626if TYPE_CHECKING :
2727 import pandas as pd
@@ -998,6 +998,9 @@ def log_model(
998998 output, which could be inferred by calling `infer_signature` method with sample input data.
999999 sample_input_data: Sample of the input data for the model.
10001000
1001+ Raises:
1002+ TypeError: Raised when both signatures and sample_input_data is not presented. Will be captured locally.
1003+
10011004 Returns:
10021005 String of the auto-generate unique model identifier. None if failed.
10031006 """
@@ -1031,6 +1034,8 @@ def log_model(
10311034 pip_requirements = pip_requirements ,
10321035 sample_input = sample_input_data ,
10331036 )
1037+ else :
1038+ raise TypeError ("Either signature or sample input data should exist for native model packaging." )
10341039 id = self .log_model_path (
10351040 path = tmpdir ,
10361041 type = "snowflake_native" ,
@@ -1174,7 +1179,6 @@ def log_model_path(
11741179 Returns:
11751180 String of the auto-generate unique model identifier.
11761181 """
1177-
11781182 # Copy model from local disk to remote stage.
11791183 fully_qualified_model_stage_name = self ._prepare_model_stage (model_name = name , model_version = version )
11801184
@@ -1183,7 +1187,7 @@ def log_model_path(
11831187 if os .path .isfile (path ):
11841188 self ._session .file .put (path , f"{ fully_qualified_model_stage_name } /data" )
11851189 elif os .path .isdir (path ):
1186- with utils .zip_file_or_directory_to_stream (path , path , add_init_py = True ) as input_stream :
1190+ with file_utils .zip_file_or_directory_to_stream (path , path ) as input_stream :
11871191 self ._session ._conn .upload_stream (
11881192 input_stream = input_stream ,
11891193 stage_location = fully_qualified_model_stage_name ,
0 commit comments