MagickMind
PythonResources

Trait (v1)

Reference for magick_mind.resources.v1.trait.

magick_mind.resources.v1.trait

Trait resource for Magick Mind SDK v1 API.

Provides CRUD operations for trait definitions.

TraitResourceV1

class TraitResourceV1(BaseResource)

Trait resource for managing trait definitions.

TraitResourceV1.create

async def create(name: str,
                 namespace: TraitNamespace,
                 category: str,
                 display_name: str,
                 type: TraitType,
                 visibility: TraitVisibility,
                 description: Optional[str] = None,
                 numeric_config: Optional[NumericConfig] = None,
                 categorical_config: Optional[CategoricalConfig] = None,
                 multilabel_config: Optional[MultilabelConfig] = None,
                 default_lock: Optional[LockType] = None,
                 default_learning_rate: float = 0.0,
                 supports_dyadic: bool = False) -> Trait

Create a new trait.

Note: TraitNamespace includes PROMOTED which is not available in Blueprint namespace.

Arguments:

  • name - Trait name
  • namespace - One of SYSTEM, USER, ORG, PROMOTED
  • category - Trait category
  • display_name - Human-readable display name
  • type - One of NUMERIC, CATEGORICAL, MULTILABEL
  • visibility - One of PRIVATE, ORG, PUBLIC
  • description - Optional description
  • numeric_config - Config for NUMERIC traits
  • categorical_config - Config for CATEGORICAL traits
  • multilabel_config - Config for MULTILABEL traits
  • default_lock - One of HARD, SOFT
  • default_learning_rate - Default learning rate (default 0.0)
  • supports_dyadic - Whether trait supports dyadic interactions (default False)

Returns:

Created Trait object

TraitResourceV1.get

async def get(trait_id: str) -> Trait

Get a trait by ID.

Arguments:

  • trait_id - The trait ID to retrieve

Returns:

Trait object

TraitResourceV1.list

async def list(cursor: Optional[str] = None,
               limit: Optional[int] = None,
               order: Optional[str] = None) -> list[Trait]

List traits with optional pagination.

Arguments:

  • cursor - Pagination cursor
  • limit - Max results to return
  • order - Sort order, ASC or DESC

Returns:

List of Trait objects

TraitResourceV1.update

async def update(trait_id: str,
                 category: str,
                 display_name: str,
                 description: str,
                 type: TraitType,
                 default_learning_rate: float,
                 supports_dyadic: bool,
                 visibility: TraitVisibility,
                 numeric_config: Optional[NumericConfig] = None,
                 categorical_config: Optional[CategoricalConfig] = None,
                 multilabel_config: Optional[MultilabelConfig] = None,
                 default_lock: Optional[LockType] = None) -> Trait

Fully replace a trait (PUT).

Note: name and namespace are immutable after creation and cannot be changed.

Arguments:

  • trait_id - The trait ID to update
  • category - Trait category
  • display_name - Human-readable display name
  • description - Trait description
  • type - One of NUMERIC, CATEGORICAL, MULTILABEL
  • default_learning_rate - Default learning rate
  • supports_dyadic - Whether trait supports dyadic interactions
  • visibility - One of PRIVATE, ORG, PUBLIC
  • numeric_config - Config for NUMERIC traits
  • categorical_config - Config for CATEGORICAL traits
  • multilabel_config - Config for MULTILABEL traits
  • default_lock - One of HARD, SOFT

Returns:

Updated Trait object

TraitResourceV1.patch

async def patch(trait_id: str,
                category: Optional[str] = None,
                display_name: Optional[str] = None,
                description: Optional[str] = None,
                type: Optional[TraitType] = None,
                numeric_config: Optional[NumericConfig] = None,
                categorical_config: Optional[CategoricalConfig] = None,
                multilabel_config: Optional[MultilabelConfig] = None,
                default_lock: Optional[LockType] = None,
                default_learning_rate: Optional[float] = None,
                supports_dyadic: Optional[bool] = None,
                visibility: Optional[TraitVisibility] = None) -> Trait

Partially update a trait (PATCH).

Note: name and namespace are immutable after creation and cannot be changed.

Arguments:

  • trait_id - The trait ID to patch
  • category - Trait category
  • display_name - Human-readable display name
  • description - Trait description
  • type - One of NUMERIC, CATEGORICAL, MULTILABEL
  • numeric_config - Config for NUMERIC traits
  • categorical_config - Config for CATEGORICAL traits
  • multilabel_config - Config for MULTILABEL traits
  • default_lock - One of HARD, SOFT
  • default_learning_rate - Default learning rate
  • supports_dyadic - Whether trait supports dyadic interactions
  • visibility - One of PRIVATE, ORG, PUBLIC

Returns:

Updated Trait object

TraitResourceV1.delete

async def delete(trait_id: str) -> None

Delete a trait.

Arguments:

  • trait_id - The trait ID to delete

On this page