Skip to content

DM 8208 Improve error handling on external task failure #233

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
Nov 18, 2016

Conversation

tgoldina
Copy link
Contributor

Testing:
Use http://localhost:8080/firefly/demo/ffapi-highlevel-charttest.html (last div) and firefly/python/SamplePythonLauncher.py to test. (In order for Firefly to access python launcher, python.exe property should be set. You can set this property in ~/gradle/build.config.

Example:
python.exe= "/path/to/myPythonLauncher.py"

These are the error conditions I have tested. (The error message appears in the last div, if everything works fine, histogram shows up - no error.)

  1. missing property for launcher executable:
    Error: java.lang.IllegalArgumentException: The python launcher path is not an executable: @python.exe@

  2. misspelled launcher:
    Error: java.lang.IllegalArgumentException: py.exe property is not defined

  3. missing launcher executable:
    Error: edu.caltech.ipac.firefly.server.query.DataAccessException: Unable to get data from external task: Failed to obtain data. /Users/tatianag/dev/miniconda/bin/python: can't open file '/Users/tatianag/dev/pynotebooks/myLauncher.py': [Errno 2] No such file or directory

  4. no permission to read:
    Error: edu.caltech.ipac.firefly.server.query.DataAccessException: Unable to get data from external task: Failed to obtain data. /Users/tatianag/dev/miniconda/bin/python: can't open file '/Users/tatianag/dev/pynotebooks/myLauncher.py': [Errno 13] Permission denied

  5. Invalid JSON returned:
    Error: edu.caltech.ipac.firefly.server.query.DataAccessException: JsonFromExternalTask Can not parse returned JSON: Unexpected character (n) at position 0.

  6. Error in python (missing json import):
    Error: edu.caltech.ipac.firefly.server.query.DataAccessException: Unable to get data from external task: Failed to obtain data. Traceback (most recent call last): File "/Users/tatianag/dev/pynotebooks/myLauncher.py", line 162, in print json.dumps(status) NameError: name 'json' is not defined

  7. Syntax error in python:
    Error: edu.caltech.ipac.firefly.server.query.DataAccessException: Unable to get data from external task: Failed to obtain data. File "/Users/tatianag/dev/pynotebooks/myLauncher.py", line 64 iimport json ^ SyntaxError: invalid syntax

Copy link
Contributor

@loitly loitly left a comment

Choose a reason for hiding this comment

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

I was able to test several of the exceptions. They are handled as described. I think the variable python.exe is a bit confusing. I expect it to be the path to python, and not the launcher. Please look at the one code comment I made. I think it could be problematic.

@@ -83,7 +83,7 @@ export const jsonRequest= function(baseUrl, cmd, paramList, doPost) {
return;
}
response.json().then( (result) => {
if (has(result,'0')) {
if (has(result,'0.success')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this may affect other cases where result has .error only. By adding this, it will not fall in to this block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I just changed it back to how it used to be before 10/21.

As we talked today, this code is handling JSON wrapper of possibly non-JSON result. The wrapping is done in ServCommand processRequest:33 and 53 and the wrapper always has 'success' field set either to true or false. Hence, checking has(result,'0.success') is a way to tell if JSON result is wrapped.

The advantage of checking for 'success' field is that now we can pass arrays as JSON result.

Just a note: when we change how we wrap JSON result in ServCommand.java, we need to change jsonRequest in JsonUtil.js, namely this precise code.

- moved getJSONFromTask to ffapi-pylaunch-test.html, added tests for image and table
- updated external task launcher documentation
@tgoldina tgoldina merged commit 4d8a642 into dev Nov 18, 2016
@tgoldina tgoldina deleted the dm-8208_jsontask_error branch November 21, 2016 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants