mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #7018 from qiagu/join1
Add datatype sniff button to edit dataset attributes page
This commit is contained in:
@@ -179,6 +179,14 @@ var View = Backbone.View.extend({
|
||||
onclick: function() {
|
||||
self._submit("datatype", form);
|
||||
}
|
||||
}),
|
||||
submit_datatype_detect: new Ui.Button({
|
||||
tooltip: _l("Detect the datatype and change it."),
|
||||
title: _l("Detect datatype"),
|
||||
icon: "fa-undo",
|
||||
onclick: function() {
|
||||
self._submit("datatype_detect", form);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ from galaxy import (
|
||||
util,
|
||||
web
|
||||
)
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy.datatypes.display_applications.util import decode_dataset_user, encode_dataset_user
|
||||
from galaxy.exceptions import RequestParameterInvalidException
|
||||
from galaxy.model.item_attrs import UsesAnnotations, UsesItemRatings
|
||||
@@ -25,6 +26,7 @@ from galaxy.util import (
|
||||
sanitize_text,
|
||||
smart_str
|
||||
)
|
||||
from galaxy.util.checkers import check_binary
|
||||
from galaxy.util.sanitize_html import sanitize_html
|
||||
from galaxy.web import form_builder
|
||||
from galaxy.web.base.controller import BaseUIController, ERROR, SUCCESS, url_for, UsesExtendedMetadataMixin
|
||||
@@ -459,6 +461,24 @@ class DatasetInterface(BaseUIController, UsesAnnotations, UsesItemRatings, UsesE
|
||||
message = 'Changed the type to %s.' % datatype
|
||||
else:
|
||||
return self.message_exception(trans, 'You are unable to change datatypes in this manner. Changing %s to %s is not allowed.' % (data.extension, datatype))
|
||||
elif operation == 'datatype_detect':
|
||||
# The user clicked the 'Detect datatype' button on the 'Change data type' form
|
||||
if data.datatype.allow_datatype_change:
|
||||
# prevent modifying datatype when dataset is queued or running as input/output
|
||||
if not __ok_to_edit_metadata(data.id):
|
||||
return self.message_exception(trans, 'This dataset is currently being used as input or output. You cannot change datatype until the jobs have completed or you have canceled them.')
|
||||
else:
|
||||
path = data.dataset.file_name
|
||||
is_binary = check_binary(path)
|
||||
datatype = sniff.guess_ext(path, trans.app.datatypes_registry.sniff_order, is_binary=is_binary)
|
||||
trans.app.datatypes_registry.change_datatype(data, datatype)
|
||||
trans.sa_session.flush()
|
||||
trans.app.datatypes_registry.set_external_metadata_tool.tool_action.execute(
|
||||
trans.app.datatypes_registry.set_external_metadata_tool, trans, incoming={'input1': data},
|
||||
overwrite=False) # overwrite is False as per existing behavior
|
||||
message = 'Detection was finished and changed the datatype to %s.' % datatype
|
||||
else:
|
||||
return self.message_exception(trans, 'Changing datatype "%s" is not allowed.' % (data.extension))
|
||||
elif operation == 'autodetect':
|
||||
# The user clicked the Auto-detect button on the 'Edit Attributes' form
|
||||
# prevent modifying metadata when dataset is queued or running as input/output
|
||||
|
||||
Reference in New Issue
Block a user