A Vertex AI prebuilt container supplies a configured runtime for executing custom model-training code inside an ML pipeline. The training code must run as a standalone script rather than depend on a local notebook environment. section 11.3.5 section 11.1.2
Prepare the training script for the container by:
- Removing notebook-only imports, visualizations, and dataset-splitting code handled by the Vertex AI SDK. section 11.3.5
- Reading configuration and dataset locations from command-line arguments, Cloud Storage URIs, and AIP environment variables. section 11.3.5
- Writing the trained model to the output directory supplied by the Vertex AI SDK. section 11.3.5
Kuala Lumpur property-price model
A notebook-trained property-price model becomes a container-compatible training script by downloading its configuration from Cloud Storage, assembling train, validation, and test dataframes from URI patterns, and saving the model to the SDK-provided output location. section 11.3.5 section 11.5
Listing 11.3 Copying AIP environment variable values
def assign_container_env_variables():
OUTPUT_MODEL_DIR = os.getenv("AIP_MODEL_DIR") #1
TRAIN_DATA_PATTERN = \
os.getenv("AIP_TRAINING_DATA_URI") #2
EVAL_DATA_PATTERN = \
os.getenv("AIP_VALIDATION_DATA_URI") #3
TEST_DATA_PATTERN = \
os.getenv("AIP_TEST_DATA_URI") #4
return OUTPUT_MODEL_DIR, TRAIN_DATA_PATTERN, \
EVAL_DATA_PATTERN, TEST_DATA_PATTERN
Inspect the environment-variable pattern used to obtain the model output directory and training, validation, and test data locations. section 11.3.5
