Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 53
Algorithm Interface
Scott Sievert edited this page Feb 17, 2017
·
1 revision
- Define the inputs and outputs for the algorithm
- Write the YAML file (
myAlg.yaml) that describes the inputs and outputs. - Call the algorithm with a dictionary of arguments.
Here's an example YAML interface file for initExp. This example gives various initialization arguments and says that the return statement must be True (which is enforced by the verifier):
getQuery:
args:
n:
description: Number of targetstype: numd:
description: Dimension of embeddingtype: numrets:
description: The ID of the center targettype: tuplevalues:
0:
type: numdescription: index of 1st target1:
type: numdescription: index of 2nd targetHere's how you would call this algorithm:
A similar interface exists for myApp's functions.
classmyApp:
# ...defgetQuery(self, butler, alg, args):
# get the index of the target to ask abouttarget_indicies=alg({'n': n, 'd': d})
# pull the target with that index outtargets= [self.TargetManager.get_target_item(butler.exp_uid, i) foriintarget_indicies]
# return that targetreturn {'targets': targets}On the HTML page in getQuery_widget.html, the myApp:getQuery return statement is then available through query. In this case, myAlg:getQuery would return 0 which would be parsed
For example, you might have the following HTML to show a particular index:
<imgclass="image" src={{query.targets[0].primary_description}}></img>