Skip to content

Commit cc7ebb1

Browse files
committed
feat(custom-target): pass indexing options to target connector
1 parent bb7c0ad commit cc7ebb1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

python/cocoindex/op.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
FieldSchema,
3838
)
3939
from .runtime import to_async_call
40+
from .index import IndexOptions
4041

4142

4243
class OpCategory(Enum):
@@ -430,6 +431,7 @@ class _TargetConnectorContext:
430431
key_decoder: Callable[[Any], Any]
431432
value_fields_schema: list[FieldSchema]
432433
value_decoder: Callable[[Any], Any]
434+
index_options: IndexOptions
433435

434436

435437
def _build_args(
@@ -543,6 +545,7 @@ def create_export_context(
543545
raw_spec: dict[str, Any],
544546
raw_key_fields_schema: list[Any],
545547
raw_value_fields_schema: list[Any],
548+
raw_index_options: dict[str, Any],
546549
) -> _TargetConnectorContext:
547550
key_annotation, value_annotation = (
548551
(
@@ -563,6 +566,7 @@ def create_export_context(
563566
)
564567

565568
spec = load_engine_object(self._spec_cls, raw_spec)
569+
index_options = load_engine_object(IndexOptions, raw_index_options)
566570
return _TargetConnectorContext(
567571
target_name=name,
568572
spec=spec,
@@ -571,6 +575,7 @@ def create_export_context(
571575
key_decoder=key_decoder,
572576
value_fields_schema=value_fields_schema,
573577
value_decoder=value_decoder,
578+
index_options=index_options,
574579
)
575580

576581
def get_persistent_key(self, export_context: _TargetConnectorContext) -> Any:
@@ -597,6 +602,7 @@ def get_setup_state(self, export_context: _TargetConnectorContext) -> Any:
597602
spec=export_context.spec,
598603
key_fields_schema=export_context.key_fields_schema,
599604
value_fields_schema=export_context.value_fields_schema,
605+
index_options=export_context.index_options,
600606
)
601607
state = get_persistent_state_fn(*args)
602608
if not isinstance(state, self._state_cls):

src/ops/py_factory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl interface::TargetFactory for PyExportTargetFactory {
295295
pythonize(py, &data_collection.spec)?,
296296
pythonize(py, &data_collection.key_fields_schema)?,
297297
pythonize(py, &data_collection.value_fields_schema)?,
298+
pythonize(py, &data_collection.index_options)?,
298299
),
299300
None,
300301
)

0 commit comments

Comments
 (0)