Skip to content

FeatureSelection

metaxy.FeatureSelection pydantic-model

FeatureSelection(
    *,
    projects: Sequence[str] | None = None,
    keys: Sequence[CoercibleToFeatureKey] | None = None,
    all: bool | None = None,
)

Bases: FrozenBaseModel

Selects a set of features from a metadata store.

Fields can be combined — both projects and keys may be set simultaneously to select all features from those projects plus the individually listed keys.

Set all=True to select every feature in the store.

Supports set operators |, &, and - which merge the underlying fields.

Examples:

>>> mx.FeatureSelection(projects=["my-project"])
FeatureSelection(projects=['my-project'], keys=None, all=None)
>>> mx.FeatureSelection(keys=["raw/video", mx.FeatureKey("ml/embeddings")])
FeatureSelection(projects=None, keys=[raw/video, ml/embeddings], all=None)
>>> mx.FeatureSelection(all=True)
FeatureSelection(projects=None, keys=None, all=True)
>>> mx.FeatureSelection(projects=["a"]) | mx.FeatureSelection(projects=["b"])
FeatureSelection(projects=['a', 'b'], keys=None, all=None)
>>> mx.FeatureSelection(keys=["a/b", "c/d"]) & mx.FeatureSelection(keys=["c/d"])
FeatureSelection(projects=None, keys=[c/d], all=None)
>>> mx.FeatureSelection(projects=["a", "b", "c"]) - mx.FeatureSelection(projects=["b"])
FeatureSelection(projects=['a', 'c'], keys=None, all=None)
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"
    }
  },
  "additionalProperties": false,
  "description": "Selects a set of features from a metadata store.\n\nFields can be combined \u2014 both `projects` and `keys` may be set simultaneously\nto select all features from those projects *plus* the individually listed keys.\n\nSet `all=True` to select every feature in the store.\n\nSupports set operators `|`, `&`, and `-` which merge the underlying fields.\n\nExamples:\n    >>> mx.FeatureSelection(projects=[\"my-project\"])\n    FeatureSelection(projects=['my-project'], keys=None, all=None)\n\n    >>> mx.FeatureSelection(keys=[\"raw/video\", mx.FeatureKey(\"ml/embeddings\")])\n    FeatureSelection(projects=None, keys=[raw/video, ml/embeddings], all=None)\n\n    >>> mx.FeatureSelection(all=True)\n    FeatureSelection(projects=None, keys=None, all=True)\n\n    >>> mx.FeatureSelection(projects=[\"a\"]) | mx.FeatureSelection(projects=[\"b\"])\n    FeatureSelection(projects=['a', 'b'], keys=None, all=None)\n\n    >>> mx.FeatureSelection(keys=[\"a/b\", \"c/d\"]) & mx.FeatureSelection(keys=[\"c/d\"])\n    FeatureSelection(projects=None, keys=[c/d], all=None)\n\n    >>> mx.FeatureSelection(projects=[\"a\", \"b\", \"c\"]) - mx.FeatureSelection(projects=[\"b\"])\n    FeatureSelection(projects=['a', 'c'], keys=None, all=None)",
  "properties": {
    "projects": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Projects"
    },
    "keys": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/FeatureKey"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Keys"
    },
    "all": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "All"
    }
  },
  "title": "FeatureSelection",
  "type": "object"
}
Source code in src/metaxy/models/feature_selection.py
def __init__(
    self,
    *,
    projects: Sequence[str] | None = None,
    keys: Sequence[CoercibleToFeatureKey] | None = None,
    all: bool | None = None,
) -> None: ...