Skip to content

Commit

Permalink
Allow import format2 workflows by default.
Browse files Browse the repository at this point in the history
Setup forcing export of format2 workflows by default in next release. There should be a least one release between enabling them to be imported by default and exporting them by default anyway I think - so 19.09 workflows can still be used on slightly older Galaxy instances.
  • Loading branch information
jmchilton committed Apr 4, 2019
1 parent ded4764 commit 4b13917
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 21 deletions.
6 changes: 4 additions & 2 deletions config/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,10 @@ galaxy:
# of Galaxy's stable API.
#enable_beta_workflow_modules: false

# Enable import and export of workflows as Galaxy Format 2 workflows.
#enable_beta_workflow_format: false
# Export of workflows as Galaxy Format 2 instead of GA workflows by
# default. The default value of this configuration variable will
# switch to True in 19.09.
#enable_beta_export_format2_default: false

# Following options only apply to workflows scheduled using the legacy
# workflow run API (running workflows via a POST to /api/workflows).
Expand Down
11 changes: 6 additions & 5 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2769,13 +2769,14 @@
:Type: bool


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``enable_beta_workflow_format``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``enable_beta_export_format2_default``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Description:
Enable import and export of workflows as Galaxy Format 2
workflows.
Export of workflows as Galaxy Format 2 instead of GA workflows by
default. The default value of this configuration variable will
switch to True in 19.09.
:Default: ``false``
:Type: bool

Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ def __init__(self, **kwargs):
# workflows built using these modules may not function in the
# future.
self.enable_beta_workflow_modules = string_as_bool(kwargs.get('enable_beta_workflow_modules', 'False'))
# Enable use of gxformat2 workflows.
self.enable_beta_workflow_format = string_as_bool(kwargs.get('enable_beta_workflow_format', 'False'))
# Enable default export of gxformat2 workflows.
self.enable_beta_export_format2_default = string_as_bool(kwargs.get('enable_beta_export_format2_default', 'False'))
# These are not even beta - just experiments - don't use them unless
# you want yours tools to be broken in the future.
self.enable_beta_tool_formats = string_as_bool(kwargs.get('enable_beta_tool_formats', 'False'))
Expand Down
16 changes: 10 additions & 6 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ def normalize_workflow_format(self, trans, as_dict):

workflow_class = as_dict.get("class", None)
if workflow_class == "GalaxyWorkflow" or "$graph" in as_dict or "yaml_content" in as_dict:
if not self.app.config.enable_beta_workflow_format:
raise exceptions.ConfigDoesNotAllowException("Format2 workflows not enabled.")

# Format 2 Galaxy workflow.
galaxy_interface = Format2ConverterGalaxyInterface()
import_options = ImportOptions()
Expand Down Expand Up @@ -444,15 +441,20 @@ def workflow_to_dict(self, trans, stored, style="export", version=None):
"""

def to_format_2(wf_dict, **kwds):
if not trans.app.config.enable_beta_workflow_format:
raise exceptions.ConfigDoesNotAllowException("Format2 workflows not enabled.")
return from_galaxy_native(wf_dict, None, **kwds)

if version == '':
version = None
if version is not None:
version = int(version)
workflow = stored.get_internal_version(version)
if style == "export":
# Export workflows as GA format through 19.05, in 19.09 this will become format2.
style = "ga"

if self.app.config.enable_beta_export_format2_default:
style = "format2"

if style == "editor":
wf_dict = self._workflow_to_dict_editor(trans, stored, workflow)
elif style == "legacy":
Expand All @@ -467,8 +469,10 @@ def to_format_2(wf_dict, **kwds):
elif style == "format2_wrapped_yaml":
wf_dict = self._workflow_to_dict_export(trans, stored, workflow=workflow)
wf_dict = to_format_2(wf_dict, json_wrapper=True)
else:
elif style == "ga":
wf_dict = self._workflow_to_dict_export(trans, stored, workflow=workflow)
else:
raise exceptions.RequestParameterInvalidException('Unknown workflow style [%s]' % style)
if version:
wf_dict['version'] = version
else:
Expand Down
20 changes: 18 additions & 2 deletions lib/galaxy/webapps/galaxy/api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,16 @@ def create(self, trans, payload, **kwd):
def workflow_dict(self, trans, workflow_id, **kwd):
"""
GET /api/workflows/{encoded_workflow_id}/download
Returns a selected workflow as a json dictionary.
:type style: str
:param style: Style of export. The default is 'export', which is the meant to be used
with workflow import endpoints. Other formats such as 'instance', 'editor',
'run' are more tied to the GUI and should not be considered stable APIs.
By default the 'export' format in 19.05 is "ga" files, in 19.09 this will
become 'format2'. Style can be specified as either 'ga' or 'format2' directly
to be explicit about which format to download.
"""
stored_workflow = self.__get_stored_accessible_workflow(trans, workflow_id)

Expand All @@ -431,7 +440,11 @@ def workflow_dict(self, trans, workflow_id, **kwd):
if download_format == 'json-download':
sname = stored_workflow.name
sname = ''.join(c in util.FILENAME_VALID_CHARS and c or '_' for c in sname)[0:150]
trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy-Workflow-%s.ga"' % (sname)
if ret_dict.get("format-version", None) == "0.1":
extension = "ga"
else:
extension = "gxwf.json"
trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy-Workflow-%s.%s"' % (sname, extension)
trans.response.set_content_type('application/galaxy-archive')
return ret_dict

Expand Down Expand Up @@ -588,7 +601,10 @@ def __api_import_from_archive(self, trans, archive_data, source=None):
try:
data = json.loads(archive_data)
except Exception:
raise exceptions.MessageException("The data content does not appear to be a valid workflow.")
if "GalaxyWorkflow" in archive_data:
data = {"yaml_content": archive_data}
else:
raise exceptions.MessageException("The data content does not appear to be a valid workflow.")
if not data:
raise exceptions.MessageException("The data content is missing.")
raw_workflow_description = self.__normalize_workflow(trans, data)
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/webapps/galaxy/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2058,12 +2058,13 @@ mapping:
Enable beta workflow modules that should not yet be considered part of Galaxy's
stable API.
enable_beta_workflow_format:
enable_beta_export_format2_default:
type: bool
default: false
required: false
desc: |
Enable import and export of workflows as Galaxy Format 2 workflows.
Export of workflows as Galaxy Format 2 instead of GA workflows by default. The
default value of this configuration variable will switch to True in 19.09.
force_beta_workflow_scheduled_min_steps:
type: int
Expand Down
1 change: 0 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if [ ! -z "$GALAXY_RUN_WITH_TEST_TOOLS" ];
then
export GALAXY_CONFIG_OVERRIDE_TOOL_CONFIG_FILE="test/functional/tools/samples_tool_conf.xml"
export GALAXY_CONFIG_ENABLE_BETA_WORKFLOW_MODULES="true"
export GALAXY_CONFIG_ENABLE_BETA_WORKFLOW_FORMAT="true"
export GALAXY_CONFIG_OVERRIDE_ENABLE_BETA_TOOL_FORMATS="true"
export GALAXY_CONFIG_OVERRIDE_WEBHOOKS_DIR="test/functional/webhooks"
fi
Expand Down
1 change: 0 additions & 1 deletion test/base/driver_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def setup_galaxy_config(
cleanup_job='onsuccess',
data_manager_config_file=data_manager_config_file,
enable_beta_tool_formats=True,
enable_beta_workflow_format=True,
expose_dataset_path=True,
file_path=file_path,
ftp_upload_purge=False,
Expand Down

0 comments on commit 4b13917

Please sign in to comment.