-
Notifications
You must be signed in to change notification settings - Fork 16
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- | ||
~ License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt | ||
--> | ||
|
||
<!-- | ||
This is a test for Python (external task) launcher. | ||
Firefly supports getting JSON data, table, or image from an external task | ||
--> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Testing getJSONFromTask</title> | ||
</head> | ||
<body> | ||
<div id="chartHere" style="display:inline-block; width: 800px; height: 350px; | ||
border: solid 1px;"></div> | ||
<br><br> | ||
<div id="tableHere" style="display:inline-block; width: 800px; height: 350px; | ||
border: solid 1px;"></div> | ||
<br><br> | ||
<div id="imageHere" style="width: 350px; height: 350px;"></div> | ||
</body> | ||
|
||
<script type="text/javascript"> | ||
{ | ||
onFireflyLoaded = function (firefly) { | ||
|
||
// json - show histogram, generated by firefly/python/SamplePythonLauncher.py | ||
var launcher = 'python'; | ||
var task = 'JsonTaskToGetHistogramData'; | ||
var taskParams = {'numbins': 10}; | ||
firefly.getJsonFromTask(launcher, task, taskParams) | ||
.then(function (histdata) { | ||
console.log('Returned JSON: ' + JSON.stringify(histdata)); | ||
firefly.util.renderDOM("chartHere", firefly.ui.Histogram, | ||
{ | ||
desc: 'Histogram data returned from Python JSON task', | ||
binColor: '#3d3033', | ||
height: 350, | ||
data: histdata | ||
}); | ||
}) | ||
.catch(function (reason) { | ||
console.error('Error fetching JSON data from ' + launcher + ' task ' + task + ': ' + reason); | ||
document.getElementById('chartHere').innerHTML = '<p style="color:red">'+reason+'</p>'; | ||
}); | ||
|
||
// table - show table, generated by firefly/python/SamplePythonLauncher.py | ||
var tblReq = firefly.util.table.makeTblRequest('TableFromExternalTask', 'Table from Python task', | ||
{ launcher : 'python', task : 'TableTask', taskParams : {p1: 1, p2: 2} }, // search parameters | ||
{ pageSize: 15} // table options | ||
); | ||
firefly.showTable('tableHere', tblReq); | ||
|
||
// image - show FITS image, generated by firefly/python/SamplePythonLauncher.py | ||
var req = { | ||
id : 'FileFromExternalTask', | ||
launcher : 'python', | ||
task : 'someImageTask', | ||
taskParams : {p1:1,p2:2}, | ||
Title : 'FITS from Python task', | ||
ColorTable : 2 | ||
}; | ||
firefly.showImage('imageHere', req); | ||
} | ||
} | ||
</script> | ||
|
||
<script type="text/javascript" src="../firefly_loader.js"></script> | ||
|
||
|
||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this may affect other cases where result has .error only. By adding this, it will not fall in to this block.
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.
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.