Example #1
0
 def __init__(self, app):
     self.app = app
     self.job_lock = False
     if self.app.is_job_handler:
         log.debug("Initializing job handler")
         self.job_handler = handler.JobHandler(app)
         self.job_stop_queue = self.job_handler.job_stop_queue
     elif app.application_stack.has_pool(
             app.application_stack.pools.JOB_HANDLERS):
         log.debug("Initializing job handler messaging interface")
         self.job_handler = MessageJobHandler(app)
         self.job_stop_queue = NoopQueue()
     else:
         self.job_handler = NoopHandler()
         self.job_stop_queue = NoopQueue()
     self.job_queue = self.job_handler.job_queue
Example #2
0
    def __init__(self, test_directory, mock_model=True):
        # The following line is needed in order to create
        # HistoryDatasetAssociations - ideally the model classes would be
        # usable without the ORM infrastructure in place.
        in_memomry_model = mapping.init("/tmp",
                                        "sqlite:///:memory:",
                                        create_tables=True)

        self.datatypes_registry = Bunch(
            integrated_datatypes_configs=
            '/galaxy/integrated_datatypes_configs.xml',
            get_datatype_by_extension=lambda ext: Bunch(),
        )

        self.config = Bunch(
            outputs_to_working_directory=False,
            commands_in_new_shell=True,
            new_file_path=os.path.join(test_directory, "new_files"),
            tool_data_path=os.path.join(test_directory, "tools"),
            root=os.path.join(test_directory, "galaxy"),
            admin_users="*****@*****.**",
            len_file_path=os.path.join('tool-data', 'shared', 'ucsc', 'chrom'),
            builds_file_path=os.path.join('tool-data', 'shared', 'ucsc',
                                          'builds.txt.sample'),
            migrated_tools_config=os.path.join(test_directory,
                                               "migrated_tools_conf.xml"),
        )

        # Setup some attributes for downstream extension by specific tests.
        self.job_config = Bunch(dynamic_params=None, )

        # Two ways to handle model layer, one is to stub out some objects that
        # have an interface similar to real model (mock_model) and can keep
        # track of 'persisted' objects in a map. The other is to use a real
        # sqlalchemy layer but target an in memory database. Depending on what
        # is being tested.
        if mock_model:
            # Create self.model to mimic app.model.
            self.model = Bunch(context=MockContext())
            for module_member_name in dir(galaxy.model):
                module_member = getattr(galaxy.model, module_member_name)
                if type(module_member) == type:
                    self.model[module_member_name] = module_member
        else:
            self.model = in_memomry_model
        self.genome_builds = GenomeBuilds(self)
        self.toolbox = None
        self.object_store = None
        self.security = SecurityHelper(id_secret="testing")
        from galaxy.security import GalaxyRBACAgent
        self.job_queue = NoopQueue()
        self.security_agent = GalaxyRBACAgent(self.model)
        self.tool_data_tables = {}
        self.dataset_collections_service = None
        self.container_finder = NullContainerFinder()
        self.name = "galaxy"
Example #3
0
 def __init__(self, app):
     self.app = app
     if self.app.is_job_handler():
         log.debug("Starting job handler")
         self.job_handler = handler.JobHandler(app)
         self.job_queue = self.job_handler.job_queue
         self.job_stop_queue = self.job_handler.job_stop_queue
     else:
         self.job_handler = NoopHandler()
         self.job_queue = self.job_stop_queue = NoopQueue()
     self.job_lock = False
Example #4
0
 def __init__(self, app):
     # This runs in the web (main) process pre-fork
     self.app = app
     self.job_queue = MessageJobQueue(app)
     self.job_stop_queue = NoopQueue()
     jobs_at_startup = self.app.model.context.query(Job).enable_eagerloads(False) \
         .filter((Job.state == Job.states.NEW) & (Job.handler == null())).all()
     if jobs_at_startup:
         log.info(
             'No handler assigned at startup for the following jobs, will dispatch via message: %s',
             ', '.join([str(j.id) for j in jobs_at_startup]))
     for job in jobs_at_startup:
         self.job_queue.put(job.id, job.tool_id)
Example #5
0
 def __init__(self, app):
     self.app = app
     if (self.app.config.track_jobs_in_database
             and self.app.job_config.is_handler(self.app.config.server_name)
         ) or not self.app.config.track_jobs_in_database:
         log.debug("Starting job handler")
         self.job_handler = handler.JobHandler(app)
         self.job_queue = self.job_handler.job_queue
         self.job_stop_queue = self.job_handler.job_stop_queue
     else:
         self.job_handler = NoopHandler()
         self.job_queue = self.job_stop_queue = NoopQueue()
     self.job_lock = False
Example #6
0
 def __init__( self, app ):
     self.app = app
     self.job_handler = NoopHandler()
     if self.app.config.server_name in self.app.config.job_handlers:
         self.job_handler = handler.JobHandler( app )
     if self.app.config.server_name == self.app.config.job_manager:
         job_handler = NoopHandler()
         # In the case that webapp == manager == handler, pass jobs in memory
         if not self.app.config.track_jobs_in_database:
             job_handler = self.job_handler
         # Otherwise, even if the manager == one of the handlers, its handler will pick up jobs from the database
         self.job_queue = JobManagerQueue( app, job_handler )
         self.job_stop_queue = JobManagerStopQueue( app, job_handler )
         if self.app.config.enable_beta_job_managers:
             from galaxy.jobs.deferred import DeferredJobQueue
             self.deferred_job_queue = DeferredJobQueue( app )
     else:
         self.job_queue = self.job_stop_queue = NoopQueue()
     self.job_handler.start()
Example #7
0
 def __init__(self, config=None, **kwargs):
     self.config = config or MockAppConfig(**kwargs)
     self.security = self.config.security
     self.name = kwargs.get('name', 'galaxy')
     self.object_store = objectstore.build_object_store_from_config(self.config)
     self.model = mapping.init("/tmp", "sqlite:///:memory:", create_tables=True, object_store=self.object_store)
     self.security_agent = self.model.security_agent
     self.visualizations_registry = MockVisualizationsRegistry()
     self.tag_handler = tags.GalaxyTagManager(self.model.context)
     self.quota_agent = quota.QuotaAgent(self.model)
     self.init_datatypes()
     self.job_config = Bunch(
         dynamic_params=None,
     )
     self.tool_data_tables = {}
     self.dataset_collections_service = None
     self.container_finder = NullContainerFinder()
     self._toolbox_lock = MockLock()
     self.genome_builds = GenomeBuilds(self)
     self.job_manager = Bunch(job_queue=NoopQueue())
     self.application_stack = ApplicationStack()
Example #8
0
 def __init__(self, *args, **kwargs):
     self.job_queue = NoopQueue()
     self.job_stop_queue = NoopQueue()