Skip to content

Field

metaxy.FieldSpec pydantic-model

FieldSpec(
    *,
    key: CoercibleToFieldKey | None = None,
    code_version: str = DEFAULT_CODE_VERSION,
    deps: SpecialFieldDep | list[FieldDep] | None = None,
)

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": {
      "additionalProperties": false,
      "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"
    }
  },
  "additionalProperties": false,
  "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"
}

Config:

  • default: {'extra': 'forbid'}

Fields:

Source code in src/metaxy/models/field.py
def __init__(
    self,
    *,
    key: CoercibleToFieldKey | None = None,
    code_version: str = DEFAULT_CODE_VERSION,
    deps: SpecialFieldDep | list[FieldDep] | None = None,
) -> None: ...

Functions

metaxy.FieldSpec.__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type, handler)

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,
)

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"
    }
  },
  "additionalProperties": false,
  "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"
}

Config:

  • default: {'extra': 'forbid'}

Fields:

Source code in src/metaxy/models/field.py
def __init__(
    self,
    *,
    feature: str | Sequence[str] | FeatureKey | "FeatureSpec" | type["BaseFeature"],
    fields: list[CoercibleToFieldKey] | Literal[SpecialFieldDep.ALL] = SpecialFieldDep.ALL,
) -> None: ...