Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions planemo/galaxy/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def _create_profile_docker(ctx, profile_directory, profile_name, kwds):

def _create_profile_local(ctx, profile_directory, profile_name, kwds):
database_type = kwds.get("database_type", "auto")
allow_sqlite_fallback = database_type == "auto"
if database_type == "auto":
if which("psql"):
database_type = "postgres"
Expand All @@ -97,10 +98,21 @@ def _create_profile_local(ctx, profile_directory, profile_name, kwds):
if database_type not in ["sqlite", "postgres_singularity"]:
database_source = create_database_source(**kwds)
database_identifier = _profile_to_database_identifier(profile_name)
database_source.create_database(
database_identifier,
)
database_connection = database_source.sqlalchemy_url(database_identifier)
try:
database_source.create_database(
database_identifier,
)
except RuntimeError:
if allow_sqlite_fallback:
# If postgres database creation fails (e.g., role doesn't exist, connection issues),
# fall back to sqlite
database_type = "sqlite"
database_location = os.path.join(profile_directory, "galaxy.sqlite")
database_connection = DATABASE_LOCATION_TEMPLATE % database_location
Comment thread
mvdbeek marked this conversation as resolved.
Outdated
else:
raise
else:
database_connection = database_source.sqlalchemy_url(database_identifier)
elif database_type == "postgres_singularity":
database_connection + database_source.sqlalchemy_url(database_identifier)
Comment thread
nsoranzo marked this conversation as resolved.
else:
Comment thread
mvdbeek marked this conversation as resolved.
Outdated
Expand Down