# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Nate Coraor <nate@bx.psu.edu> # Date 1283437371 14400 # Node ID 04c59f0a5202a89731f76b33525a4e753e0cfa42 # Parent a37dacb261540967fb21a2f5fe928464346a897a 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. --- a/templates/dataset/edit_attributes.mako +++ b/templates/dataset/edit_attributes.mako @@ -92,7 +92,9 @@ </div></form> %if data.missing_meta(): - <div class="errormessagesmall">${_('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.')}</div> + <div class="form-row"> + <div class="errormessagesmall">${_('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.')}</div> + </div> %endif </div></div> --- a/templates/mobile/history/detail.mako +++ b/templates/mobile/history/detail.mako @@ -55,8 +55,11 @@ <div>Metadata is being Auto-Detected.</div> %elif data_state == "empty": <div>No data: <i>${data.display_info()}</i></div> - %elif data_state == "ok": + %elif data_state in [ "ok", "failed_metadata" ]: <div> + %if data_state == "failed_metadata": + Warning: setting metadata failed, + %endif ${data.blurb}, format: <span class="${data.ext}">${data.ext}</span>, database: <span class="${data.dbkey}">${data.dbkey}</span> --- 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, --- 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 --- a/static/june_2007_style/blue/history.css +++ b/static/june_2007_style/blue/history.css @@ -7,6 +7,8 @@ div.historyItem .historyItemTitle{font-w 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;} --- 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 ) --- a/templates/root/history.mako +++ b/templates/root/history.mako @@ -19,7 +19,7 @@ <script type="text/javascript"> -<% TERMINAL_STATES = ["ok", "error", "empty", "deleted", "discarded"] %> +<% TERMINAL_STATES = ["ok", "error", "empty", "deleted", "discarded", "failed_metadata"] %> TERMINAL_STATES = ${ h.to_json_string(TERMINAL_STATES) }; $(function() { --- a/lib/galaxy/web/controllers/root.py +++ b/lib/galaxy/web/controllers/root.py @@ -335,6 +335,9 @@ class RootController( BaseController, Us 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: --- 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; --- a/templates/root/history_common.mako +++ b/templates/root/history_common.mako @@ -100,7 +100,12 @@ <div>${_('Metadata is being Auto-Detected.')}</div> %elif data_state == "empty": <div>${_('No data: ')}<i>${data.display_info()}</i></div> - %elif data_state == "ok": + %elif data_state in [ "ok", "failed_metadata" ]: + %if data_state == "failed_metadata": + <div class="warningmessagesmall" style="margin: 4px 0 4px 0"> + An error occurred setting the metadata for this dataset. You may be able to <a href="${h.url_for( controller='root', action='edit', id=data.id )}" target="galaxy_main">set it manually or retry auto-detection</a>. + </div> + %endif <div> ${data.blurb}, format: <span class="${data.ext}">${data.ext}</span>, --- 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 ) --- a/universe_wsgi.ini.sample +++ b/universe_wsgi.ini.sample @@ -346,6 +346,13 @@ use_interactive = True # unresponsive when this operation occurs internally. #set_metadata_externally = False +# Although it is fairly reliable, setting metadata can occasionally fail. In +# these instances, you can choose to retry setting it internally or leave it in +# a failed state (since retrying internally may cause the Galaxy process to be +# unresponsive). If this option is set to False, the user will be given the +# option to retry externally, or set metadata manually (when possible). +#retry_metadata_internally = True + # Number of concurrent jobs to run (local job runner) #local_job_queue_workers = 5