def test_fasta_count(self, l): job = map_tool_to_destination(dbcountJob, theApp, dbTool, "*****@*****.**", True, path) self.assertEquals(job, 'Destination4') priority_job = map_tool_to_destination(dbcountJob, theApp, dbTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'Destination4_high') l.check(('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test.fasta'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total amount of records: 6'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_db' with 'Destination4'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test.fasta'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total amount of records: 6'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_db' with 'Destination4_high'."))
def test_tool_not_found(self, l): job = map_tool_to_destination(runJob, theApp, unTool, "*****@*****.**", True, path) self.assertEquals(job, 'waffles_default') priority_job = map_tool_to_destination(runJob, theApp, unTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'waffles_default_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Tool 'unregistered' not specified in config. Using default destination." ), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'unregistered' with 'waffles_default'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Tool 'unregistered' not specified in config. Using default destination." ), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'unregistered' with 'waffles_default_high'."))
def test_filesize_run(self, l): job = map_tool_to_destination(runJob, theApp, vanillaTool, "*****@*****.**", True, path) self.assertEquals(job, 'Destination1') priority_job = map_tool_to_destination(runJob, theApp, vanillaTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'Destination1_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test3.full'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total size: 3.23 KB'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total number of files: 1'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test' with 'Destination1'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test3.full'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total size: 3.23 KB'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total number of files: 1'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test' with 'Destination1_high'."))
def test_arguments_arg_not_found(self, l): job = map_tool_to_destination(argNotFoundJob, theApp, argTool, "*****@*****.**", True, path) self.assertEquals(job, 'waffles_default') priority_job = map_tool_to_destination(argNotFoundJob, theApp, argTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'waffles_default_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'waffles_default'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'waffles_default_high'.") )
def test_arguments_tool(self, l): job = map_tool_to_destination(argJob, theApp, argTool, "*****@*****.**", True, path) self.assertEquals(job, 'Destination6') priority_job = map_tool_to_destination(argJob, theApp, argTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'Destination6_med') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'Destination6'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'Destination6_med'.") )
def test_arguments_arg_not_found(self, l): job = map_tool_to_destination( argNotFoundJob, theApp, argTool, "*****@*****.**", True, path ) self.assertEquals( job, 'waffles_default' ) priority_job = map_tool_to_destination( argNotFoundJob, theApp, argTool, "*****@*****.**", True, priority_path ) self.assertEquals( priority_job, 'waffles_default_high' ) l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'waffles_default'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'waffles_default_high'.") )
def test_arguments_tool(self, l): job = map_tool_to_destination( argJob, theApp, argTool, "*****@*****.**", True, path ) self.assertEquals( job, 'Destination6' ) priority_job = map_tool_to_destination( argJob, theApp, argTool, "*****@*****.**", True, priority_path ) self.assertEquals( priority_job, 'Destination6_med' ) l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'Destination6'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_arguments' with 'Destination6_med'.") )
def test_unauthorized_user(self, l): job = map_tool_to_destination(runJob, theApp, usersTool, "*****@*****.**", True, users_test_path) self.assertEquals(job, 'lame_cluster') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_users' with 'lame_cluster'.") )
def test_no_verbose(self, l): job = map_tool_to_destination(runJob, theApp, noVBTool, "*****@*****.**", True, no_verbose_path) self.assertEquals(job, 'Destination1') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_no_verbose' with 'Destination1'.") )
def test_tool_not_found(self, l): job = map_tool_to_destination(runJob, theApp, unTool, "*****@*****.**", True, path) self.assertEquals(job, 'waffles_default') priority_job = map_tool_to_destination(runJob, theApp, unTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'waffles_default_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Tool 'unregistered' not specified in config. Using default destination."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'unregistered' with 'waffles_default'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Tool 'unregistered' not specified in config. Using default destination."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'unregistered' with 'waffles_default_high'.") )
def test_unauthorized_user(self, l): job = map_tool_to_destination( runJob, theApp, usersTool, "*****@*****.**", True, users_test_path ) self.assertEquals( job, 'lame_cluster' ) l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_users' with 'lame_cluster'.") )
def test_no_verbose(self, l): job = map_tool_to_destination( runJob, theApp, noVBTool, "*****@*****.**", True, no_verbose_path ) self.assertEquals( job, 'Destination1' ) l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_no_verbose' with 'Destination1'.") )
def gateway(job, app, tool, user, user_email): """ Function to specify the destination for a job. At present this is exactly the same as using dynamic_dtd with tool_destinations.yml but can be extended to more complex mapping such as limiting resources based on user group or selecting destinations based on queue size. Arguments to this function can include app, job, job_id, job_wrapper, tool, tool_id, user, user_email (see https://docs.galaxyproject.org/en/latest/admin/jobs.html) """ if user_email in user_destinations.keys(): if hasattr(tool, 'id') and isinstance( tool.id, str) and tool.id.startswith('toolshed'): # map shed tools only return user_destinations[user_email] #if user: # user_roles = [role.name for role in user.all_roles() if not role.deleted] # If any of these are prefixed with 'training-' #if any([role.startswith('training-') for role in user_roles]): # # Then they are a training user, we will send their jobs to pulsar, # # Or give them extra resources # if hasattr(tool, 'id') and isinstance(tool.id, str) and tool.id.startswith('toolshed') and tool.id.split('/')[-2] in pulsar_list: # return app.job_config.get_destination('pulsar_destination') # else: # return app.job_config.get_destination('slurm_dest') destination = map_tool_to_destination(job, app, tool, user_email, path=TOOL_DESTINATION_PATH) return destination
def test_fasta_count(self, l): job = map_tool_to_destination(dbcountJob, theApp, dbTool, "*****@*****.**", True, path) self.assertEquals(job, 'Destination4') priority_job = map_tool_to_destination(dbcountJob, theApp, dbTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'Destination4_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test.fasta'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total amount of records: 6'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_db' with 'Destination4'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test.fasta'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total amount of records: 6'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test_db' with 'Destination4_high'.") )
def test_filesize_run(self, l): job = map_tool_to_destination(runJob, theApp, vanillaTool, "*****@*****.**", True, path) self.assertEquals(job, 'Destination1') priority_job = map_tool_to_destination(runJob, theApp, vanillaTool, "*****@*****.**", True, priority_path) self.assertEquals(priority_job, 'Destination1_high') l.check( ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test3.full'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total size: 3.23 KB'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total number of files: 1'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test' with 'Destination1'."), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Running config validation...'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Finished config validation.'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Loading file: input1' + script_dir + '/data/test3.full'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total size: 3.23 KB'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', 'Total number of files: 1'), ('galaxy.jobs.dynamic_tool_destination', 'DEBUG', "Running 'test' with 'Destination1_high'.") )
def gateway(job, app, tool, user_email): """ Function to specify the destination for a job. At present this is exactly the same as using dynamic_dtd with tool_destinations.yml but can be extended to more complex mapping such as limiting resources based on user group or selecting destinations based on queue size. Arguments to this function can include app, job, job_id, job_wrapper, tool, tool_id, user, user_email (see https://docs.galaxyproject.org/en/latest/admin/jobs.html) """ # map jobs from user_destinations if user_email in user_destinations.keys(): if hasattr(tool, 'id') and isinstance(tool.id, str) and tool.id.startswith('toolshed'): # map shed tools only return user_destinations[user_email] destination = map_tool_to_destination(job, app, tool, user_email, path=TOOL_DESTINATION_PATH) return destination