Field¶
metaxy.FieldKey
¶
Bases: _Key
Field key as a sequence of string parts.
Hashable for use as dict keys in registries. Parts cannot contain forward slashes (/) or double underscores (__).
Example:
```py
FieldKey("a/b/c") # String format
# FieldKey(parts=['a', 'b', 'c'])
FieldKey(["a", "b", "c"]) # List format
# FieldKey(parts=['a', 'b', 'c'])
FieldKey(FieldKey(["a", "b", "c"])) # FieldKey copy
# FieldKey(parts=['a', 'b', 'c'])
```
Source code in src/metaxy/models/types.py
Attributes¶
metaxy.FieldKey.parts
property
¶
Backward compatibility property for accessing root as parts.
metaxy.FieldKey.table_name
property
¶
table_name: str
Get SQL-like table name for this feature key.
Replaces hyphens with underscores for SQL compatibility.
Functions¶
metaxy.FieldKey.__lt__
¶
metaxy.FieldKey.__le__
¶
metaxy.FieldKey.__gt__
¶
metaxy.FieldKey.__ge__
¶
metaxy.FieldKey.__iter__
¶
metaxy.FieldKey.__getitem__
¶
metaxy.FieldKey.__contains__
¶
metaxy.FieldKey.__reversed__
¶
metaxy.FieldKey.model_dump
¶
Serialize to list format for backward compatibility.
metaxy.FieldKey.__eq__
¶
metaxy.FieldSpec
pydantic-model
¶
FieldSpec(key: CoercibleToFieldKey, code_version: str = DEFAULT_CODE_VERSION, deps: SpecialFieldDep | list[FieldDep] | None = None, *args, **kwargs: Any)
Bases: BaseModel
Show JSON schema:
{
"$defs": {
"FeatureKey": {
"description": "Feature key as a sequence of string parts.\n\nHashable for use as dict keys in registries.\nParts cannot contain forward slashes (/) or double underscores (__).\n\nExample:\n\n ```py\n FeatureKey(\"a/b/c\") # String format\n # FeatureKey(parts=['a', 'b', 'c'])\n\n FeatureKey([\"a\", \"b\", \"c\"]) # List format\n # FeatureKey(parts=['a', 'b', 'c'])\n\n FeatureKey(FeatureKey([\"a\", \"b\", \"c\"])) # FeatureKey copy\n # FeatureKey(parts=['a', 'b', 'c'])\n ```",
"items": {
"type": "string"
},
"title": "FeatureKey",
"type": "array"
},
"FieldDep": {
"properties": {
"feature": {
"$ref": "#/$defs/FeatureKey"
},
"fields": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/FieldKey"
},
"type": "array"
},
{
"const": "__METAXY_ALL_DEP__",
"type": "string"
}
],
"default": "__METAXY_ALL_DEP__",
"title": "Fields"
}
},
"required": [
"feature"
],
"title": "FieldDep",
"type": "object"
},
"FieldKey": {
"description": "Field key as a sequence of string parts.\n\nHashable for use as dict keys in registries.\nParts cannot contain forward slashes (/) or double underscores (__).\n\nExample:\n\n ```py\n FieldKey(\"a/b/c\") # String format\n # FieldKey(parts=['a', 'b', 'c'])\n\n FieldKey([\"a\", \"b\", \"c\"]) # List format\n # FieldKey(parts=['a', 'b', 'c'])\n\n FieldKey(FieldKey([\"a\", \"b\", \"c\"])) # FieldKey copy\n # FieldKey(parts=['a', 'b', 'c'])\n ```",
"items": {
"type": "string"
},
"title": "FieldKey",
"type": "array"
},
"SpecialFieldDep": {
"enum": [
"__METAXY_ALL_DEP__"
],
"title": "SpecialFieldDep",
"type": "string"
}
},
"properties": {
"key": {
"$ref": "#/$defs/FieldKey"
},
"code_version": {
"default": "__metaxy_initial__",
"title": "Code Version",
"type": "string"
},
"deps": {
"anyOf": [
{
"$ref": "#/$defs/SpecialFieldDep"
},
{
"items": {
"$ref": "#/$defs/FieldDep"
},
"type": "array"
}
],
"title": "Deps"
}
},
"title": "FieldSpec",
"type": "object"
}
Fields:
Source code in src/metaxy/models/field.py
def __init__(
self,
key: CoercibleToFieldKey,
code_version: str = DEFAULT_CODE_VERSION,
deps: SpecialFieldDep | list[FieldDep] | None = None,
*args,
**kwargs: Any,
) -> None:
validated_key = FieldKeyAdapter.validate_python(key)
# Handle None deps - use empty list as default
if deps is None:
deps = []
super().__init__(
key=validated_key,
code_version=code_version,
deps=deps,
*args,
**kwargs,
)
Functions¶
metaxy.FieldSpec.__get_pydantic_core_schema__
classmethod
¶
Add custom validator to coerce strings to FieldSpec.
Source code in src/metaxy/models/field.py
@classmethod
def __get_pydantic_core_schema__(cls, source_type, handler):
"""Add custom validator to coerce strings to FieldSpec."""
from pydantic_core import core_schema
# Get the default schema
python_schema = handler(source_type)
# Wrap it with a before validator that converts strings
return core_schema.no_info_before_validator_function(
_validate_field_spec_from_string,
python_schema,
)
metaxy.FieldDep
pydantic-model
¶
FieldDep(feature: str | Sequence[str] | FeatureKey | FeatureSpec | type[BaseFeature], fields: list[CoercibleToFieldKey] | Literal[ALL] = ALL, **kwargs: Any)
Bases: BaseModel
Show JSON schema:
{
"$defs": {
"FeatureKey": {
"description": "Feature key as a sequence of string parts.\n\nHashable for use as dict keys in registries.\nParts cannot contain forward slashes (/) or double underscores (__).\n\nExample:\n\n ```py\n FeatureKey(\"a/b/c\") # String format\n # FeatureKey(parts=['a', 'b', 'c'])\n\n FeatureKey([\"a\", \"b\", \"c\"]) # List format\n # FeatureKey(parts=['a', 'b', 'c'])\n\n FeatureKey(FeatureKey([\"a\", \"b\", \"c\"])) # FeatureKey copy\n # FeatureKey(parts=['a', 'b', 'c'])\n ```",
"items": {
"type": "string"
},
"title": "FeatureKey",
"type": "array"
},
"FieldKey": {
"description": "Field key as a sequence of string parts.\n\nHashable for use as dict keys in registries.\nParts cannot contain forward slashes (/) or double underscores (__).\n\nExample:\n\n ```py\n FieldKey(\"a/b/c\") # String format\n # FieldKey(parts=['a', 'b', 'c'])\n\n FieldKey([\"a\", \"b\", \"c\"]) # List format\n # FieldKey(parts=['a', 'b', 'c'])\n\n FieldKey(FieldKey([\"a\", \"b\", \"c\"])) # FieldKey copy\n # FieldKey(parts=['a', 'b', 'c'])\n ```",
"items": {
"type": "string"
},
"title": "FieldKey",
"type": "array"
}
},
"properties": {
"feature": {
"$ref": "#/$defs/FeatureKey"
},
"fields": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/FieldKey"
},
"type": "array"
},
{
"const": "__METAXY_ALL_DEP__",
"type": "string"
}
],
"default": "__METAXY_ALL_DEP__",
"title": "Fields"
}
},
"required": [
"feature"
],
"title": "FieldDep",
"type": "object"
}
Fields:
-
feature(FeatureKey) -
fields(list[FieldKey] | Literal[ALL])
Source code in src/metaxy/models/field.py
def __init__( # pyright: ignore[reportMissingSuperCall]
self,
feature: str
| Sequence[str]
| FeatureKey
| "FeatureSpec"
| type["BaseFeature"],
fields: list[CoercibleToFieldKey]
| Literal[SpecialFieldDep.ALL] = SpecialFieldDep.ALL,
**kwargs: Any,
) -> None: ... # pyright: ignore[reportMissingSuperCall]