Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement serve flag for planemo test #1185

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion planemo/commands/cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"instances to limit generated traffic.",
default="0",
)
@options.galaxy_target_options()
@options.serve_option()
@options.galaxy_run_options()
@options.galaxy_config_options()
@options.test_options()
@options.engine_options()
Expand Down
18 changes: 18 additions & 0 deletions planemo/engine/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import os

from planemo.engine import (
engine_context,
)
from planemo.galaxy import galaxy_config
from planemo.galaxy import galaxy_serve
from planemo.galaxy.api import (
DEFAULT_ADMIN_API_KEY
)
from planemo.galaxy.config import _find_test_data
from planemo.galaxy.ephemeris_sleep import sleep
from planemo.galaxy.test import (
handle_reports_and_summary,
run_in_config,
Expand All @@ -15,6 +22,17 @@

def test_runnables(ctx, runnables, original_paths=None, **kwds):
"""Return exit code indicating test or failure."""
if kwds.get("serve"):
kwds["engine"] = "external_galaxy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not this only works with that engine type in the option help?

kwds["galaxy_url"] = ''.join(("http://", kwds["host"], ":", kwds["port"]))
kwds["galaxy_admin_key"] = kwds["galaxy_admin_key"] or DEFAULT_ADMIN_API_KEY
pid = os.fork()
if pid == 0:
sleep(kwds["galaxy_url"], verbose=ctx.verbose, timeout=500)
else:
galaxy_serve(ctx, runnables, **kwds)
exit(1)

engine_type = kwds["engine"]
test_engine_testable = {RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory}
enable_test_engines = any(r.type not in test_engine_testable for r in runnables)
Expand Down
9 changes: 9 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,15 @@ def no_cleanup_option():
)


def serve_option():
return planemo_option(
"--serve",
is_flag=True,
default=False,
help=("Continue serving Galaxy instance after testing.")
)


def docker_enable_option():
return planemo_option(
"--docker/--no_docker",
Expand Down