Jelle, I've added support for uploading image datatypes based on your patches in change set 5833:e7214c69ed7d, but with some changes. There is a new image_util.py file in ~/lib/galaxy/datatypes/util which allows for detecting image data types without having to create a new Image() class. I've also aded a couple of fixes to the code. There is currently no support in the Galaxy api for uploading files outside of a data library, so I did not have to add the new config setting discussed in the previous thread. We'll look into that further when the api is enhanced to enable uploads. Thanks very much for your contribution! Greg Von Kuster On Jul 25, 2011, at 11:23 AM, Jelle Scholtalbers wrote:
Hi Greg,
this was indeed causing the problem. I added some code which now allows to sniff image files. It is practically untested (it does work for me on bmp, jpg, png, tiff) - didn't try with PIL although the code is there. Attached are diffs against changeset 058a5d7a4f84 (bit outdated - can provide newer if desired..).
Sniffed formats: http://infohost.nmt.edu/tcc/help/pubs/pil/formats.html or http://docs.python.org/library/imghdr.html depending if PIL is available or not.
Cheers, Jelle
On Fri, Jul 22, 2011 at 6:46 PM, Greg Von Kuster <greg@bx.psu.edu> wrote: Based on the error message you gave, I assume the following code in ~/lib/galaxy/datatypes/sniff.py is presenting the problem.
if check_binary( filename ): if ext not in unsniffable_binary_formats and not datatypes_registry.get_datatype_by_extension( ext ).sniff( filename ): raise InappropriateDatasetContentError, 'The binary uploaded file contains inappropriate content.'
Have you tried adding your 'jpg' extension to the following in ~/lib/galaxy/datatypes/binary.py?
# Currently these supported binary data types must be manually set on upload unsniffable_binary_formats = [ 'ab1', 'scf' ]
On Jul 22, 2011, at 11:52 AM, Jelle Scholtalbers wrote:
Hi Greg,
I used that link when trying to create the support. The jpg datatype was already present in the datatypes_conf.xml (
<datatype extension="jpg" type="galaxy.datatypes.images:Image" mimetype="image/jpeg"/> ) , so I first made it available at upload -> display_in_upload=True. As far as I understood, if galaxy doesn't have to guess what the format is, this would be sufficient? From step2:
"Galaxy tools are configured to automatically set the data type of an output dataset. However, in some scenarios, Galaxy will attempt to determine the data type of a file using a sniffer"
However manually setting the format on upload still gave the mentioned error. Therefore I followed the rest of the guide (adding a sniffer) but still seem to fail here..
Cheers, Jelle
On Jul 22, 2011 3:26 PM, "Greg Von Kuster" <greg@bx.psu.edu> wrote:
Hello Jelle,
There are a few things you need to do to add support for a new data type. The steps are described here:
http://wiki.g2.bx.psu.edu/Admin/Datatypes/Adding%20Datatypes
Greg Von Kuster
On Jul 22, 2011, at 8:49 AM, Jelle Scholtalbers wrote:
Hi all,
I would like to be able to upload images to my Galaxy instance - in particular jpg/png to data libraries. I can't however find out how to overcome the problem of inappropriate content in binary file. How to go about?
When I create a sniffer class in the galaxy.datatypes.images.py that always returns true (for testing purposes) I still don't get the jpg uploaded without an error (sniffer is incl. in the datatypes_conf.xml ). class Jpg( Image ): file_ext = "jpg" def sniff(self, filename): """Determine if the file is in jpg format. """ return True
It seems I'm missing something obvious and could use some help.
Cheers, Jelle ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at:
Greg Von Kuster Galaxy Development Team greg@bx.psu.edu
Greg Von Kuster Galaxy Development Team greg@bx.psu.edu
<datatypes_conf.xml.diff><images.py.diff><upload.py.diff>
Greg Von Kuster Galaxy Development Team greg@bx.psu.edu