def __init__(self, app_name, security, model, tool_data_path, shed_tool_data_path, tool_data_tables=None, registry=None, hgweb_config_manager=None): self.name = app_name self.security = security self.model = model self.config = Bunch() self.config.tool_data_path = tool_data_path self.config.shed_tool_data_path = shed_tool_data_path self.temporary_path = tempfile.mkdtemp(prefix='tool_validation_') self.config.tool_data_table_config = os.path.join(self.temporary_path, 'tool_data_table_conf.xml') self.config.shed_tool_data_table_config = os.path.join(self.temporary_path, 'shed_tool_data_table_conf.xml') self.tool_data_tables = tool_data_tables self.datatypes_registry = registry self.hgweb_config_manager = hgweb_config_manager self.config.len_file_path = os.path.join(self.temporary_path, 'chromlen.txt') # If the builds file path is set to None, tools/__init__.py will load the default. # Otherwise it will attempt to load a nonexistent file and log an error. This does # not appear to be an issue with the len_file_path config option. self.config.builds_file_path = None self.genome_builds = GenomeBuilds(self)
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", self.config.database_connection, create_tables=True, object_store=self.object_store) self.security_agent = self.model.security_agent self.visualizations_registry = MockVisualizationsRegistry() self.tag_handler = tags.GalaxyTagHandler(self.model.context) self.quota_agent = quota.DatabaseQuotaAgent(self.model) self.init_datatypes() self.job_config = Bunch(dynamic_params=None, destinations={}) self.tool_data_tables = {} self.dataset_collections_service = None self.container_finder = NullContainerFinder() self._toolbox_lock = MockLock() self.tool_shed_registry = Bunch(tool_sheds={}) self.genome_builds = GenomeBuilds(self) self.job_manager = NoopManager() self.application_stack = ApplicationStack() self.auth_manager = AuthManager(self) self.user_manager = UserManager(self) self.execution_timer_factory = Bunch( get_timer=StructuredExecutionTimer) def url_for(*args, **kwds): return "/mock/url" self.url_for = url_for
def __init__(self, **kwd): log.debug("python path is: %s", ", ".join(sys.path)) self.name = "tool_shed" # Read the tool_shed.ini configuration file and check for errors. self.config = config.Configuration(**kwd) self.config.check() configure_logging(self.config) self.application_stack = application_stack_instance() # Initialize the Galaxy datatypes registry. self.datatypes_registry = galaxy.datatypes.registry.Registry() self.datatypes_registry.load_datatypes(self.config.root, self.config.datatypes_config) # Initialize the Tool Shed repository_types registry. self.repository_types_registry = tool_shed.repository_types.registry.Registry( ) # Initialize the RepositoryGridFilterManager. self.repository_grid_filter_manager = RepositoryGridFilterManager() # Determine the Tool Shed database connection string. if self.config.database_connection: db_url = self.config.database_connection else: db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database # Initialize the Tool Shed database and check for appropriate schema version. from galaxy.webapps.tool_shed.model.migrate.check import create_or_verify_database create_or_verify_database(db_url, self.config.database_engine_options) # Set up the Tool Shed database engine and ORM. from galaxy.webapps.tool_shed.model import mapping self.model = mapping.init(self.config.file_path, db_url, self.config.database_engine_options) self.security = idencoding.IdEncodingHelper( id_secret=self.config.id_secret) # initialize the Tool Shed tag handler. self.tag_handler = CommunityTagHandler(self) # Initialize the Tool Shed tool data tables. Never pass a configuration file here # because the Tool Shed should always have an empty dictionary! self.tool_data_tables = galaxy.tools.data.ToolDataTableManager( self.config.tool_data_path) self.genome_builds = GenomeBuilds(self) from galaxy import auth self.auth_manager = auth.AuthManager(self) # Citation manager needed to load tools. from galaxy.managers.citations import CitationsManager self.citations_manager = CitationsManager(self) # The Tool Shed makes no use of a Galaxy toolbox, but this attribute is still required. self.toolbox = tools.ToolBox([], self.config.tool_path, self) # Initialize the Tool Shed security agent. self.security_agent = self.model.security_agent # The Tool Shed makes no use of a quota, but this attribute is still required. self.quota_agent = galaxy.quota.NoQuotaAgent(self.model) # Initialize the baseline Tool Shed statistics component. self.shed_counter = self.model.shed_counter # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located. self.hgweb_config_manager = self.model.hgweb_config_manager self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir # Initialize the repository registry. self.repository_registry = tool_shed.repository_registry.Registry(self) # used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base. self.server_starttime = int(time.time()) log.debug("Tool shed hgweb.config file is: %s", self.hgweb_config_manager.hgweb_config)
def __init__(self, **kwd): print >> sys.stderr, "python path is: " + ", ".join(sys.path) self.name = "tool_shed" # Read the tool_shed_wsgi.ini configuration file and check for errors. self.config = config.Configuration(**kwd) self.config.check() config.configure_logging(self.config) # Initialize the Galaxy datatypes registry. self.datatypes_registry = galaxy.datatypes.registry.Registry() self.datatypes_registry.load_datatypes(self.config.root, self.config.datatypes_config) # Initialize the Tool Shed repository_types registry. self.repository_types_registry = tool_shed.repository_types.registry.Registry( ) # Initialize the RepositoryGridFilterManager. self.repository_grid_filter_manager = RepositoryGridFilterManager() # Determine the Tool Shed database connection string. if self.config.database_connection: db_url = self.config.database_connection else: db_url = "sqlite:///%s?isolation_level=IMMEDIATE" % self.config.database # Initialize the Tool Shed database and check for appropriate schema version. from galaxy.webapps.tool_shed.model.migrate.check import create_or_verify_database create_or_verify_database(db_url, self.config.database_engine_options) # Set up the Tool Shed database engine and ORM. from galaxy.webapps.tool_shed.model import mapping self.model = mapping.init(self.config.file_path, db_url, self.config.database_engine_options) # Initialize the Tool SHed security helper. self.security = security.SecurityHelper( id_secret=self.config.id_secret) # initialize the Tool Shed tag handler. self.tag_handler = CommunityTagHandler() # Initialize the Tool Shed tool data tables. Never pass a configuration file here # because the Tool Shed should always have an empty dictionary! self.tool_data_tables = galaxy.tools.data.ToolDataTableManager( self.config.tool_data_path) self.genome_builds = GenomeBuilds(self) # Citation manager needed to load tools. from galaxy.managers.citations import CitationsManager self.citations_manager = CitationsManager(self) # The Tool Shed makes no use of a Galaxy toolbox, but this attribute is still required. self.toolbox = tools.ToolBox([], self.config.tool_path, self) # Initialize the Tool Shed security agent. self.security_agent = self.model.security_agent # The Tool Shed makes no use of a quota, but this attribute is still required. self.quota_agent = galaxy.quota.NoQuotaAgent(self.model) # TODO: Add OpenID support self.openid_providers = OpenIDProviders() # Initialize the baseline Tool Shed statistics component. self.shed_counter = self.model.shed_counter # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located. self.hgweb_config_manager = self.model.hgweb_config_manager self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir # Initialize the repository registry. self.repository_registry = tool_shed.repository_registry.Registry(self) print >> sys.stderr, "Tool shed hgweb.config file is: ", self.hgweb_config_manager.hgweb_config
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"
def __init__(self, config=None, **kwargs): super().__init__() self[BasicApp] = self self[MinimalManagerApp] = self self[StructuredApp] = self self.config = config or MockAppConfig(**kwargs) self.security = self.config.security self[idencoding.IdEncodingHelper] = self.security self.name = kwargs.get('name', 'galaxy') self.object_store = objectstore.build_object_store_from_config( self.config) self.model = mapping.init("/tmp", self.config.database_connection, create_tables=True, object_store=self.object_store) self[SharedModelMapping] = self.model self[GalaxyModelMapping] = self.model self[scoped_session] = self.model.context self.security_agent = self.model.security_agent self.visualizations_registry = MockVisualizationsRegistry() self.tag_handler = tags.GalaxyTagHandler(self.model.context) self[tags.GalaxyTagHandler] = self.tag_handler self.quota_agent = quota.DatabaseQuotaAgent(self.model) self.init_datatypes() self.job_config = Bunch(dynamic_params=None, destinations={}, use_messaging=False, assign_handler=lambda *args, **kwargs: None) self.tool_data_tables = {} self.dataset_collections_service = None self.container_finder = NullContainerFinder() self._toolbox_lock = MockLock() self.tool_shed_registry = Bunch(tool_sheds={}) self.genome_builds = GenomeBuilds(self) self.job_manager = NoopManager() self.application_stack = ApplicationStack() self.auth_manager = AuthManager(self.config) self.user_manager = UserManager(self) self.execution_timer_factory = Bunch( get_timer=StructuredExecutionTimer) self.is_job_handler = False rebind_container_to_task(self) def url_for(*args, **kwds): return "/mock/url" self.url_for = url_for
def __init__( self, sa_session: SessionlessContext, tool_app_config: ToolAppConfig, datatypes_registry: Registry, object_store: ObjectStore, tool_data_table_manager: ToolDataTableManager, file_sources: ConfiguredFileSources, ): self.model = Bunch(context=sa_session) self.config = tool_app_config self.datatypes_registry = datatypes_registry self.object_store = object_store self.genome_builds = GenomeBuilds(self) self.tool_data_tables = tool_data_table_manager self.file_sources = file_sources self.biotools_metadata_source = None
def __init__(self, config=None, **kwargs): super().__init__() config = config or MockAppConfig(**kwargs) GalaxyDataTestApp.__init__(self, config=config, **kwargs) self[BasicSharedApp] = self self[MinimalManagerApp] = self self[StructuredApp] = self self[idencoding.IdEncodingHelper] = self.security self.name = kwargs.get('name', 'galaxy') self[SharedModelMapping] = self.model self[GalaxyModelMapping] = self.model self[galaxy_scoped_session] = self.model.context self.visualizations_registry = MockVisualizationsRegistry() self.tag_handler = tags.GalaxyTagHandler(self.model.context) self[tags.GalaxyTagHandler] = self.tag_handler self.quota_agent = quota.DatabaseQuotaAgent(self.model) self.job_config = Bunch( dynamic_params=None, destinations={}, use_messaging=False, assign_handler=lambda *args, **kwargs: None ) self.tool_data_tables = ToolDataTableManager(tool_data_path=self.config.tool_data_path) self.dataset_collections_service = None self.container_finder = NullContainerFinder() self._toolbox_lock = MockLock() self.tool_shed_registry = Bunch(tool_sheds={}) self.genome_builds = GenomeBuilds(self) self.job_manager = NoopManager() self.application_stack = ApplicationStack() self.auth_manager = AuthManager(self.config) self.user_manager = UserManager(self) self.execution_timer_factory = Bunch(get_timer=StructuredExecutionTimer) self.file_sources = Bunch(to_dict=lambda *args, **kwargs: {}) self.interactivetool_manager = Bunch(create_interactivetool=lambda *args, **kwargs: None) self.is_job_handler = False self.biotools_metadata_source = None rebind_container_to_task(self) def url_for(*args, **kwds): return "/mock/url" self.url_for = url_for
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()
def _configure_genome_builds(self, data_table_name="__dbkeys__", load_old_style=True): self.genome_builds = GenomeBuilds(self, data_table_name=data_table_name, load_old_style=load_old_style)
def __init__(self, **kwd) -> None: super().__init__() self[BasicApp] = self log.debug("python path is: %s", ", ".join(sys.path)) self.name = "tool_shed" # will be overwritten when building WSGI app self.is_webapp = False # Read the tool_shed.ini configuration file and check for errors. self.config: Any = config.Configuration(**kwd) self.config.check() configure_logging(self.config) self.application_stack = application_stack_instance() # Initialize the Galaxy datatypes registry. self.datatypes_registry = galaxy.datatypes.registry.Registry() self.datatypes_registry.load_datatypes(self.config.root, self.config.datatypes_config) # Initialize the Tool Shed repository_types registry. self.repository_types_registry = tool_shed.repository_types.registry.Registry( ) # Initialize the RepositoryGridFilterManager. self.repository_grid_filter_manager = RepositoryGridFilterManager() # Determine the Tool Shed database connection string. if self.config.database_connection: db_url = self.config.database_connection else: db_url = f"sqlite:///{self.config.database}?isolation_level=IMMEDIATE" # Initialize the Tool Shed database and check for appropriate schema version. from tool_shed.webapp.model.migrate.check import create_or_verify_database create_or_verify_database(db_url, self.config.database_engine_options) # Set up the Tool Shed database engine and ORM. from tool_shed.webapp.model import mapping model: mapping.ToolShedModelMapping = mapping.init( self.config.file_path, db_url, self.config.database_engine_options) self.model = model self.security = idencoding.IdEncodingHelper( id_secret=self.config.id_secret) self._register_singleton(idencoding.IdEncodingHelper, self.security) self._register_singleton(SharedModelMapping, model) self._register_singleton(mapping.ToolShedModelMapping, model) self._register_singleton(scoped_session, self.model.context) self._register_singleton(UserManager, UserManager) # initialize the Tool Shed tag handler. self.tag_handler = CommunityTagHandler(self) # Initialize the Tool Shed tool data tables. Never pass a configuration file here # because the Tool Shed should always have an empty dictionary! self.tool_data_tables = galaxy.tools.data.ToolDataTableManager( self.config.tool_data_path) self.genome_builds = GenomeBuilds(self) self.auth_manager = self._register_singleton( auth.AuthManager, auth.AuthManager(self.config)) # Citation manager needed to load tools. self.citations_manager = self._register_singleton( CitationsManager, CitationsManager(self)) self.use_tool_dependency_resolution = False # Initialize the Tool Shed security agent. self.security_agent = model.security_agent # The Tool Shed makes no use of a quota, but this attribute is still required. self.quota_agent = self._register_singleton(QuotaAgent, NoQuotaAgent()) # Initialize the baseline Tool Shed statistics component. self.shed_counter = model.shed_counter # Let the Tool Shed's HgwebConfigManager know where the hgweb.config file is located. self.hgweb_config_manager = hgweb_config_manager self.hgweb_config_manager.hgweb_config_dir = self.config.hgweb_config_dir # Initialize the repository registry. self.repository_registry = tool_shed.repository_registry.Registry(self) # used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base. self.server_starttime = int(time.time()) log.debug("Tool shed hgweb.config file is: %s", self.hgweb_config_manager.hgweb_config)