Il giorno ven, 20/09/2013 alle 10.25 -0500, John Chilton ha scritto:
On Fri, Sep 20, 2013 at 9:08 AM, Nicola Soranzo soranzo@crs4.it wrote:
First step is to create a new dynamic job destination, this is demonstrated in job_conf.xml in the above changeset. This demonstrates the new style job_conf section - this will need to be adapted for the old style runners but is still doable.
Then you will want to add a dynamic job runner rule that implements this logic. This is the file lib/galaxy/jobs/rules/license_checker.py.
Is there a way to specify in job_conf.xml a per-tool final destination after the has_license filtering ? E.g.:
<tool id="cat1" destination="has_license" final_destination="local" /> <tool id="cat2" destination="has_license" final_destination="remote_cluster" />
The 'final_destination' attribute would then be used in has_license function instead of returning DEFAULT_JOB_DESTINATION_ID.
There is no way currently to pass information from the tool tag to the dynamic runner or to have the dynamic runner "pass" on making a decision in some way. It could potentially make sense to add these - but I would put forward a workaround that in my opinion is actually a little better: ...
I have actually found a way to implement my idea of specifying a final destination! I also generalized your approach giving the possibility to also specify a per-tool required group in jobs_conf.xml .
job_conf.xml :
<?xml version="1.0"?> <job_conf> <plugins workers="4"> <plugin id="local" type="runner" load="galaxy.jobs.runners.local:LocalJobRunner" /> <plugin id="drmaa" type="runner" load="galaxy.jobs.runners.drmaa:DRMAAJobRunner" /> </plugins> <handlers> <handler id="main"/> </handlers> <destinations default="remote_cluster"> <destination id="local" runner="local" /> <destination id="is_user_in_group" runner="dynamic"> <param id="function">is_user_in_group</param> </destination> <destination id="remote_cluster" runner="drmaa" /> </destinations> <tools> <tool id="tool1" destination="is_user_in_group" required_group="other_group" /> <tool id="tool2" destination="is_user_in_group" final_destination="local" /> </tools> </job_conf>
lib/galaxy/jobs/rules/is_user_in_group.py :
from galaxy.jobs.mapper import JobMappingException DEFAULT_GROUP = 'have_license'
def is_user_in_group(user, app, tool_id): # app is a galaxy.app.UniverseApplication object if user is None: raise JobMappingException('You must login to use this tool!') user_group_assocs = user.groups or [] default_destination_id = app.job_config.get_destination(None) for jtc in app.job_config.get_job_tool_configurations(tool_id): # app.job_config.get_job_tool_configurations(tool_id) returns a list of galaxy.jobs.JobToolConfiguration objects if not jtc.params: required_group = jtc.get('required_group', DEFAULT_GROUP) final_destination = jtc.get('final_destination', default_destination_id) break else: required_group = DEFAULT_GROUP final_destination = default_destination_id user_in_group = required_group in [user_group_assoc.group.name for user_group_assoc in user_group_assocs] if not user_in_group: raise JobMappingException('This tool is restricted to users in the %s group, please contact a site administrator to be authorized!' % required_group) else: return final_destination
Hope that helps, Nicola