Skip to content

Commit 31ca8a0

Browse files
committed
Store postgres database in profile by default
1 parent aefdaaf commit 31ca8a0

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

planemo/database/factory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Create a DatabaseSource from supplied planemo configuration."""
22

3+
from typing import Optional
4+
35
from galaxy.util.commands import which
46

57
from .interface import DatabaseSource
@@ -8,7 +10,7 @@
810
from .postgres_singularity import SingularityPostgresDatabaseSource
911

1012

11-
def create_database_source(**kwds) -> DatabaseSource:
13+
def create_database_source(profile_directory: Optional[str] = None, **kwds) -> DatabaseSource:
1214
"""Return a :class:`planemo.database.interface.DatabaseSource` for configuration."""
1315
database_type = kwds.get("database_type", "auto")
1416
if database_type == "auto":
@@ -26,7 +28,7 @@ def create_database_source(**kwds) -> DatabaseSource:
2628
elif database_type == "postgres_docker":
2729
return DockerPostgresDatabaseSource(**kwds)
2830
elif database_type == "postgres_singularity":
29-
return SingularityPostgresDatabaseSource(**kwds)
31+
return SingularityPostgresDatabaseSource(profile_directory=profile_directory, **kwds)
3032
# TODO
3133
# from .sqlite import SqliteDatabaseSource
3234
# elif database_type == "sqlite":

planemo/database/interface.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
class DatabaseSource(metaclass=abc.ABCMeta):
88
"""Interface describing a source of profile databases."""
99

10-
@abc.abstractmethod
11-
def create_database(self, identifier):
12-
"""Create a database with specified short identifier.
13-
14-
Throw an exception if it already exists.
15-
"""
16-
1710
@abc.abstractmethod
1811
def delete_database(self, identifier):
1912
"""Delete a database with specified short identifier.

planemo/database/postgres_singularity.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import time
55
from tempfile import mkdtemp
6+
from typing import Optional
67

78
from galaxy.util.commands import shell_process
89

@@ -76,14 +77,16 @@ class SingularityPostgresDatabaseSource(ExecutesPostgresSqlMixin, DatabaseSource
7677
"with" statements to automatically start and stop the container.
7778
"""
7879

79-
def __init__(self, **kwds):
80+
def __init__(self, profile_directory: Optional[str] = None, **kwds):
8081
"""Construct a postgres database source from planemo configuration."""
8182

8283
self.singularity_path = "singularity"
8384
self.database_user = DEFAULT_POSTGRES_USER
8485
self.database_password = DEFAULT_POSTGRES_PASSWORD
85-
if "postgres_storage_location" in kwds and kwds["postgres_storage_location"] is not None:
86+
if kwds.get("postgres_storage_location") is not None:
8687
self.database_location = kwds["postgres_storage_location"]
88+
elif profile_directory:
89+
self.database_location = os.path.join(profile_directory, "postgres")
8790
else:
8891
self.database_location = os.path.join(mkdtemp(suffix="_planemo_postgres_db"))
8992
self.database_socket_dir = os.path.join(self.database_location, "pgrun")

0 commit comments

Comments
 (0)