-
Notifications
You must be signed in to change notification settings - Fork 85
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
base: master
Are you sure you want to change the base?
Changes from 12 commits
da229e8
892c0fa
2e6c0d2
6feac57
145494a
661b6f7
4811cbd
76af174
673d9bb
3350595
6000383
01bf215
dfc7683
74b0ba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,51 @@ | ||
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, | ||
) | ||
from planemo.runnable import ( | ||
flatten_to_single_artifacts, | ||
for_paths, | ||
RunnableType, | ||
) | ||
|
||
|
||
def test_runnables(ctx, runnables, original_paths=None, **kwds): | ||
"""Return exit code indicating test or failure.""" | ||
if kwds.get("serve"): | ||
if "galaxy" not in kwds["engine"]: | ||
raise ValueError("The serve option is only supported by Galaxy-based engines.") | ||
kwds["galaxy_url"] = kwds["galaxy_url"] or ''.join(("http://", kwds["host"], ":", str(kwds["port"]))) | ||
kwds["galaxy_admin_key"] = kwds["galaxy_admin_key"] or DEFAULT_ADMIN_API_KEY | ||
pid = os.fork() | ||
if pid == 0: | ||
# wait for served Galaxy instance to start | ||
sleep(kwds["galaxy_url"], verbose=ctx.verbose, timeout=500) | ||
# then proceed to test against it | ||
kwds["engine"] = "external_galaxy" | ||
else: | ||
# serve Galaxy instance | ||
galaxy_serve(ctx, runnables, **kwds) | ||
exit(1) | ||
Comment on lines
+29
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forking in the presence of threads seems brittle. With #1232 we're removing the run_tests.sh mode, so you could just sleep infinitely in cmd_test.sh / cmd_shed_test.sh after merging this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
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) | ||
enable_test_engines = enable_test_engines or engine_type != "galaxy" | ||
|
||
if enable_test_engines: | ||
runnables = flatten_to_single_artifacts(runnables) # the test engines cannot deal with directories | ||
ctx.vlog("Using test engine type %s" % engine_type) | ||
with engine_context(ctx, **kwds) as engine: | ||
test_data = engine.test(runnables) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fascinating! I had no clue about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, new for me as well, I came across it while searching for a way to write a conditional with statement.