Closed kotfic closed 8 years ago
@mgrauer @aashish24 PTAL
Tests appear to be failing because http://demo.geonode.org/geoserver/wms is throwing a proxy error?
this looks great @kotfic will look into the details.
See also this gist: https://gist.github.com/kotfic/6e6e34d297479fa8ea62790c1c9ce36a for an interactive example of the PythonAnalysis and GirderWorkerPythonAnalysis classes at work.
@kotfic thanks. We will review the branch and get back to you if we have any more questions.
I am closing this one for now.
This PR implements a new approach to analyses in minerva.
Overview
analyses are implemented as a new girder resource at the
minvera_analysis
endpoint. These are in turn stored in a mongodb collection. The items in the collection model thename
,type
(e.g. python, R, etc) andpath
to an analysis file. In this PR only the 'python' type is implemented.A python analysis is a python file that contains a function
run(...)
The run function is the interface to the analysis and its arguments and certain aspects of its documentation are exposed at theminerva_analysis/{name}/meta
endpoint.Example
Consider the following analysis:
Where
/tmp/sum.py
contains the following code:Calling
GET
on/minerva_analysis/sum/meta
will return:This interface can be used to query information from the user who in turn
POST
s to/minerva_analysis/sum/
with a json body containing:Which will return the json value
4
Technical details
This process is achieved using a python abstract syntax tree parser to pull information out of the interface function (e.g.
run
) and a docutils SparseNodeVisitor to pullparam
andtype
descriptions out of the documentation. This allows the script to be the single source of truth for argument information and documentation but means thattype
values should not be relied on to be from a particular set of enumerated values. Python analyses are implemented as a objects of typePythonAnalysis
defined inserver/utility/analysis.py
Python analyses are created with the dictionary returned from loading the girder python analysis or through the convenience functionget_analysis_obj
e.g.:The
analysis
variable now exposes its inputs through theanalysis.inputs
property. and can be run withanalysis.run_analysis(args, kwargs, opts)
where args are the positional arguments to the analysis run function, kwargs are the keyword arguments, and opts is a dictionary of options for the style in which the run should be executed (Note: opts is not implemented in this PR, only stubbed out).PythonAnalysis
also implements a call method as a convenience causing it to work the same way as therun
function would work - as though it had been imported. e.g.:Notes
analysis_test.py
has been moved intobsve_analysis_test.py
, currently tests for thePythonAnalysis
class are inanalysis_test.py
and test for the REST interface are inanalysis_rest_test.py
server/utility/girder_worker_analysis.py
This implements the classGirderWorkerPythonAnalysis
and exposes aspec
property. E.g.:Print produces
GirderWorkerPythonAnalysis
does not currently implement therun_analysis
function but could be easily extended to provide this functionality.