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

Scottx611x/persistent visualization urls #2638

Merged
merged 10 commits into from Mar 1, 2018

Conversation

scottx611x
Copy link
Member

@scottx611x scottx611x commented Feb 28, 2018

I noticed this morning that although we have the ability to relaunch VisualizationTools from the UI, if one was to share the url of a running VisualizationTool with someone else who accesses said url after said VisualizationTool's container had been purged then they would get the "Please Wait" page indefinitely.

This PR relaunches VisualizationTools if they aren't already running when their url is accessed
feb-28-2018 14-17-20

@scottx611x scottx611x added this to the Release 1.6.3 milestone Feb 28, 2018
assign_perm('core.read_dataset', self.user, self.tool.dataset)

# Need to set_password() to be able to login. Otherwise
# usr.password in the hash representation which is not what the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in the hash" -> "is the hash"?


with mock.patch.object(VisualizationTool, "launch") as launch_mock:
get_response = self.client.get(
"{}/".format(self.tool.get_relative_container_url())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the trailing slash required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unfortunately, Normal django routing middleware tacks this on automatically. The format() is probably overkill for this though

@@ -164,3 +168,59 @@ def relaunch(self, request, *args, **kwargs):
except Exception as e:
logger.error(e)
return HttpResponseBadRequest(e)


class VisualizationToolProxy(Proxy, object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already a visualization-tool-proxy: Perhaps rename to reflect the difference? AutoRelaunchProxy or something like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better left in the file where it's used? Or would that be weird?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the renaming, I'd push to keep it in views.py since we're wrapping a view now


def user_has_access_to_tool(user, tool):
return \
False if not user.has_perm('core.read_dataset', tool.dataset) else True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return user.has_perm('core.read_dataset', tool.dataset)?

return HttpResponseForbidden(
"Requesting User does not have sufficient permissions to "
"view Tool with uuid: {}".format(visualization_tool.uuid)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be more concise? "User does not have permission to view Tool {}"

Copy link
Member

@mccalluc mccalluc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some style tweaks, but overall, great! Thanks for doing this.

@mccalluc
Copy link
Member

(But test failures could be related?)

@codecov
Copy link

codecov bot commented Feb 28, 2018

Codecov Report

Merging #2638 into develop will decrease coverage by 0.97%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2638      +/-   ##
===========================================
- Coverage    55.54%   54.56%   -0.98%     
===========================================
  Files          400      399       -1     
  Lines        26609    25596    -1013     
  Branches      1242     1242              
===========================================
- Hits         14780    13967     -813     
+ Misses       11829    11629     -200
Impacted Files Coverage Δ
refinery/tool_manager/tests.py 99.81% <100%> (ø) ⬆️
refinery/tool_manager/views.py 96.19% <100%> (+0.53%) ⬆️
refinery/tool_manager/utils.py 100% <100%> (ø) ⬆️
refinery/tool_manager/urls.py 100% <100%> (ø) ⬆️
refinery/selenium_testing/utils.py 0% <0%> (-90.91%) ⬇️
refinery/file_store/admin.py 82.35% <0%> (-12.89%) ⬇️
refinery/file_store/models.py 62.31% <0%> (-8.79%) ⬇️
refinery/core/utils.py 35.81% <0%> (-4.56%) ⬇️
refinery/file_store/tasks.py 37.17% <0%> (-2.91%) ⬇️
refinery/data_set_manager/views.py 45.39% <0%> (-2.78%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9dad32d...a666097. Read the comment docs.

@scottx611x scottx611x merged commit 6972de6 into develop Mar 1, 2018
@scottx611x scottx611x deleted the scottx611x/persistent_visualization_urls branch March 1, 2018 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants