3737
3838from planemo import git
3939from planemo .config import OptionSource
40+ from planemo .database import create_database_source
4041from planemo .deps import ensure_dependency_resolvers_conf_configured
4142from planemo .docker import docker_host_args
4243from planemo .galaxy .workflows import (
@@ -421,7 +422,6 @@ def config_join(*args):
421422 )
422423 )
423424 _handle_container_resolution (ctx , kwds , properties )
424- properties ["database_connection" ] = _database_connection (database_location , ** kwds )
425425 if kwds .get ("mulled_containers" , False ):
426426 properties ["mulled_channels" ] = kwds .get ("conda_ensure_channels" , "" )
427427
@@ -444,15 +444,6 @@ def config_join(*args):
444444 # https://github.com/galaxyproject/planemo/issues/788
445445 env ["GALAXY_LOG" ] = log_file
446446 env ["GALAXY_PID" ] = pid_file
447- write_galaxy_config (
448- galaxy_root = galaxy_root ,
449- properties = properties ,
450- env = env ,
451- kwds = kwds ,
452- template_args = template_args ,
453- config_join = config_join ,
454- )
455-
456447 _write_tool_conf (ctx , all_tool_paths , tool_conf )
457448 write_file (empty_tool_conf , EMPTY_TOOL_CONF_TEMPLATE )
458449
@@ -461,19 +452,29 @@ def config_join(*args):
461452 write_file (shed_tool_conf , shed_tool_conf_contents , force = False )
462453
463454 write_file (shed_data_manager_config_file , SHED_DATA_MANAGER_CONF_TEMPLATE )
455+ with _database_connection (database_location , ** kwds ) as database_connection :
456+ properties ["database_connection" ] = database_connection
457+ write_galaxy_config (
458+ galaxy_root = galaxy_root ,
459+ properties = properties ,
460+ env = env ,
461+ kwds = kwds ,
462+ template_args = template_args ,
463+ config_join = config_join ,
464+ )
464465
465- yield LocalGalaxyConfig (
466- ctx ,
467- config_directory ,
468- env ,
469- test_data_dir ,
470- port ,
471- server_name ,
472- master_api_key ,
473- runnables ,
474- galaxy_root ,
475- kwds ,
476- )
466+ yield LocalGalaxyConfig (
467+ ctx ,
468+ config_directory ,
469+ env ,
470+ test_data_dir ,
471+ port ,
472+ server_name ,
473+ master_api_key ,
474+ runnables ,
475+ galaxy_root ,
476+ kwds ,
477+ )
477478
478479
479480def write_galaxy_config (galaxy_root , properties , env , kwds , template_args , config_join ):
@@ -1104,10 +1105,17 @@ def default_use_path_paste(self):
11041105 return self .user_is_admin
11051106
11061107
1108+ @contextlib .contextmanager
11071109def _database_connection (database_location , ** kwds ):
1108- default_connection = DATABASE_LOCATION_TEMPLATE % database_location
1109- database_connection = kwds .get ("database_connection" ) or default_connection
1110- return database_connection
1110+ if kwds .get ("database_type" ) != "sqlite" :
1111+ database_source = create_database_source (** kwds )
1112+ try :
1113+ database_source .start ()
1114+ yield database_source .sqlalchemy_url (kwds .get ("database_identifier" , "galaxy" ))
1115+ finally :
1116+ database_source .stop ()
1117+ else :
1118+ yield DATABASE_LOCATION_TEMPLATE % database_location
11111119
11121120
11131121def _find_galaxy_root (ctx , ** kwds ):
0 commit comments