in src/sagemaker_core/main/intelligent_defaults_helper.py [0:0]
def load_default_configs(additional_config_paths: List[str] = None, s3_resource=None):
default_config_path = os.getenv(
ENV_VARIABLE_ADMIN_CONFIG_OVERRIDE, _DEFAULT_ADMIN_CONFIG_FILE_PATH
)
user_config_path = os.getenv(ENV_VARIABLE_USER_CONFIG_OVERRIDE, _DEFAULT_USER_CONFIG_FILE_PATH)
config_paths = [default_config_path, user_config_path]
if additional_config_paths:
config_paths += additional_config_paths
config_paths = list(filter(lambda item: item is not None, config_paths))
merged_config = {}
for file_path in config_paths:
config_from_file = {}
if file_path.startswith(S3_PREFIX):
config_from_file = _load_config_from_s3(file_path, s3_resource)
else:
try:
config_from_file = _load_config_from_file(file_path)
except ValueError:
error = LocalConfigNotFoundError(file_path=file_path)
if file_path not in (
_DEFAULT_ADMIN_CONFIG_FILE_PATH,
_DEFAULT_USER_CONFIG_FILE_PATH,
):
# Throw exception only when User provided file path is invalid.
# If there are no files in the Default config file locations, don't throw
# Exceptions.
raise error
logger.debug(error)
if config_from_file:
try:
validate_sagemaker_config(config_from_file)
except jsonschema.exceptions.ValidationError as error:
raise ConfigSchemaValidationError(file_path=file_path, message=str(error))
merge_dicts(merged_config, config_from_file)
logger.debug("Fetched defaults config from location: %s", file_path)
else:
logger.debug("Not applying SDK defaults from location: %s", file_path)
return merged_config