1313from __future__ import absolute_import
1414
1515import os
16- import re
1716import time
1817import uuid
1918
2221from sagemaker .debugger import (
2322 DebuggerHookConfig ,
2423 FrameworkProfile ,
25- get_rule_container_image_uri ,
2624 ProfilerConfig ,
2725 ProfilerRule ,
2826 Rule ,
@@ -93,8 +91,6 @@ def test_mxnet_with_default_profiler_config_and_profiler_rule(
9391 )
9492
9593 job_description = mx .latest_training_job .describe ()
96- if "DisableProfiler" in job_description ["ProfilerConfig" ]:
97- job_description ["ProfilerConfig" ].pop ("DisableProfiler" )
9894 assert (
9995 job_description ["ProfilerConfig" ]
10096 == ProfilerConfig (
@@ -103,13 +99,6 @@ def test_mxnet_with_default_profiler_config_and_profiler_rule(
10399 )
104100 assert job_description .get ("ProfilingStatus" ) == "Enabled"
105101
106- profiler_rule_configuration = job_description .get ("ProfilerRuleConfigurations" )[0 ]
107- assert re .match (r"ProfilerReport-\d*" , profiler_rule_configuration ["RuleConfigurationName" ])
108- assert profiler_rule_configuration ["RuleEvaluatorImage" ] == get_rule_container_image_uri (
109- mx .sagemaker_session .boto_region_name
110- )
111- assert profiler_rule_configuration ["RuleParameters" ] == {"rule_to_invoke" : "ProfilerReport" }
112-
113102 with pytest .raises (ValueError ) as error :
114103 mx .enable_default_profiling ()
115104 assert "Debugger monitoring is already enabled." in str (error )
@@ -155,18 +144,9 @@ def test_mxnet_with_custom_profiler_config_then_update_rule_and_config(
155144 )
156145
157146 job_description = mx .latest_training_job .describe ()
158- if "DisableProfiler" in job_description ["ProfilerConfig" ]:
159- job_description ["ProfilerConfig" ].pop ("DisableProfiler" )
160147 assert job_description .get ("ProfilerConfig" ) == profiler_config ._to_request_dict ()
161148 assert job_description .get ("ProfilingStatus" ) == "Enabled"
162149
163- profiler_rule_configuration = job_description .get ("ProfilerRuleConfigurations" )[0 ]
164- assert re .match (r"ProfilerReport-\d*" , profiler_rule_configuration ["RuleConfigurationName" ])
165- assert profiler_rule_configuration ["RuleEvaluatorImage" ] == get_rule_container_image_uri (
166- mx .sagemaker_session .boto_region_name
167- )
168- assert profiler_rule_configuration ["RuleParameters" ] == {"rule_to_invoke" : "ProfilerReport" }
169-
170150 _wait_until_training_can_be_updated (sagemaker_session .sagemaker_client , training_job_name )
171151
172152 mx .update_profiler (
@@ -178,13 +158,6 @@ def test_mxnet_with_custom_profiler_config_then_update_rule_and_config(
178158 assert job_description ["ProfilerConfig" ]["S3OutputPath" ] == profiler_config .s3_output_path
179159 assert job_description ["ProfilerConfig" ]["ProfilingIntervalInMilliseconds" ] == 500
180160
181- profiler_report_rule_config = job_description .get ("ProfilerRuleConfigurations" )[0 ]
182- assert re .match (r"ProfilerReport-\d*" , profiler_report_rule_config ["RuleConfigurationName" ])
183- assert profiler_report_rule_config ["RuleEvaluatorImage" ] == get_rule_container_image_uri (
184- mx .sagemaker_session .boto_region_name
185- )
186- assert profiler_report_rule_config ["RuleParameters" ] == {"rule_to_invoke" : "ProfilerReport" }
187-
188161
189162def test_mxnet_with_built_in_profiler_rule_with_custom_parameters (
190163 sagemaker_session ,
@@ -225,8 +198,6 @@ def test_mxnet_with_built_in_profiler_rule_with_custom_parameters(
225198 )
226199
227200 job_description = mx .latest_training_job .describe ()
228- if "DisableProfiler" in job_description ["ProfilerConfig" ]:
229- job_description ["ProfilerConfig" ].pop ("DisableProfiler" )
230201 assert job_description .get ("ProfilingStatus" ) == "Enabled"
231202 assert (
232203 job_description .get ("ProfilerConfig" )
@@ -298,8 +269,6 @@ def test_mxnet_with_profiler_and_debugger_then_disable_framework_metrics(
298269 )
299270
300271 job_description = mx .latest_training_job .describe ()
301- if "DisableProfiler" in job_description ["ProfilerConfig" ]:
302- job_description ["ProfilerConfig" ].pop ("DisableProfiler" )
303272 assert job_description ["ProfilerConfig" ] == profiler_config ._to_request_dict ()
304273 assert job_description ["DebugHookConfig" ] == debugger_hook_config ._to_request_dict ()
305274 assert job_description .get ("ProfilingStatus" ) == "Enabled"
@@ -387,13 +356,6 @@ def test_mxnet_with_enable_framework_metrics_then_update_framework_metrics(
387356 == updated_framework_profile .profiling_parameters
388357 )
389358
390- profiler_rule_configuration = job_description .get ("ProfilerRuleConfigurations" )[0 ]
391- assert re .match (r"ProfilerReport-\d*" , profiler_rule_configuration ["RuleConfigurationName" ])
392- assert profiler_rule_configuration ["RuleEvaluatorImage" ] == get_rule_container_image_uri (
393- mx .sagemaker_session .boto_region_name
394- )
395- assert profiler_rule_configuration ["RuleParameters" ] == {"rule_to_invoke" : "ProfilerReport" }
396-
397359
398360def test_mxnet_with_disable_profiler_then_enable_default_profiling (
399361 sagemaker_session ,
@@ -431,12 +393,10 @@ def test_mxnet_with_disable_profiler_then_enable_default_profiling(
431393 )
432394
433395 job_description = mx .latest_training_job .describe ()
434- assert job_description .get ("ProfilerConfig" ) is None
435396 assert job_description .get ("ProfilerRuleConfigurations" ) is None
436397 assert job_description .get ("ProfilingStatus" ) == "Disabled"
437398
438399 _wait_until_training_can_be_updated (sagemaker_session .sagemaker_client , training_job_name )
439-
440400 mx .enable_default_profiling ()
441401
442402 job_description = mx .latest_training_job .describe ()
0 commit comments