4242from sagemaker .utils import resolve_value_from_config
4343from sagemaker .workflow import is_pipeline_variable
4444
45- LOGGER = logging .getLogger (__name__ )
46-
4745
4846def get_jumpstart_launched_regions_message () -> str :
4947 """Returns formatted string indicating where JumpStart is launched."""
@@ -79,7 +77,7 @@ def get_jumpstart_content_bucket(
7977 and len (os .environ [constants .ENV_VARIABLE_JUMPSTART_CONTENT_BUCKET_OVERRIDE ]) > 0
8078 ):
8179 bucket_override = os .environ [constants .ENV_VARIABLE_JUMPSTART_CONTENT_BUCKET_OVERRIDE ]
82- LOGGER .info ("Using JumpStart bucket override: '%s'" , bucket_override )
80+ constants . JUMPSTART_LOGGER .info ("Using JumpStart bucket override: '%s'" , bucket_override )
8381 return bucket_override
8482 try :
8583 return constants .JUMPSTART_REGION_NAME_TO_LAUNCHED_REGION_DICT [region ].content_bucket
@@ -343,6 +341,39 @@ def update_inference_tags_with_jumpstart_training_tags(
343341 return inference_tags
344342
345343
344+ def emit_logs_based_on_model_specs (model_specs : JumpStartModelSpecs , region : str ) -> None :
345+ """Emits logs based on model specs and region."""
346+
347+ if model_specs .hosting_eula_key :
348+ constants .JUMPSTART_LOGGER .info (
349+ "Model '%s' requires accepting end-user license agreement (EULA). "
350+ "See https://%s.s3.%s.amazonaws.com%s/%s for terms of use." ,
351+ model_specs .model_id ,
352+ get_jumpstart_content_bucket (region = region ),
353+ region ,
354+ ".cn" if region .startswith ("cn-" ) else "" ,
355+ model_specs .hosting_eula_key ,
356+ )
357+
358+ if model_specs .deprecated :
359+ deprecated_message = model_specs .deprecated_message or (
360+ "Using deprecated JumpStart model "
361+ f"'{ model_specs .model_id } ' and version '{ model_specs .version } '."
362+ )
363+
364+ constants .JUMPSTART_LOGGER .warning (deprecated_message )
365+
366+ if model_specs .deprecate_warn_message :
367+ constants .JUMPSTART_LOGGER .warning (model_specs .deprecate_warn_message )
368+
369+ if model_specs .inference_vulnerable or model_specs .training_vulnerable :
370+ constants .JUMPSTART_LOGGER .warning (
371+ "Using vulnerable JumpStart model '%s' and version '%s'." ,
372+ model_specs .model_id ,
373+ model_specs .version ,
374+ )
375+
376+
346377def verify_model_region_and_return_specs (
347378 model_id : Optional [str ],
348379 version : Optional [str ],
@@ -402,26 +433,11 @@ def verify_model_region_and_return_specs(
402433 f"JumpStart model ID '{ model_id } ' and version '{ version } ' " "does not support training."
403434 )
404435
405- if model_specs .hosting_eula_key and scope == constants .JumpStartScriptScope .INFERENCE .value :
406- LOGGER .info (
407- "Model '%s' requires accepting end-user license agreement (EULA). "
408- "See https://%s.s3.%s.amazonaws.com%s/%s for terms of use." ,
409- model_id ,
410- get_jumpstart_content_bucket (region = region ),
411- region ,
412- ".cn" if region .startswith ("cn-" ) else "" ,
413- model_specs .hosting_eula_key ,
414- )
415-
416436 if model_specs .deprecated :
417437 if not tolerate_deprecated_model :
418438 raise DeprecatedJumpStartModelError (
419439 model_id = model_id , version = version , message = model_specs .deprecated_message
420440 )
421- LOGGER .warning ("Using deprecated JumpStart model '%s' and version '%s'." , model_id , version )
422-
423- if model_specs .deprecate_warn_message :
424- LOGGER .warning (model_specs .deprecate_warn_message )
425441
426442 if scope == constants .JumpStartScriptScope .INFERENCE .value and model_specs .inference_vulnerable :
427443 if not tolerate_vulnerable_model :
@@ -431,9 +447,6 @@ def verify_model_region_and_return_specs(
431447 vulnerabilities = model_specs .inference_vulnerabilities ,
432448 scope = constants .JumpStartScriptScope .INFERENCE ,
433449 )
434- LOGGER .warning (
435- "Using vulnerable JumpStart model '%s' and version '%s' (inference)." , model_id , version
436- )
437450
438451 if scope == constants .JumpStartScriptScope .TRAINING .value and model_specs .training_vulnerable :
439452 if not tolerate_vulnerable_model :
@@ -443,9 +456,6 @@ def verify_model_region_and_return_specs(
443456 vulnerabilities = model_specs .training_vulnerabilities ,
444457 scope = constants .JumpStartScriptScope .TRAINING ,
445458 )
446- LOGGER .warning (
447- "Using vulnerable JumpStart model '%s' and version '%s' (training)." , model_id , version
448- )
449459
450460 return model_specs
451461
0 commit comments