Question: Question: Bioblend - upload_file does not work from command line ?
1
gravatar for lindfors.erno
3.3 years ago by
Germany
lindfors.erno30 wrote:

Hi all,

I have been trying to run Galaxy from command line via BioBlend by following an example given in Running Galaxy From Command Line With Bioblend.

I have not managed to upload a file from my local computer.

More specifically, I am trying to upload a simple flat file that contains one column of integer numbers. The exact content of this file is copy-pasted in the end of this message.

I am using the following commands for uploading.
from bioblend.galaxy import GalaxyInstance
from bioblend.galaxy.histories import HistoryClient
from bioblend.galaxy.tools import ToolClient
galaxyInstance = GalaxyInstance(url = GALAXY_URL, key=API_KEY)
historyClient = HistoryClient(galaxyInstance)
toolClient = ToolClient(galaxyInstance)
history = historyClient.create_history('tmp')
inputFile = toolClient.upload_file(LOCAL_FILE_PATH, history['id'], type='txt')

Then the content of inputFile is the following.
>>> inputFile
{u'outputs': [{u'visible': True, u'file_size': 0, u'file_ext': u'auto', u'id': u
'6b7e7ce7e274628f', u'misc_info': None, u'hda_ldda': u'hda', u'state': u'queued'
, u'metadata_dbkey': u'?', u'misc_blurb': None, u'peek': u'<table cellspacing="0
" cellpadding="3"></table>', u'update_time': u'2014-10-02T08:20:48.026438', u'da
ta_type': u'auto', u'tags': [], u'deleted': False, u'history_id': u'2d9035b3fc15
2403', u'genome_build': u'?', u'hid': 1, u'metadata_data_lines': None, u'uuid':
None, u'name': u'BigFile_test.txt', u'model_class': u'HistoryDatasetAssociation'
, u'output_name': u'output0', u'purged': False}]}

From what I understand u'file_size': 0 means that the size of uploaded file is zero. In practice, I think it means the uploading operation failed to upload any content to the inputFile variable.

Does anybody have any idea why this happens? 

With best regards,
Erno Lindfors

<FileContent>
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
</FileContent>

bioblend software error galaxy • 1.1k views
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by lindfors.erno30
2
gravatar for jmchilton
3.3 years ago by
jmchilton1.0k
United States
jmchilton1.0k wrote:
>>> from bioblend.galaxy import GalaxyInstance
>>> from bioblend.galaxy.histories import HistoryClient
>>> from bioblend.galaxy.tools import ToolClient
>>> galaxyInstance = GalaxyInstance(url = "localhost:8080", key="9dd451f888265a341fc1002639287b90")
>>> historyClient = HistoryClient(galaxyInstance)
>>> toolClient = ToolClient(galaxyInstance)
>>> history = historyClient.create_history('tmp')
>>> open("foo.txt", "w").write("1\n2\n3\n4\n5\n")
>>> inputFile = toolClient.upload_file("foo.txt", history['id'], type='txt')
>>> inputFile
{u'outputs': [{u'visible': True, u'file_size': 0, u'file_ext': u'auto', u'id': u'b701da857886499b', u'misc_info': None, u'hda_ldda': u'hda', u'state': u'queued', u'misc_blurb': None, u'peek': u'<table cellspacing="0" cellpadding="3"></table>', u'update_time': u'2014-10-06T17:45:13.714530', u'data_type': u'galaxy.datatypes.data.Text', u'tags': [], u'deleted': False, u'history_id': u'82b264d8c3d11790', u'genome_build': u'?', u'hid': 1, u'metadata_data_lines': None, u'metadata_dbkey': u'?', u'history_content_type': u'dataset', u'name': u'foo.txt', u'uuid': u'662f9004-7117-4bab-8e64-db66ef633840', u'model_class': u'HistoryDatasetAssociation', u'output_name': u'output0', u'purged': False}], u'implicit_collections': [], u'jobs': [{u'tool_id': u'upload1', u'update_time': u'2014-10-06T17:45:13.881153', u'exit_code': None, u'state': u'new', u'create_time': u'2014-10-06T17:45:13.775743', u'model_class': u'Job', u'id': u'86cf1d3beeec9f1c'}]}

I get the same output more or less but I do have a new history with the correct dataset populated and green. Galaxy doesn't know when the request is finished what the final dataset will look like - that is why file size is 0 and file_ext is listed as 'auto' even though you specified one. Galaxy creates an actual job for each upload. When I consume the API I just poll the history for the its state to no longer be active and then check the history contents API with the ID returned here (in my example that would be u'b701da857886499b'.

Can you try opening Galaxy and looking at the history and see if the dataset is created? If it is not I would imagine there is some error in the logs that will help diagnose the problem.

ADD COMMENTlink written 3.3 years ago by jmchilton1.0k
0
gravatar for lindfors.erno
3.3 years ago by
Germany
lindfors.erno30 wrote:

Thanks for the reponse!
I checked the dataset is indeed created in the history.

ADD COMMENTlink written 3.3 years ago by lindfors.erno30
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 53 users visited in the last hour