API Reference / cli /

create_algorithm.py

tuiml create-algorithm: register a user-authored algorithm.

Thin CLI wrapper over the tuiml_create_algorithm tool. It stores the submitted source under ~/.tuiml/user_algorithms/ and adds the class to the component registry, so the rest of the CLI and every MCP tool can use it by class name.

Functions

Command

tuiml create-algorithm

Line 21
tuiml create-algorithm [OPTIONS]

Validate, save, and register a new user-authored algorithm.

The source must define exactly one @classifier or @regressor class. It is checked with an AST denylist before anything is written (no subprocess, socket, os, urllib or requests imports; no eval, exec, open or __import__ calls), then saved to ~/.tuiml/user_algorithms///algorithm.py.

Once saved the class is added to the component registry under its own class name, so every other command and MCP tool (tuiml train, tuiml describe, tuiml_benchmark) can use it immediately. Each version is also registered under the pinned alias _v__ , so two versions of the same algorithm can compete in a single experiment.

Requires TUIML_ALLOW_USER_ALGORITHMS=1 in the environment.

Register a classifier whose source lives in a local file:

bash
$ tuiml create-algorithm --name MyKNN --kind classifier \
    --code "$(cat my_knn.py)"

Submit an explicit version and description:

bash
$ tuiml create-algorithm --name MyKNN --kind classifier --version 1.1.0 \
    --description "kNN with distance weighting" --code "$(cat my_knn.py)"

Overwrite an existing version instead of bumping it, printing raw JSON:

bash
$ tuiml create-algorithm --name MyKNN --kind classifier \
    --code "$(cat my_knn.py)" --force --json-output

Options

--name
str required
Directory name, usually equal to the class name (Python identifier).
--kind
str required
Task kind: 'classifier' or 'regressor'. Must match the decorator on the submitted class.
--code
str required
Full Python source. Must define exactly one @classifier or @regressor class.
--version
str
Semver (MAJOR.MINOR.PATCH) for this submission, e.g. '1.0.1'. Defaults to '1.0.0'.
--description
str
Optional short description (falls back to the class docstring).
--force/--no-force
= False
Overwrite an existing <name>/<version>/ on disk. Prefer bumping --version instead.
--json-output
flag
Print the raw JSON result.