Skip to content

Commit 1e7799f

Browse files
author
Chuyang Deng
committed
simplify and rename method
1 parent 1d837cb commit 1e7799f

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

src/sagemaker/cli/framework_upgrade.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ def add_dlc_framework_version(
8989
existing_content[scope]["processors"].append(processor)
9090
existing_content[scope]["version_aliases"][short_version] = full_version
9191

92-
add_version = {
92+
new_version = {
9393
"registries": registries,
9494
"repository": repository,
9595
"py_versions": py_versions,
9696
}
97-
existing_content[scope]["versions"][full_version] = add_version
97+
existing_content[scope]["versions"][full_version] = new_version
9898

9999

100100
def add_algo_version(
@@ -127,14 +127,14 @@ def add_algo_version(
127127
if scope not in existing_content["scope"]:
128128
existing_content["scope"].append(scope)
129129

130-
add_version = {
130+
new_version = {
131131
"py_versions": py_versions,
132132
"registries": registries,
133133
"repository": repository,
134134
}
135135
if tag_prefix:
136-
add_version["tag_prefix"] = tag_prefix
137-
existing_content["versions"][full_version] = add_version
136+
new_version["tag_prefix"] = tag_prefix
137+
existing_content["versions"][full_version] = new_version
138138

139139

140140
def add_region(existing_content, region, account):
@@ -155,7 +155,7 @@ def add_region(existing_content, region, account):
155155
existing_content["versions"][version]["registries"][region] = account
156156

157157

158-
def update_json(
158+
def add_version(
159159
existing_content, short_version, full_version, scope, processors, py_versions, tag_prefix,
160160
):
161161
"""Read framework image uri information from json file to a dictionary, update it with new
@@ -222,28 +222,25 @@ def main():
222222
parser.add_argument("--account", help="Registry account of new region")
223223

224224
args = parser.parse_args()
225-
framework = args.framework
226-
short_version = args.short_version
227-
full_version = args.full_version
228-
processors = args.processors
229-
py_versions = args.py_versions
230-
scope = args.scope
231-
tag_prefix = args.tag_prefix
232-
region = args.region
233-
account = args.account
234-
235-
content = config_for_framework(framework)
236-
237-
if region or account:
238-
if region and not account or account and not region:
225+
226+
content = config_for_framework(args.framework)
227+
228+
if args.region or args.account:
229+
if args.region and not args.account or args.account and not args.region:
239230
raise ValueError("--region and --account must be used together to expand region.")
240-
add_region(content, region, account)
231+
add_region(content, args.region, args.account)
241232
else:
242-
update_json(
243-
content, short_version, full_version, scope, processors, py_versions, tag_prefix,
233+
add_version(
234+
content,
235+
args.short_version,
236+
args.full_version,
237+
args.scope,
238+
args.processors,
239+
args.py_versions,
240+
args.tag_prefix,
244241
)
245242

246-
file = os.path.join(IMAGE_URI_CONFIG_DIR, "{}.json".format(framework))
243+
file = os.path.join(IMAGE_URI_CONFIG_DIR, "{}.json".format(args.framework))
247244
_write_dict_to_json(file, content)
248245

249246

0 commit comments

Comments
 (0)