Skip to content

Commit 499b501

Browse files
authored
Merge pull request #894 from jmchilton/workflow_edit
Command to open workflow in a synchronized graphical editor.
2 parents 1e1cfa4 + f42fd0c commit 499b501

6 files changed

Lines changed: 46 additions & 7 deletions

File tree

planemo/commands/cmd_shed_serve.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
"""Module describing the planemo ``shed_serve`` command."""
2-
import time
3-
42
import click
53

64
from planemo import io
75
from planemo import options
86
from planemo import shed
97
from planemo.cli import command_function
108
from planemo.galaxy import shed_serve
9+
from planemo.galaxy.serve import sleep_for_serve
1110

1211

1312
@click.command("shed_serve")
@@ -33,6 +32,5 @@ def cli(ctx, paths, **kwds):
3332
"""
3433
install_args_list = shed.install_arg_lists(ctx, paths, **kwds)
3534
with shed_serve(ctx, install_args_list, **kwds) as config:
36-
gx_url = "http://localhost:%d/" % config.port
37-
io.info("Galaxy running with tools installed at %s" % gx_url)
38-
time.sleep(1000000)
35+
io.info("Galaxy running with tools installed at %s" % config.galaxy_url)
36+
sleep_for_serve()

planemo/commands/cmd_workflow_convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli(ctx, workflow_path, output=None, force=False, **kwds):
4545

4646
runnable = for_path(workflow_path)
4747
with engine_context(ctx, **kwds) as galaxy_engine:
48-
with galaxy_engine.serve_runnables([runnable]) as config:
48+
with galaxy_engine.ensure_runnables_served([runnable]) as config:
4949
workflow_id = config.workflow_id(workflow_path)
5050
output_dict = config.gi.workflows.export_workflow_dict(workflow_id)
5151

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Module describing the planemo ``workflow_edit`` command."""
2+
import click
3+
4+
from planemo import options
5+
from planemo.cli import command_function
6+
from planemo.engine import (
7+
engine_context,
8+
is_galaxy_engine,
9+
)
10+
from planemo.galaxy.serve import sleep_for_serve
11+
from planemo.runnable import (
12+
for_path,
13+
)
14+
15+
16+
@click.command('workflow_edit')
17+
@options.required_workflow_arg()
18+
@options.galaxy_serve_options()
19+
@command_function
20+
def cli(ctx, workflow_path, output=None, force=False, **kwds):
21+
"""Open a synchronized Galaxy workflow editor.
22+
"""
23+
assert is_galaxy_engine(**kwds)
24+
25+
kwds["workflows_from_path"] = True
26+
27+
runnable = for_path(workflow_path)
28+
with engine_context(ctx, **kwds) as galaxy_engine:
29+
with galaxy_engine.ensure_runnables_served([runnable]) as config:
30+
workflow_id = config.workflow_id(workflow_path)
31+
url = "%s/workflow/editor?id=%s" % (config.galaxy_url, workflow_id)
32+
click.launch(url)
33+
sleep_for_serve()

planemo/galaxy/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,10 @@ def _install_workflow(self, runnable):
752752
if self._kwds["shed_install"]:
753753
install_shed_repos(runnable, self.gi, self._kwds.get("ignore_dependency_problems", False))
754754

755+
default_from_path = self._kwds.get("workflows_from_path", False)
755756
# TODO: Allow serialization so this doesn't need to assume a
756757
# shared filesystem with Galaxy server.
757-
from_path = runnable.type.name == "cwl_workflow"
758+
from_path = default_from_path or (runnable.type.name == "cwl_workflow")
758759
workflow = import_workflow(
759760
runnable.path, admin_gi=self.gi, user_gi=self.user_gi, from_path=from_path
760761
)

planemo/galaxy/serve.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import contextlib
55
import os
6+
import time
67

78
from planemo import io
89
from planemo import network_util
@@ -101,6 +102,11 @@ def serve_daemon(ctx, runnables=[], **kwds):
101102
config.cleanup()
102103

103104

105+
def sleep_for_serve():
106+
# This is bad, do something better...
107+
time.sleep(1000000)
108+
109+
104110
__all__ = (
105111
"serve",
106112
"serve_daemon",

planemo/galaxy/workflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def import_workflow(path, admin_gi, user_gi, from_path=False):
6161
return importer.import_workflow(workflow)
6262
else:
6363
# TODO: Update bioblend to allow from_path.
64+
path = os.path.abspath(path)
6465
payload = dict(
6566
from_path=path
6667
)

0 commit comments

Comments
 (0)