This directory contains sample files demonstrating the usage of various AIHC SDK modules.
Important: AIHC SDK modules require Python 3.5 or higher.
-
AIHC Services: Python 3.5+ (required)
- Uses type annotations and typing module
- All AIHC modules (Job, Dataset, Model, Service, DevInstance, ResourcePool)
-
Other BCE Services: Python 2.7+ (compatible)
- BOS, VPC, BCC, EIP, SCS, RDS, etc. work fine with Python 2.7
Why Python 3.5+?
- AIHC modules use modern Python features for better code quality and IDE support
- Type annotations provide better error detection and documentation
- Python 2.7 reached end-of-life on January 1, 2020
Recommendation: Use Python 3.7 or higher for the best experience.
- aihc_sample.py - Main sample file demonstrating basic usage of all AIHC modules
- aihc_job_sample.py - Sample file for job management operations
- aihc_dataset_sample.py - Sample file for dataset management operations
- aihc_model_sample.py - Sample file for model management operations
- aihc_service_sample.py - Sample file for service management operations
- aihc_devinstance_sample.py - Sample file for development instance management operations
- aihc_resource_pool_sample.py - Sample file for resource pool management operations
The AIHC SDK provides interfaces for the following modules:
- Job Management - Create, query, and manage training jobs
- Dataset Management - Manage datasets and their versions
- Model Management - Manage models and their versions
- Service Management - Manage online services for model deployment
- Development Instance Management - Manage development environments
- Resource Pool Management - Manage resource pools and queues
Before running any samples, please update the configuration in aihc_sample_conf.py:
- Set your
AK(Access Key) andSK(Secret Key) - Verify the
HOSTendpoint is correct for your region
-
Python Version: Python 3.5 or higher (Python 3.7+ recommended)
Check your Python version:
python --version # or python3 --version -
Install Dependencies:
pip install six pycryptodome # or pip3 install six pycryptodome -
Configure Credentials: Update aihc_sample_conf.py
To run any sample file:
# Method 1: Direct execution
python3 aihc_sample.py
# Method 2: As module
python3 -m sample.aihc.aihc_sample
# Method 3: Specific module sample
python3 -m sample.aihc.aihc_job_sample
python3 -m sample.aihc.aihc_dataset_sample
python3 -m sample.aihc.aihc_service_sampleReplace aihc_sample.py with the specific sample file you want to run.
If you are using Python 2.7 for other BCE services (BOS, VPC, etc.), they will continue to work normally. AIHC is an independent module and does not affect other services.
To test Python 2 compatibility on ARM64 Mac, use Docker:
# Run from project root directory
./test_py2_with_docker.shFor detailed Python 2 testing instructions, see PYTHON2_TEST_GUIDE.md in the project root.