Skip to content

Commit 2eba6d6

Browse files
authored
refactor: rename related_arg_attr to arg_relationship for clarify (#786)
1 parent 9bd6b67 commit 2eba6d6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

python/cocoindex/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SentenceTransformerEmbed(op.FunctionSpec):
7070
gpu=True,
7171
cache=True,
7272
behavior_version=1,
73-
related_arg_attr=(op.RelatedFieldAttribute.VECTOR_ORIGIN_TEXT, "text"),
73+
arg_relationship=(op.ArgRelationship.VECTOR_ORIGIN_TEXT, "text"),
7474
)
7575
class SentenceTransformerEmbedExecutor:
7676
"""Executor for SentenceTransformerEmbed."""

python/cocoindex/op.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def __call__(
8888
_COCOINDEX_ATTR_PREFIX = "cocoindex.io/"
8989

9090

91-
class RelatedFieldAttribute(Enum):
92-
"""The attribute of a field that is related to the op."""
91+
class ArgRelationship(Enum):
92+
"""Specifies the relationship between an input argument and the output."""
9393

9494
VECTOR_ORIGIN_TEXT = _COCOINDEX_ATTR_PREFIX + "vector_origin_text"
9595
CHUNKS_BASE_TEXT = _COCOINDEX_ATTR_PREFIX + "chunk_base_text"
@@ -103,15 +103,15 @@ class OpArgs:
103103
- cache: Whether the executor will be cached.
104104
- behavior_version: The behavior version of the executor. Cache will be invalidated if it
105105
changes. Must be provided if `cache` is True.
106-
- related_arg_attr: It specifies the relationship between an input argument and the output,
107-
e.g. `(RelatedFieldAttribute.CHUNKS_BASE_TEXT, "content")` means the output is chunks for the
106+
- arg_relationship: It specifies the relationship between an input argument and the output,
107+
e.g. `(ArgRelationship.CHUNKS_BASE_TEXT, "content")` means the output is chunks for the
108108
input argument with name `content`.
109109
"""
110110

111111
gpu: bool = False
112112
cache: bool = False
113113
behavior_version: int | None = None
114-
related_arg_attr: tuple[RelatedFieldAttribute, str] | None = None
114+
arg_relationship: tuple[ArgRelationship, str] | None = None
115115

116116

117117
def _to_async_call(call: Callable[..., Any]) -> Callable[..., Awaitable[Any]]:
@@ -161,8 +161,8 @@ def analyze(
161161
attributes = []
162162

163163
def process_attribute(arg_name: str, arg: _engine.OpArgSchema) -> None:
164-
if op_args.related_arg_attr is not None:
165-
related_attr, related_arg_name = op_args.related_arg_attr
164+
if op_args.arg_relationship is not None:
165+
related_attr, related_arg_name = op_args.arg_relationship
166166
if related_arg_name == arg_name:
167167
attributes.append(
168168
TypeAttr(related_attr.value, arg.analyzed_value)

0 commit comments

Comments
 (0)