Skip to content

Commit c23569f

Browse files
committed
Coding on a plane and I want to use a local sqlite database...
... so lets add an option and make it setable in ~/.planemo.yml.
1 parent 49c5c1e commit c23569f

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

planemo/galaxy_config.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ def config_join(*args):
140140
preseeded_database = True
141141
master_api_key = kwds.get("master_api_key", "test_key")
142142
dependency_dir = os.path.join(config_directory, "deps")
143-
143+
galaxy_sqlite_database = kwds.get("galaxy_sqlite_database", None)
144144
try:
145145
_download_database_template(
146146
galaxy_root,
147147
database_location,
148-
latest=latest_galaxy
148+
latest=latest_galaxy,
149+
galaxy_sqlite_database=galaxy_sqlite_database,
149150
)
150151
except Exception as e:
151152
print(e)
@@ -358,7 +359,16 @@ def cleanup(self):
358359
shutil.rmtree(self.config_directory)
359360

360361

361-
def _download_database_template(galaxy_root, database_location, latest=False):
362+
def _download_database_template(
363+
galaxy_root,
364+
database_location,
365+
latest=False,
366+
galaxy_sqlite_database=None
367+
):
368+
if galaxy_sqlite_database is not None:
369+
shutil.copyfile(galaxy_sqlite_database, database_location)
370+
return True
371+
362372
if latest:
363373
template_url = DOWNLOADS_URL + urlopen(LATEST_URL).read()
364374
urlretrieve(template_url, database_location)

planemo/options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ def galaxy_root_option():
4242
)
4343

4444

45+
def galaxy_sqlite_database_option():
46+
return click.option(
47+
"--galaxy_sqlite_database",
48+
callback=get_default_callback(None, resolve_path=True),
49+
type=click.Path(exists=True, file_okay=False, resolve_path=True),
50+
help="Preseeded Galaxy sqlite database to target.",
51+
)
52+
53+
4554
def galaxy_cwl_root_option():
4655
return click.option(
4756
"--cwl_galaxy_root",
@@ -521,6 +530,7 @@ def galaxy_config_options():
521530
def galaxy_target_options():
522531
return _compose(
523532
galaxy_root_option(),
533+
galaxy_sqlite_database_option(),
524534
install_galaxy_option(),
525535
no_cache_galaxy_option(),
526536
no_cleanup_option(),

0 commit comments

Comments
 (0)