From 44b0b1ca4d8fe0404da33afb2401275c2ffff3dd Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Thu, 2 Sep 2010 10:22:51 -0400 Subject: [PATCH] New config option to prevent Galaxy from retrying set_meta internally if it fails externally, and accompanying code to allow users to retry set_meta upon failure. --- lib/galaxy/config.py | 1 + lib/galaxy/jobs/__init__.py | 7 +++++-- lib/galaxy/model/__init__.py | 3 ++- lib/galaxy/tools/__init__.py | 5 +++++ lib/galaxy/web/controllers/root.py | 3 +++ static/june_2007_style/blue/history.css | 2 ++ static/june_2007_style/history.css.tmpl | 4 +++- templates/dataset/edit_attributes.mako | 4 +++- templates/mobile/history/detail.mako | 5 ++++- templates/root/history.mako | 2 +- templates/root/history_common.mako | 7 ++++++- universe_wsgi.ini.sample | 7 +++++++ 12 files changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index 509b1ae468c..5cd7abd4184 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -53,6 +53,7 @@ class Configuration( object ): self.tool_secret = kwargs.get( "tool_secret", "" ) self.id_secret = kwargs.get( "id_secret", "USING THE DEFAULT IS NOT SECURE!" ) self.set_metadata_externally = string_as_bool( kwargs.get( "set_metadata_externally", "False" ) ) + self.retry_metadata_internally = string_as_bool( kwargs.get( "retry_metadata_internally", "True" ) ) self.use_remote_user = string_as_bool( kwargs.get( "use_remote_user", "False" ) ) self.remote_user_maildomain = kwargs.get( "remote_user_maildomain", None ) self.remote_user_logout_href = kwargs.get( "remote_user_logout_href", None ) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 39796939c5a..65a14991845 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -492,9 +492,12 @@ class JobWrapper( object ): #either use the metadata from originating output dataset, or call set_meta on the copies #it would be quicker to just copy the metadata from the originating output dataset, #but somewhat trickier (need to recurse up the copied_from tree), for now we'll call set_meta() - if not self.external_output_metadata.external_metadata_set_successfully( dataset, self.sa_session ): - # Only set metadata values if they are missing... + if not self.app.config.set_metadata_externally or \ + ( not self.external_output_metadata.external_metadata_set_successfully( dataset, self.sa_session ) \ + and self.app.config.retry_metadata_internally ): dataset.set_meta( overwrite = False ) + elif not self.external_output_metadata.external_metadata_set_successfully( dataset, self.sa_session ) and not context['stderr']: + dataset._state = model.Dataset.states.FAILED_METADATA else: #load metadata from file #we need to no longer allow metadata to be edited while the job is still running, diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 3bf8e27d0b8..966dee330fd 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -402,7 +402,8 @@ class Dataset( object ): EMPTY = 'empty', ERROR = 'error', DISCARDED = 'discarded', - SETTING_METADATA = 'setting_metadata' ) + SETTING_METADATA = 'setting_metadata', + FAILED_METADATA = 'failed_metadata' ) permitted_actions = get_permitted_actions( filter='DATASET' ) file_path = "/tmp/" engine = None diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index dad82d8d640..05c3900e56e 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1708,6 +1708,11 @@ class SetMetadataTool( Tool ): external_metadata = galaxy.datatypes.metadata.JobExternalOutputMetadataWrapper( job ) if external_metadata.external_metadata_set_successfully( dataset, app.model.context ): dataset.metadata.from_JSON_dict( external_metadata.get_output_filenames_by_dataset( dataset, app.model.context ).filename_out ) + else: + dataset._state = model.Dataset.states.FAILED_METADATA + self.sa_session.add( dataset ) + self.sa_session.flush() + return # If setting external metadata has failed, how can we inform the user? # For now, we'll leave the default metadata and set the state back to its original. dataset.datatype.after_setting_metadata( dataset ) diff --git a/lib/galaxy/web/controllers/root.py b/lib/galaxy/web/controllers/root.py index 393e1e3209f..0ac059917bf 100644 --- a/lib/galaxy/web/controllers/root.py +++ b/lib/galaxy/web/controllers/root.py @@ -335,6 +335,9 @@ class RootController( BaseController, UsesHistory, UsesAnnotations ): if params.annotation: annotation = sanitize_html( params.annotation, 'utf-8', 'text/html' ) self.add_item_annotation( trans, data, annotation ) + # If setting metadata previously failed and all required elements have now been set, clear the failed state. + if data._state == trans.model.Dataset.states.FAILED_METADATA and not data.missing_meta(): + data._state = None trans.sa_session.flush() return trans.show_ok_message( "Attributes updated%s" % message, refresh_frames=['history'] ) else: diff --git a/static/june_2007_style/blue/history.css b/static/june_2007_style/blue/history.css index 03046df84ac..ea6906311f8 100644 --- a/static/june_2007_style/blue/history.css +++ b/static/june_2007_style/blue/history.css @@ -7,6 +7,8 @@ div.historyItem .historyItemTitle{font-weight:bold;line-height:16px;} div.historyItem div.historyItem{margin-right:-11px;} div.historyItem-ok{border-color:#66AA66;background:#CCFFCC;} div.historyItem-ok .state-icon{display:none;} +div.historyItem-failed_metadata{border-color:#66AA66;background:#CCFFCC;} +div.historyItem-failed_metadata .state-icon{display:none;} div.historyItem-error{border-color:#AA6666;background:#FFCCCC;} div.historyItem-error .state-icon{background:url(history-states.png) no-repeat 0px -0px;} div.historyItem-empty{border-color:#AA6666;background:#FFCCCC;} diff --git a/static/june_2007_style/history.css.tmpl b/static/june_2007_style/history.css.tmpl index 8a24e9d7bf9..5b429c3c4c6 100644 --- a/static/june_2007_style/history.css.tmpl +++ b/static/june_2007_style/history.css.tmpl @@ -46,13 +46,15 @@ div.historyItem div.historyItem { } ## Change background/border color depending on state -div.historyItem-ok { +div.historyItem-ok, +div.historyItem-failed_metadata { border-color: $history_ok_border; background: $history_ok_bg; .state-icon { display: none; } } + div.historyItem-error { border-color: $history_error_border; background: $history_error_bg; diff --git a/templates/dataset/edit_attributes.mako b/templates/dataset/edit_attributes.mako index 0db0d0a009d..22d9e9e3f49 100644 --- a/templates/dataset/edit_attributes.mako +++ b/templates/dataset/edit_attributes.mako @@ -92,7 +92,9 @@ %if data.missing_meta(): -
${_('Required metadata values are missing. Some of these values may not be editable by the user. Selecting "Auto-detect" will attempt to fix these values.')}
+
+
${_('Required metadata values are missing. Some of these values may not be editable by the user. Selecting "Auto-detect" will attempt to fix these values.')}
+
%endif diff --git a/templates/mobile/history/detail.mako b/templates/mobile/history/detail.mako index d3e1292ad2c..caaf850c6d0 100644 --- a/templates/mobile/history/detail.mako +++ b/templates/mobile/history/detail.mako @@ -55,8 +55,11 @@
Metadata is being Auto-Detected.
%elif data_state == "empty":
No data: ${data.display_info()}
- %elif data_state == "ok": + %elif data_state in [ "ok", "failed_metadata" ]:
+ %if data_state == "failed_metadata": + Warning: setting metadata failed, + %endif ${data.blurb}, format: ${data.ext}, database: ${data.dbkey} diff --git a/templates/root/history.mako b/templates/root/history.mako index 33d4df7b867..a8f91225f99 100644 --- a/templates/root/history.mako +++ b/templates/root/history.mako @@ -19,7 +19,7 @@ ${h.js( "jquery", "jquery.tipsy", "galaxy.base", "json2", "class", "jquery.jstor