-
Notifications
You must be signed in to change notification settings - Fork 1.2k
V2 compability tests #1555
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
V2 compability tests #1555
Changes from 1 commit
872ba39
64c66f2
bec3f3c
fa86f39
52f9f66
09a72ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TensorFlow(entry_point="foo.py") | ||
sagemaker.tensorflow.TensorFlow() | ||
m = MXNet() | ||
sagemaker.mxnet.MXNet() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
|
||
|
||
class FrameworkVersion(unittest.TestCase): | ||
def setUp(self) -> None: | ||
pass | ||
|
||
def test_something(self): | ||
self.assertEqual(True, False) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ast | ||
import unittest | ||
|
||
from tests.unit.v2.utils import get_sample_file | ||
from tools.compatibility.v2.ast_transformer import ASTTransformer | ||
import pasta | ||
|
||
|
||
class TransformerTest(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.transformer_class = ASTTransformer() | ||
|
||
def test_simple_transform(self): | ||
sample = get_sample_file('simple.txt') | ||
rewrite = self.transformer_class.visit( | ||
ast.parse( | ||
sample | ||
) | ||
) | ||
|
||
expected = """TensorFlow(entry_point='foo.py', framework_version='1.11.0') | ||
sagemaker.tensorflow.TensorFlow(framework_version='1.11.0') | ||
m = MXNet(framework_version='1.2.0') | ||
sagemaker.mxnet.MXNet(framework_version='1.2.0')\n""" | ||
|
||
self.assertEqual(pasta.dump(rewrite), expected) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we use pytest, so as long as a function name starts with "test", it is run as part of the test suite |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from os.path import join | ||
|
||
SAMPLES_DIRECTORY = "/Users/owahab/Desktop/personal/sagemaker-python-sdk/tests/unit/v2/samples/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can either move the sample file to tests/data and use |
||
|
||
|
||
def get_sample_file(filename): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is used in only one file (at least so far), I would leave it in |
||
file_path = join(SAMPLES_DIRECTORY, filename) | ||
with open(file_path) as file_content: | ||
return file_content.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can delete this file