@@ -161,6 +161,9 @@ def transform(self, fn_spec: op.FunctionSpec, *args, **kwargs) -> DataSlice:
161161 """
162162 Apply a function to the data slice.
163163 """
164+ if not isinstance (fn_spec , op .FunctionSpec ):
165+ raise ValueError ("transform() can only be called on a CocoIndex function" )
166+
164167 transform_args : list [tuple [Any , str | None ]]
165168 transform_args = [(self ._state .engine_data_slice , None )]
166169 transform_args += [(self ._state .flow_builder_state .get_data_slice (v ), None ) for v in args ]
@@ -280,6 +283,9 @@ def export(self, name: str, target_spec: op.StorageSpec, /, *,
280283
281284 `vector_index` is for backward compatibility only. Please use `vector_indexes` instead.
282285 """
286+ if not isinstance (target_spec , op .StorageSpec ):
287+ raise ValueError ("export() can only be called on a CocoIndex target storage" )
288+
283289 # For backward compatibility only.
284290 if len (vector_indexes ) == 0 and len (vector_index ) > 0 :
285291 vector_indexes = [index .VectorIndexDef (field_name = field_name , metric = metric )
@@ -343,8 +349,10 @@ def add_source(self, spec: op.SourceSpec, /, *,
343349 refresh_interval : datetime .timedelta | None = None ,
344350 ) -> DataSlice :
345351 """
346- Add a source to the flow.
352+ Import a source to the flow.
347353 """
354+ if not isinstance (spec , op .SourceSpec ):
355+ raise ValueError ("add_source() can only be called on a CocoIndex source" )
348356 return _create_data_slice (
349357 self ._state ,
350358 lambda target_scope , name : self ._state .engine_flow_builder .add_source (
0 commit comments