Skip to content
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

Fix bug where source and variables are not accessible to visualization #2012

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a1ab88c
Fix bug where source and variables are not accessible to visualization
ajchili Aug 30, 2019
4a47cf8
Updated snapshot
ajchili Aug 30, 2019
0798ca4
Removed test_generate_test_visualization_html_from_notebook
ajchili Aug 30, 2019
5b0a55f
Added test cases to ensure roc_curve, table, and tfdv visualizations …
ajchili Aug 30, 2019
7f11c43
Made test requirements identical to normal requirements
ajchili Aug 30, 2019
eef0ac1
Fixed source links
ajchili Aug 30, 2019
38a667e
Updated test_server.py to use table visualization
ajchili Aug 30, 2019
500b208
Update .travis.yml
IronPan Aug 30, 2019
6f2df58
Add logging to debug travis tests
ajchili Aug 31, 2019
8841fc3
Add tensorflow back to requirements.txt
ajchili Aug 31, 2019
5da1796
Updated .travis.yml and requirements.txt, also added comment that spe…
ajchili Aug 31, 2019
7e9066f
Testing TFDV visualization with different source
ajchili Aug 31, 2019
4c90c42
Changed remote paths to be local due to timeout issues
ajchili Aug 31, 2019
b961af5
Removed visualization tests due to continued failure
ajchili Aug 31, 2019
8970859
Reverted .gitignore and removed tensorflow from text_exporter pip ins…
ajchili Aug 31, 2019
6d9295a
Moved where dependencies are installed in .travis.yaml
ajchili Sep 1, 2019
2276ed5
Revert "Made test requirements identical to normal requirements"
ajchili Sep 3, 2019
d67ad52
Added pip install requirements to .travis file
ajchili Sep 3, 2019
3ac0521
Removed new unit test and requirements.txt install
ajchili Sep 3, 2019
27e6599
Cleaned up tests and re-added test.py predefined visualization
ajchili Sep 4, 2019
e98b29c
Cleanup
ajchili Sep 4, 2019
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
5 changes: 4 additions & 1 deletion backend/src/apiserver/visualization/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def create_cell_from_file(filepath: Text) -> NotebookNode:
NotebookNode with specified file as code within node.

"""
return new_code_cell("%run {}".format(filepath))
with open(filepath, 'r') as f:
code = f.read()

return new_code_cell(code)


def create_cell_from_custom_code(code: list) -> NotebookNode:
Expand Down
41 changes: 20 additions & 21 deletions backend/src/apiserver/visualization/snapshots/snap_test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,26 @@
snapshots['TestExporterMethods::test_create_cell_from_custom_code 1'] = '''x = 2
print(x)'''

snapshots['TestExporterMethods::test_create_cell_from_file 1'] = '%run types/tfdv.py'
snapshots['TestExporterMethods::test_create_cell_from_file 1'] = '''"""
test.py provides a basic predefined visualization that can be used for testing
because it does not have dependencies and had a low chance of being updated.
"""

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

print(2)'''

snapshots['TestExporterMethods::test_generate_custom_visualization_html_from_notebook 1'] = '''
<div class="output_wrapper">
Expand All @@ -65,24 +84,4 @@



'''

snapshots['TestExporterMethods::test_generate_test_visualization_html_from_notebook 1'] = '''
<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>



</div>

</div>
</div>



'''
9 changes: 1 addition & 8 deletions backend/src/apiserver/visualization/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_create_cell_from_args_with_multiple_args(self):
self.assertMatchSnapshot(html)

def test_create_cell_from_file(self):
cell = exporter.create_cell_from_file("types/tfdv.py")
cell = exporter.create_cell_from_file("types/test.py")
self.assertMatchSnapshot(cell.source)

def test_create_cell_from_custom_code(self):
Expand All @@ -66,13 +66,6 @@ def test_create_cell_from_custom_code(self):
cell = exporter.create_cell_from_custom_code(code)
self.assertMatchSnapshot(cell.source)

# Tests to ensure output is generated for predefined visualizations.
def test_generate_test_visualization_html_from_notebook(self):
nb = new_notebook()
nb.cells.append(exporter.create_cell_from_file("types/test.py"))
html = self.exporter.generate_html_from_notebook(nb)
self.assertMatchSnapshot(html)

# Tests to ensure output is generated for custom visualizations.
def test_generate_custom_visualization_html_from_notebook(self):
nb = new_notebook()
Expand Down
20 changes: 20 additions & 0 deletions backend/src/apiserver/visualization/types/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
test.py provides a basic predefined visualization that can be used for testing
because it does not have dependencies and had a low chance of being updated.
"""

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

print(2)