Skip to content

Commit 5b078f7

Browse files
authored
change: add v2 migration script to console_scripts in setup.py (#1530)
1 parent 40f1d75 commit 5b078f7

File tree

11 files changed

+16
-24
lines changed

11 files changed

+16
-24
lines changed

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def read_version():
105105
],
106106
install_requires=required_packages,
107107
extras_require=extras,
108-
entry_points={"console_scripts": ["sagemaker=sagemaker.cli.main:main"]},
108+
entry_points={
109+
"console_scripts": [
110+
"sagemaker=sagemaker.cli.main:main",
111+
"sagemaker-upgrade-v2=sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main",
112+
]
113+
},
109114
include_package_data=True, # TODO-reinvent-2019 [knakad]: Remove after rule_configs is in PyPI
110115
)

tools/compatibility/v2/ast_transformer.py renamed to src/sagemaker/cli/compatibility/v2/ast_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import ast
1717

18-
from modifiers import framework_version
18+
from sagemaker.cli.compatibility.v2.modifiers import framework_version
1919

2020
FUNCTION_CALL_MODIFIERS = [framework_version.FrameworkVersionEnforcer()]
2121

tools/compatibility/v2/files.py renamed to src/sagemaker/cli/compatibility/v2/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pasta
2222

23-
from ast_transformer import ASTTransformer
23+
from sagemaker.cli.compatibility.v2.ast_transformer import ASTTransformer
2424

2525
LOGGER = logging.getLogger(__name__)
2626

tools/compatibility/v2/modifiers/framework_version.py renamed to src/sagemaker/cli/compatibility/v2/modifiers/framework_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import ast
1717

18-
from modifiers.modifier import Modifier
18+
from sagemaker.cli.compatibility.v2.modifiers.modifier import Modifier
1919

2020
FRAMEWORK_DEFAULTS = {
2121
"Chainer": "4.1.0",

tools/compatibility/v2/sagemaker_upgrade_v2.py renamed to src/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import argparse
1717
import os
1818

19-
import files
19+
from sagemaker.cli.compatibility.v2 import files
2020

2121
_EXT_TO_UPDATER_CLS = {".py": files.PyFileUpdater, ".ipynb": files.JupyterNotebookFileUpdater}
2222

2323

2424
def _update_file(input_file, output_file):
25-
"""Update a file to be compatible with v2 of the SageMaker Python SDK,
25+
"""Updates a file to be compatible with v2 of the SageMaker Python SDK,
2626
and write the updated source to the output file.
2727
2828
Args:
@@ -51,10 +51,10 @@ def _update_file(input_file, output_file):
5151

5252

5353
def _parse_args():
54-
"""Parses CLI arguments"""
54+
"""Parses CLI arguments."""
5555
parser = argparse.ArgumentParser(
5656
description="A tool to convert files to be compatible with v2 of the SageMaker Python SDK. "
57-
"Simple usage: sagemaker_upgrade_v2.py --in-file foo.py --out-file bar.py"
57+
"Simple usage: sagemaker-upgrade-v2 --in-file foo.py --out-file bar.py"
5858
)
5959
parser.add_argument(
6060
"--in-file",
@@ -71,6 +71,7 @@ def _parse_args():
7171
return parser.parse_args()
7272

7373

74-
if __name__ == "__main__":
74+
def main():
75+
"""Parses the CLI arguments and executes the file update."""
7576
args = _parse_args()
7677
_update_file(args.in_file, args.out_file)

tools/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ skip_install = true
8282
deps =
8383
pylint==2.3.1
8484
commands =
85-
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker tools
85+
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker
8686

8787
[testenv:twine]
8888
basepython = python3

0 commit comments

Comments
 (0)