mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Vis registry: add two tests (has_attribute, not_eq); add see also for test types in visualization.dtd; correct applicability tests for trackster and circster using not_eq on datatype.track_type
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
<data_sources>
|
||||
<data_source>
|
||||
<model_class>HistoryDatasetAssociation</model_class>
|
||||
<test type="isinstance" test_attr="datatype" result_type="datatype">data.Data</test>
|
||||
<test type="not_eq" test_attr="datatype.track_type">None</test>
|
||||
<to_param param_attr="id">dataset_id</to_param>
|
||||
<to_param assign="hda">hda_ldda</to_param>
|
||||
</data_source>
|
||||
<data_source>
|
||||
<model_class>LibraryDatasetDatasetAssociation</model_class>
|
||||
<test type="isinstance" test_attr="datatype" result_type="datatype">data.Data</test>
|
||||
<test type="not_eq" test_attr="datatype.track_type">None</test>
|
||||
<to_param param_attr="id">dataset_id</to_param>
|
||||
<to_param assign="ldda">hda_ldda</to_param>
|
||||
</data_source>
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
<data_sources>
|
||||
<data_source>
|
||||
<model_class>HistoryDatasetAssociation</model_class>
|
||||
<test type="isinstance" test_attr="datatype" result_type="datatype">data.Data</test>
|
||||
<test type="not_eq" test_attr="datatype.track_type">None</test>
|
||||
<to_param param_attr="id">dataset_id</to_param>
|
||||
<to_param assign="hda">hda_ldda</to_param>
|
||||
<to_param param_attr="dbkey">dbkey</to_param>
|
||||
</data_source>
|
||||
<data_source>
|
||||
<model_class>LibraryDatasetDatasetAssociation</model_class>
|
||||
<test type="isinstance" test_attr="datatype" result_type="datatype">data.Data</test>
|
||||
<test type="not_eq" test_attr="datatype.track_type">None</test>
|
||||
<to_param param_attr="id">dataset_id</to_param>
|
||||
<to_param assign="ldda">hda_ldda</to_param>
|
||||
</data_source>
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
Currently, all tests are OR'd and there is no logical grouping. Tests are run in order.
|
||||
(text): the text of this element is what the given target will be compared to (REQUIRED)
|
||||
type: what type of test to run (e.g. when the target is an HDA the test will often be of type 'isinstance'
|
||||
and test whether the HDA's datatype isinstace of a class)
|
||||
and test whether the HDA's datatype isinstace of a class).
|
||||
See lib/galaxy/visualizations/registry.py, DataSourceParser.parse_tests for test type options.
|
||||
DEFAULT: string comparison.
|
||||
test_attr: what attribute of the target object should be used in the test. For instance, 'datatype'
|
||||
will attempt to get the HDA.datatype from a target HDA. If the given object doesn't have
|
||||
|
||||
@@ -203,6 +203,7 @@ class VisualizationsRegistry( pluginframework.PageServingPluginManager ):
|
||||
#log.debug( '\t passed model_class' )
|
||||
|
||||
# tests are optional - default is the above class test
|
||||
#TODO: not true: must have test currently
|
||||
tests = data_source[ 'tests' ]
|
||||
if tests and not self.is_object_applicable( trans, target_object, tests ):
|
||||
continue
|
||||
@@ -228,14 +229,14 @@ class VisualizationsRegistry( pluginframework.PageServingPluginManager ):
|
||||
Run a visualization's data_source tests to find out if
|
||||
it can be applied to the target_object.
|
||||
"""
|
||||
#log.debug( 'is_object_applicable( self, trans, %s, %s )', target_object, data_source_tests )
|
||||
log.debug( 'is_object_applicable( self, trans, %s, %s )', target_object, data_source_tests )
|
||||
for test in data_source_tests:
|
||||
test_type = test[ 'type' ]
|
||||
result_type = test[ 'result_type' ]
|
||||
test_result = test[ 'result' ]
|
||||
test_fn = test[ 'fn' ]
|
||||
#log.debug( '%s %s: %s, %s, %s, %s', str( target_object ), 'is_object_applicable',
|
||||
# test_type, result_type, test_result, test_fn )
|
||||
log.debug( '%s %s: %s, %s, %s, %s', str( target_object ), 'is_object_applicable',
|
||||
test_type, result_type, test_result, test_fn )
|
||||
|
||||
if test_type == 'isinstance':
|
||||
# parse test_result based on result_type (curr: only datatype has to do this)
|
||||
@@ -253,7 +254,7 @@ class VisualizationsRegistry( pluginframework.PageServingPluginManager ):
|
||||
|
||||
#NOTE: tests are OR'd, if any test passes - the visualization can be applied
|
||||
if test_fn( target_object, test_result ):
|
||||
#log.debug( '\t test passed' )
|
||||
log.debug( '\t test passed' )
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -407,6 +408,7 @@ class VisualizationsConfigParser( object ):
|
||||
|
||||
# allow manually turning off a vis by checking for a disabled property
|
||||
if 'disabled' in xml_tree.attrib:
|
||||
#TODO: differentiate between disabled and failed to parse, log.warn only on failure, log.info otherwise
|
||||
return None
|
||||
|
||||
# a text display name for end user links
|
||||
@@ -627,6 +629,13 @@ class DataSourceParser( object ):
|
||||
test_fn = lambda o, result: ( hasattr( getter( o ), 'has_dataprovider' )
|
||||
and getter( o ).has_dataprovider( result ) )
|
||||
|
||||
elif test_type == 'has_attribute':
|
||||
# does the object itself have attr in 'result' (no equivalence checking)
|
||||
test_fn = lambda o, result: hasattr( getter( o ), result )
|
||||
|
||||
elif test_type == 'not_eq':
|
||||
test_fn = lambda o, result: str( getter( o ) ) != result
|
||||
|
||||
else:
|
||||
# default to simple (string) equilavance (coercing the test_attr to a string)
|
||||
test_fn = lambda o, result: str( getter( o ) ) == result
|
||||
|
||||
Reference in New Issue
Block a user