in src/sagemaker_xgboost_container/training.py [0:0]
def run_algorithm_mode():
"""Run training in algorithm mode, which does not require a user entry point.
This parses the following environ elements for training:
'SM_INPUT_TRAINING_CONFIG_FILE'
'SM_INPUT_DATA_CONFIG_FILE'
'SM_CHANNEL_TRAIN'
'SM_CHANNEL_VALIDATION'
'SM_HOSTS'
'SM_CURRENT_HOST'
'SM_MODEL_DIR'
'SM_CHECKPOINT_CONFIG_FILE'
"""
# TODO: replace with CSDK constants in sagemaker_containers._env
with open(os.getenv(sm_env_constants.SM_INPUT_TRAINING_CONFIG_FILE), "r") as f:
train_config = json.load(f)
with open(os.getenv(sm_env_constants.SM_INPUT_DATA_CONFIG_FILE), "r") as f:
data_config = json.load(f)
checkpoint_config_file = os.getenv(sm_env_constants.SM_CHECKPOINT_CONFIG_FILE)
if os.path.exists(checkpoint_config_file):
with open(checkpoint_config_file, "r") as f:
checkpoint_config = json.load(f)
else:
checkpoint_config = {}
train_path = os.environ[sm_env_constants.SM_CHANNEL_TRAIN]
val_path = os.environ.get(sm_env_constants.SM_CHANNEL_VALIDATION)
sm_hosts = json.loads(os.environ[sm_env_constants.SM_HOSTS])
sm_current_host = os.environ[sm_env_constants.SM_CURRENT_HOST]
model_dir = os.getenv(sm_env_constants.SM_MODEL_DIR)
sagemaker_train(
train_config=train_config,
data_config=data_config,
train_path=train_path,
val_path=val_path,
model_dir=model_dir,
sm_hosts=sm_hosts,
sm_current_host=sm_current_host,
checkpoint_config=checkpoint_config,
)