@@ -462,8 +462,6 @@ def train( # noqa: C901
462
462
debugger_hook_config = None ,
463
463
tensorboard_output_config = None ,
464
464
enable_sagemaker_metrics = None ,
465
- profiler_rule_configs = None ,
466
- profiler_config = None ,
467
465
):
468
466
"""Create an Amazon SageMaker training job.
469
467
@@ -533,9 +531,6 @@ def train( # noqa: C901
533
531
Series. For more information see:
534
532
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
535
533
(default: ``None``).
536
- profiler_rule_configs (list[dict]): A list of profiler rule configurations.
537
- profiler_config (dict): Configuration for how profiling information is emitted
538
- with SageMaker Profiler. (default: ``None``).
539
534
540
535
Returns:
541
536
str: ARN of the training job, if it is created.
@@ -565,8 +560,6 @@ def train( # noqa: C901
565
560
debugger_hook_config = debugger_hook_config ,
566
561
tensorboard_output_config = tensorboard_output_config ,
567
562
enable_sagemaker_metrics = enable_sagemaker_metrics ,
568
- profiler_rule_configs = profiler_rule_configs ,
569
- profiler_config = profiler_config ,
570
563
)
571
564
LOGGER .info ("Creating training-job with name: %s" , job_name )
572
565
LOGGER .debug ("train request: %s" , json .dumps (train_request , indent = 4 ))
@@ -597,8 +590,6 @@ def _get_train_request( # noqa: C901
597
590
debugger_hook_config = None ,
598
591
tensorboard_output_config = None ,
599
592
enable_sagemaker_metrics = None ,
600
- profiler_rule_configs = None ,
601
- profiler_config = None ,
602
593
):
603
594
"""Constructs a request compatible for creating an Amazon SageMaker training job.
604
595
@@ -668,9 +659,6 @@ def _get_train_request( # noqa: C901
668
659
Series. For more information see:
669
660
https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries
670
661
(default: ``None``).
671
- profiler_rule_configs (list[dict]): A list of profiler rule configurations.
672
- profiler_config(dict): Configuration for how profiling information is emitted with
673
- SageMaker Profiler. (default: ``None``).
674
662
675
663
Returns:
676
664
Dict: a training request dict
@@ -746,66 +734,8 @@ def _get_train_request( # noqa: C901
746
734
if tensorboard_output_config is not None :
747
735
train_request ["TensorBoardOutputConfig" ] = tensorboard_output_config
748
736
749
- if profiler_rule_configs is not None :
750
- train_request ["ProfilerRuleConfigurations" ] = profiler_rule_configs
751
-
752
- if profiler_config is not None :
753
- train_request ["ProfilerConfig" ] = profiler_config
754
-
755
737
return train_request
756
738
757
- def update_training_job (
758
- self ,
759
- job_name ,
760
- profiler_rule_configs = None ,
761
- profiler_config = None ,
762
- ):
763
- """Calls the UpdateTrainingJob API for the given job name and returns the response.
764
-
765
- Args:
766
- job_name (str): Name of the training job being updated.
767
- profiler_rule_configs (list): List of profiler rule configurations. (default: ``None``).
768
- profiler_config(dict): Configuration for how profiling information is emitted with
769
- SageMaker Profiler. (default: ``None``).
770
- """
771
- update_training_job_request = self ._get_update_training_job_request (
772
- job_name = job_name ,
773
- profiler_rule_configs = profiler_rule_configs ,
774
- profiler_config = profiler_config ,
775
- )
776
- LOGGER .info ("Updating training job with name %s" , job_name )
777
- LOGGER .debug ("Update request: %s" , json .dumps (update_training_job_request , indent = 4 ))
778
- self .sagemaker_client .update_training_job (** update_training_job_request )
779
-
780
- def _get_update_training_job_request (
781
- self ,
782
- job_name ,
783
- profiler_rule_configs = None ,
784
- profiler_config = None ,
785
- ):
786
- """Constructs a request compatible for updateing an Amazon SageMaker training job.
787
-
788
- Args:
789
- job_name (str): Name of the training job being updated.
790
- profiler_rule_configs (list): List of profiler rule configurations. (default: ``None``).
791
- profiler_config(dict): Configuration for how profiling information is emitted with
792
- SageMaker Profiler. (default: ``None``).
793
-
794
- Returns:
795
- Dict: an update training request dict
796
- """
797
- update_training_job_request = {
798
- "TrainingJobName" : job_name ,
799
- }
800
-
801
- if profiler_rule_configs is not None :
802
- update_training_job_request ["ProfilerRuleConfigurations" ] = profiler_rule_configs
803
-
804
- if profiler_config is not None :
805
- update_training_job_request ["ProfilerConfig" ] = profiler_config
806
-
807
- return update_training_job_request
808
-
809
739
def process (
810
740
self ,
811
741
inputs ,
@@ -1802,48 +1732,6 @@ def compile_model(
1802
1732
LOGGER .info ("Creating compilation-job with name: %s" , job_name )
1803
1733
self .sagemaker_client .create_compilation_job (** compilation_job_request )
1804
1734
1805
- def package_model_for_edge (
1806
- self ,
1807
- output_model_config ,
1808
- role ,
1809
- job_name ,
1810
- compilation_job_name ,
1811
- model_name ,
1812
- model_version ,
1813
- resource_key ,
1814
- tags ,
1815
- ):
1816
- """Create an Amazon SageMaker Edge packaging job.
1817
-
1818
- Args:
1819
- output_model_config (dict): Identifies the Amazon S3 location where you want Amazon
1820
- SageMaker Edge to save the results of edge packaging job
1821
- role (str): An AWS IAM role (either name or full ARN). The Amazon SageMaker Edge
1822
- edge packaging jobs use this role to access model artifacts. You must grant
1823
- sufficient permissions to this role.
1824
- job_name (str): Name of the edge packaging job being created.
1825
- compilation_job_name (str): Name of the compilation job being created.
1826
- resource_key (str): KMS key to encrypt the disk used to package the job
1827
- tags (list[dict]): List of tags for labeling a compile model job. For more, see
1828
- https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.
1829
- """
1830
- edge_packaging_job_request = {
1831
- "OutputConfig" : output_model_config ,
1832
- "RoleArn" : role ,
1833
- "ModelName" : model_name ,
1834
- "ModelVersion" : model_version ,
1835
- "EdgePackagingJobName" : job_name ,
1836
- "CompilationJobName" : compilation_job_name ,
1837
- }
1838
-
1839
- if tags is not None :
1840
- edge_packaging_job_request ["Tags" ] = tags
1841
- if resource_key is not None :
1842
- edge_packaging_job_request ["ResourceKey" ] = (resource_key ,)
1843
-
1844
- LOGGER .info ("Creating edge-packaging-job with name: %s" , job_name )
1845
- self .sagemaker_client .create_edge_packaging_job (** edge_packaging_job_request )
1846
-
1847
1735
def tune ( # noqa: C901
1848
1736
self ,
1849
1737
job_name ,
@@ -3150,23 +3038,6 @@ def wait_for_compilation_job(self, job, poll=5):
3150
3038
self ._check_job_status (job , desc , "CompilationJobStatus" )
3151
3039
return desc
3152
3040
3153
- def wait_for_edge_packaging_job (self , job , poll = 5 ):
3154
- """Wait for an Amazon SageMaker Edge packaging job to complete.
3155
-
3156
- Args:
3157
- job (str): Name of the edge packaging job to wait for.
3158
- poll (int): Polling interval in seconds (default: 5).
3159
-
3160
- Returns:
3161
- (dict): Return value from the ``DescribeEdgePackagingJob`` API.
3162
-
3163
- Raises:
3164
- exceptions.UnexpectedStatusException: If the compilation job fails.
3165
- """
3166
- desc = _wait_until (lambda : _edge_packaging_job_status (self .sagemaker_client , job ), poll )
3167
- self ._check_job_status (job , desc , "EdgePackagingJobStatus" )
3168
- return desc
3169
-
3170
3041
def wait_for_tuning_job (self , job , poll = 5 ):
3171
3042
"""Wait for an Amazon SageMaker hyperparameter tuning job to complete.
3172
3043
@@ -3250,13 +3121,7 @@ def _check_job_status(self, job, desc, status_key_name):
3250
3121
# If the status is capital case, then convert it to Camel case
3251
3122
status = _STATUS_CODE_TABLE .get (status , status )
3252
3123
3253
- if status == "Stopped" :
3254
- LOGGER .warning (
3255
- "Job ended with status 'Stopped' rather than 'Completed'. "
3256
- "This could mean the job timed out or stopped early for some other reason: "
3257
- "Consider checking whether it completed as you expect."
3258
- )
3259
- elif status != "Completed" :
3124
+ if status not in ("Completed" , "Stopped" ):
3260
3125
reason = desc .get ("FailureReason" , "(No reason provided)" )
3261
3126
job_type = status_key_name .replace ("JobStatus" , " job" )
3262
3127
raise exceptions .UnexpectedStatusException (
@@ -3618,7 +3483,6 @@ def logs_for_job( # noqa: C901 - suppress complexity warning for this method
3618
3483
last_describe_job_call = time .time ()
3619
3484
last_description = description
3620
3485
last_debug_rule_statuses = None
3621
- last_profiler_rule_statuses = None
3622
3486
3623
3487
while True :
3624
3488
_flush_log_streams (
@@ -3657,32 +3521,22 @@ def logs_for_job( # noqa: C901 - suppress complexity warning for this method
3657
3521
debug_rule_statuses = description .get ("DebugRuleEvaluationStatuses" , {})
3658
3522
if (
3659
3523
debug_rule_statuses
3660
- and _rule_statuses_changed (debug_rule_statuses , last_debug_rule_statuses )
3524
+ and _debug_rule_statuses_changed (debug_rule_statuses , last_debug_rule_statuses )
3661
3525
and (log_type in {"All" , "Rules" })
3662
3526
):
3527
+ print ()
3528
+ print ("********* Debugger Rule Status *********" )
3529
+ print ("*" )
3663
3530
for status in debug_rule_statuses :
3664
- rule_log = (
3665
- f" { status [' RuleConfigurationName' ] } : { status [' RuleEvaluationStatus' ] } "
3531
+ rule_log = "* {:>18}: {:<18}" . format (
3532
+ status [" RuleConfigurationName" ], status [" RuleEvaluationStatus" ]
3666
3533
)
3667
3534
print (rule_log )
3535
+ print ("*" )
3536
+ print ("*" * 40 )
3668
3537
3669
3538
last_debug_rule_statuses = debug_rule_statuses
3670
3539
3671
- # Print prettified logs related to the status of SageMaker Profiler rules.
3672
- profiler_rule_statuses = description .get ("ProfilerRuleEvaluationStatuses" , {})
3673
- if (
3674
- profiler_rule_statuses
3675
- and _rule_statuses_changed (profiler_rule_statuses , last_profiler_rule_statuses )
3676
- and (log_type in {"All" , "Rules" })
3677
- ):
3678
- for status in profiler_rule_statuses :
3679
- rule_log = (
3680
- f"{ status ['RuleConfigurationName' ]} : { status ['RuleEvaluationStatus' ]} "
3681
- )
3682
- print (rule_log )
3683
-
3684
- last_profiler_rule_statuses = profiler_rule_statuses
3685
-
3686
3540
if wait :
3687
3541
self ._check_job_status (job_name , description , "TrainingJobStatus" )
3688
3542
if dot :
@@ -4245,38 +4099,6 @@ def _processing_job_status(sagemaker_client, job_name):
4245
4099
return desc
4246
4100
4247
4101
4248
- def _edge_packaging_job_status (sagemaker_client , job_name ):
4249
- """Process the current status of a packaging job
4250
-
4251
- Args:
4252
- sagemaker_client (boto3.client.sagemaker): a sagemaker client
4253
- job_name (str): the name of the job to inspec
4254
-
4255
- Returns:
4256
- Dict: the status of the edge packaging job
4257
- """
4258
- package_status_codes = {
4259
- "Completed" : "!" ,
4260
- "InProgress" : "." ,
4261
- "Failed" : "*" ,
4262
- "Stopped" : "s" ,
4263
- "Stopping" : "_" ,
4264
- }
4265
- in_progress_statuses = ["InProgress" , "Stopping" , "Starting" ]
4266
-
4267
- desc = sagemaker_client .describe_edge_packaging_job (EdgePackagingJobName = job_name )
4268
- status = desc ["EdgePackagingJobStatus" ]
4269
-
4270
- status = _STATUS_CODE_TABLE .get (status , status )
4271
- print (package_status_codes .get (status , "?" ), end = "" )
4272
- sys .stdout .flush ()
4273
-
4274
- if status in in_progress_statuses :
4275
- return None
4276
-
4277
- return desc
4278
-
4279
-
4280
4102
def _compilation_job_status (sagemaker_client , job_name ):
4281
4103
"""Placeholder docstring"""
4282
4104
compile_status_codes = {
@@ -4454,8 +4276,8 @@ def _get_initial_job_state(description, status_key, wait):
4454
4276
return LogState .TAILING if wait and not job_already_completed else LogState .COMPLETE
4455
4277
4456
4278
4457
- def _rule_statuses_changed (current_statuses , last_statuses ):
4458
- """Checks the rule evaluation statuses for SageMaker Debugger and Profiler rules."""
4279
+ def _debug_rule_statuses_changed (current_statuses , last_statuses ):
4280
+ """Checks the rule evaluation statuses for SageMaker Debugger rules."""
4459
4281
if not last_statuses :
4460
4282
return True
4461
4283
0 commit comments