Skip to content

Commit 40b31c7

Browse files
committed
address PR comment
1 parent 7216855 commit 40b31c7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/sagemaker/cli/compatibility/v2/modifiers/tf_legacy_mode.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ class TensorFlowLegacyModeConstructorUpgrader(Modifier):
3535
"training_steps",
3636
)
3737

38+
def __init__(self):
39+
"""Initializes a ``TensorFlowLegacyModeConstructorUpgrader``."""
40+
self._region = None
41+
42+
@property
43+
def region(self):
44+
"""Returns the AWS region for constructing an ECR image URI."""
45+
if self._region is None:
46+
self._region = boto3.Session().region_name
47+
48+
return self._region
49+
3850
def node_should_be_modified(self, node):
3951
"""Checks if the ``ast.Call`` node instantiates a TensorFlow estimator with legacy mode.
4052
@@ -170,8 +182,9 @@ def _image_uri_from_args(self, keywords):
170182
if kw.arg == "train_instance_type":
171183
instance_type = kw.value.s
172184

173-
region = boto3.Session().region_name
174-
return fw_utils.create_image_uri(region, "tensorflow", instance_type, tf_version, "py2")
185+
return fw_utils.create_image_uri(
186+
self.region, "tensorflow", instance_type, tf_version, "py2"
187+
)
175188

176189

177190
class TensorBoardParameterRemover(Modifier):

0 commit comments

Comments
 (0)