|
| 1 | +# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +"""A tool to upgrade SageMaker Python SDK code to be compatible with v2.""" |
| 14 | +from __future__ import absolute_import |
| 15 | + |
| 16 | +import argparse |
| 17 | + |
| 18 | +import files |
| 19 | + |
| 20 | + |
| 21 | +def _parse_and_validate_args(): |
| 22 | + """Parses CLI arguments""" |
| 23 | + parser = argparse.ArgumentParser( |
| 24 | + description="A tool to convert files to be compatible with v2 of the SageMaker Python SDK." |
| 25 | + "\nSimple usage: sagemaker_upgrade_v2.py --in-file foo.py --out-file bar.py" |
| 26 | + ) |
| 27 | + parser.add_argument( |
| 28 | + "--in-file", help="If converting a single file, the name of the file to convert" |
| 29 | + ) |
| 30 | + parser.add_argument( |
| 31 | + "--out-file", |
| 32 | + help="If converting a single file, the output file destination. If needed, " |
| 33 | + "directories in the output file path are created. If the output file already exists, " |
| 34 | + "it is overwritten.", |
| 35 | + ) |
| 36 | + |
| 37 | + return parser.parse_args() |
| 38 | + |
| 39 | + |
| 40 | +if __name__ == "__main__": |
| 41 | + args = _parse_and_validate_args() |
| 42 | + |
| 43 | + files.PyFileUpdater(input_path=args.in_file, output_path=args.out_file).update() |
0 commit comments