@@ -161,6 +161,9 @@ def transform(self, fn_spec: op.FunctionSpec, *args, **kwargs) -> DataSlice:
161
161
"""
162
162
Apply a function to the data slice.
163
163
"""
164
+ if not isinstance (fn_spec , op .FunctionSpec ):
165
+ raise ValueError ("transform() can only be called on a CocoIndex function" )
166
+
164
167
transform_args : list [tuple [Any , str | None ]]
165
168
transform_args = [(self ._state .engine_data_slice , None )]
166
169
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, /, *,
280
283
281
284
`vector_index` is for backward compatibility only. Please use `vector_indexes` instead.
282
285
"""
286
+ if not isinstance (target_spec , op .StorageSpec ):
287
+ raise ValueError ("export() can only be called on a CocoIndex target storage" )
288
+
283
289
# For backward compatibility only.
284
290
if len (vector_indexes ) == 0 and len (vector_index ) > 0 :
285
291
vector_indexes = [index .VectorIndexDef (field_name = field_name , metric = metric )
@@ -343,8 +349,10 @@ def add_source(self, spec: op.SourceSpec, /, *,
343
349
refresh_interval : datetime .timedelta | None = None ,
344
350
) -> DataSlice :
345
351
"""
346
- Add a source to the flow.
352
+ Import a source to the flow.
347
353
"""
354
+ if not isinstance (spec , op .SourceSpec ):
355
+ raise ValueError ("add_source() can only be called on a CocoIndex source" )
348
356
return _create_data_slice (
349
357
self ._state ,
350
358
lambda target_scope , name : self ._state .engine_flow_builder .add_source (
0 commit comments