Skip to content

change: add v2 migration script to console_scripts in setup.py #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def read_version():
],
install_requires=required_packages,
extras_require=extras,
entry_points={"console_scripts": ["sagemaker=sagemaker.cli.main:main"]},
entry_points={
"console_scripts": [
"sagemaker=sagemaker.cli.main:main",
"sagemaker-upgrade-v2=sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main",
]
},
include_package_data=True, # TODO-reinvent-2019 [knakad]: Remove after rule_configs is in PyPI
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import ast

from modifiers import framework_version
from sagemaker.cli.compatibility.v2.modifiers import framework_version

FUNCTION_CALL_MODIFIERS = [framework_version.FrameworkVersionEnforcer()]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import pasta

from ast_transformer import ASTTransformer
from sagemaker.cli.compatibility.v2.ast_transformer import ASTTransformer

LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import ast

from modifiers.modifier import Modifier
from sagemaker.cli.compatibility.v2.modifiers.modifier import Modifier

FRAMEWORK_DEFAULTS = {
"Chainer": "4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import argparse
import os

import files
from sagemaker.cli.compatibility.v2 import files

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


def _update_file(input_file, output_file):
"""Update a file to be compatible with v2 of the SageMaker Python SDK,
"""Updates a file to be compatible with v2 of the SageMaker Python SDK,
and write the updated source to the output file.

Args:
Expand Down Expand Up @@ -51,10 +51,10 @@ def _update_file(input_file, output_file):


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


if __name__ == "__main__":
def main():
"""Parses the CLI arguments and executes the file update."""
args = _parse_args()
_update_file(args.in_file, args.out_file)
14 changes: 0 additions & 14 deletions tools/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ skip_install = true
deps =
pylint==2.3.1
commands =
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker tools
python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker

[testenv:twine]
basepython = python3
Expand Down