tencent cloud

Tencent Cloud TI Platform

Product Introduction
Overview
Product Pricing
Benefits to Customers
Use Cases
Purchase Guide
Billing Overview
Purchase Mode
Renewal Instructions
Overdue Payment Instructions
Security Compliance
Data Security Protection Mechanism
Monitoring, Auditing, and Logging
Security Compliance Qualifications
Quick Start
Platform Usage Preparation
Operation Guide
Model Hub
Task-Based Modeling
Dev Machine
Model Management
Model Evaluation
Online Services
Resource Group Management
Managing Data Sources
Tikit
GPU Virtualization
Practical Tutorial
Deploying and Reasoning of LLM
LLM Training and Evaluation
Built-In Training Image List
Custom Training Image Specification
Angel Training Acceleration Feature Introduction
Implementing Resource Isolation Between Sub-users Based on Tags
API Documentation
History
Introduction
API Category
Making API Requests
Online Service APIs
Data Types
Error Codes
Related Agreement
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Open-Source Software Information
Contact Us

Using Lifecycle Scripts

PDF
Focus Mode
Font Size
Last updated: 2025-05-09 15:35:27

Lifecycle Script Configuration Rules

The lifecycle configuration provides shell scripts that run when a user creates or starts a dev machine instance, enabling users to install custom dependencies and personalize the dev machine environment.
The lifecycle configuration follows the following rules:
Creation script: A script that runs after it is created for the first time when you launch a dev machine instance. The script runs only once.
Startup script: A script that runs on every boot of a dev machine instance, including when it is created for the first time.
After Base64 encoding, each script cannot exceed 16,384 characters.
Each script will run as a root user.
The $PATH environment variable for each script is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin.
Each script runs for a maximum of 5 minutes. A dev machine will fail to start when the time limit is exceeded. It should be avoided to install large dependencies in scripts. You can view the reason for failure on the details page, for example, "startup script timeout."
If an error occurs in scripts, a dev machine will also fail to start. You can view the reason for failure on the details page.
If scripts are copied from the editor to the TI-ONE webpage, ensure that the editor you used to edit the scripts uses the Unix-style orchestration.

Lifecycle Script Best Practices

The following shows a practical case of using the lifecycle configuration:
A lifecycle script runs with root account permissions, and a dev machine process runs as a TI-ONE user. To switch users, you can run sudo -u tione in the script to switch to the TI-ONE user.
The dev machine uses Conda to manage multiple kernels. You can activate conda env to install dependencies for different kernels.
For example, to install Python Fire in the kernel of conda_python3, you can write the startup script as follows:
#!/bin/bash
sudo -u tione -i <<'EOF'

# This will affect only the Jupyter kernel called "conda_python3".
source /opt/conda/bin/activate python3

# Replace fire with the name of the package you want to install.
pip install fire
# You can also perform "conda install" here as well.

source /opt/conda/bin/deactivate

EOF
For example, to install Python Fire in all kernels, you can write the script as follows:
#!/bin/bash
sudo -u tione -i <<'EOF'

# Note that "base" is special environment name, include it there as well.

for env in base /opt/conda/envs/*; do
source /opt/conda/bin/activate $(basename "$env")

# Installing packages in the Jupyter system environment can affect stability of your tione
# Notebook Instance. You can remove this check if you'd like to install Jupyter extensions, etc.
if [ $env = 'JupyterSystemEnv' ]; then
continue
fi

# Replace myPackage with the name of the package you want to install.
pip install fire
# You can also perform "conda install" here as well.

source /opt/conda/bin/deactivate
done

EOF


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback