Skip to main content

Deploy Algorithms with AI

TDgpt publishes AI skills in tools/tdgpt/skills/ of the source repository. After an AI tool reads a skill's SKILL.md, it can carry out the whole procedure, including dependency checks, file deployment, service restart, and registration verification, instead of you running each step by hand.

The Linux package installs this directory as <install_dir>/skills/, /usr/local/taos/taosanode/skills/ by default, and refreshes it on upgrade; working from source uses tools/tdgpt/skills/ in the repository. The Windows package does not include it, because the deploy script relies on POSIX tools and can only manage Linux targets through the remote mode.

This section describes the supported algorithm types, prerequisites, and usage.

Supported Algorithm Types​

User algorithms are deployed to the Anode's custom_algo_dir, <data_dir>/custom by default, which is /var/lib/taos/taosanode/custom for a native Linux installation. Each type has its own subdirectory and is discovered and called through a different endpoint.

TypeDirectoryRegistration contractDiscovery endpointCall endpoint
ad anomaly detectioncustom/ad/Subclass AbstractAnomalyDetectionService; execute() returns a list of flagsGET /listPOST /anomaly-detect
fc forecastcustom/fc/Subclass AbstractForecastService; execute() returns a result dictGET /listPOST /forecast
classificationcustom/classification/Subclass AbstractClassificationService; execute() returns labelsGET /listPOST /classification
regressioncustom/regression/Subclass AbstractRegressionService; execute() returns predicted valuesGET /listPOST /regression
batch envelopecustom/batch/Class named _X implementing build(ts, values, windows, params)GET /api/v1/analysis/batch/algosPOST /api/v1/analysis/batch

Imputation, correlation, clustering, and series diagnosis have no user extension directory and cannot be extended this way. Dynamically loaded model files and user models that run in their own virtual environment also follow separate paths and are out of scope here.

Two Integration Paths​

The AI tool first decides whether your code already follows the TDgpt class hierarchy, and then either deploys it directly or generates an Adapter.

Your codeWhat happens
Already subclasses the base classes above, or implements batch build()Preflight and deploy directly
Plain function, plain class (such as predict or forecast), CLI script, or third-party model objectAn Adapter is generated: a new entry file subclasses the TDgpt base class and calls your code inside
Multi-file package, model weights, or configuration filesAn Adapter plus these files, deployed next to the entry

Code that does not follow the TDgpt hierarchy is the common case, and the model does not have to be rewritten: the generated Adapter performs the adaptation.

Prerequisites​

  • The host running the AI tool is Linux or macOS. The deploy script relies on POSIX tools (sh, chmod, sha256sum, base64). A Windows host cannot use the local or local Docker mode; it can only manage a Linux target through the remote mode.
  • The target Anode is reachable in one of three ways: a native install on the same host, a Docker container, or a Linux host over SSH.
  • The Anode main virtual environment is detected automatically, or supplied explicitly with a flag.
  • Docker deployments must use a persistent bind mount or named volume for custom_algo_dir, otherwise the algorithms are lost when the container is recreated.

Procedure​

  1. Collect the deployment information: the Anode URL (port 6035 by default), the public algorithm name, the algorithm type, the script path, and the deployment form (local, Docker, or remote).
  2. Let the AI tool load the skill: point it at tools/tdgpt/skills/tdgpt-custom-algorithm/SKILL.md, or open that skill directory.
  3. Preflight with --check to confirm the detected algorithm type, the target paths, and whether dependencies are present. Missing packages are installed only after confirmation.
  4. Deploy: the script copies the entry file, plus any file given with --asset, into the target directory. Docker mode needs a container name, and remote mode needs an SSH target.
  5. Restart the Anode: the script does not restart the service by default and only prints the command. Pass a restart mode to restart automatically.
  6. Verify: check that the algorithm appears in the discovery endpoint of its type, then call the corresponding endpoint once.

Example command:

python3 scripts/deploy_custom_algorithm.py \
--tdgpt-url http://192.168.1.20:6035 \
--model-name my_ad \
--algorithm-type ad \
--script ./my_ad.py \
--deploy-mode remote --ssh root@192.168.1.20 \
--check

Common Options​

OptionDescription
--tdgpt-urlAnode URL, for example http://127.0.0.1:6035
--model-namePublic algorithm name; it must match the name attribute of the class in the script
--scriptPath to the algorithm script
--algorithm-typead, fc, classification, regression, or batch; detected from the script by default
--deploy-modelocal, docker, or remote; detected by default
--containerContainer name for Docker deployments
--sshSSH target for remote deployments, for example root@192.168.1.20
--venv-pythonPython path of the target Anode main virtual environment
--custom-dirOverride custom_algo_dir on the target
--configAnode configuration file path on the target
--restartHow to restart after deployment; defaults to none, which only prints the command
--servicesystemd service name used for the restart
--install-missingInstall missing packages; requires --yes
--checkPreflight only, no deployment
--dry-runResolve and validate only, write nothing
--verify-onlyRerun only the registration and call checks
--assetExtra file or directory deployed next to the entry; repeatable
--allow-ephemeralAllow writing into an unmounted container path, whose content is lost when the container is recreated

Notes​

  • There is no hot reload: the Anode must be restarted before a deployed algorithm takes effect.
  • Built-in algorithms ship with TDgpt and cannot be overridden by placing files under custom/.
  • Models that need their own virtual environment or process isolation use their own integration paths.
  • When packages are missing, the AI tool lists them first and installs only after you confirm.