galaxyproject / galaxy

Data intensive science for everyone.
https://galaxyproject.org
Other
1.35k stars 978 forks source link

master API key does not allow workflow import #6699

Open fbartusch opened 5 years ago

fbartusch commented 5 years ago

Short Version: I want to automatically import Galaxy workflows and their tools into an containerized Galaxy instance. I use bioblend to import the workflow in a running bgruening/galaxy-stable:18.05 docker container using the default Master API Key of the Galaxy instance in that container. The import does not work, because Galaxy cannot assign a user to the API Key and therefore to the workflow.

Long Version to reproduce the error: Used Softare/Workflow Galaxy: Galaxy 18.05 (obtained via docker pull bgruening/galaxy-stable:18.05) bioblend 0.11.0 Docker: Docker version 18.03.1-ce, build 9ee9f40 Python 2.7.13 Workflow: https://gist.github.com/fbartusch/11ec46111f5470c504dc50965e1309b9#file-gistfile1-txt

Code to import Workflow, executed in ipython shell:

client = docker.from_env()
client.images.pull('bgruening/galaxy-stable:18.05')
client.containers.run("bgruening/galaxy-stable:18.05", detach=True, ports={'80/tcp': 8080, '21/tcp': 8021, '22/tcp': 8022}
instance = GalaxyInstance(url='127.0.0.1:8080', key='83D4jaba7330aDKHkakjGa937')
workflow_client = WorkflowClient(instance)
wf_file = "Galaxy-Workflow-galaxy101.ga"
with open(wf_file) as wf_file_handler:
    wf_description = json.load(wf_file_handler)
workflow_client.import_workflow_json(wf_description)

Bioblend Error Message:

ConnectionError                           Traceback (most recent call last)
<ipython-input-12-11f9600b0413> in <module>()
----> 1 workflow_client.import_workflow_json(wf_description)

/home/centos/miniconda3/envs/test/lib/python2.7/site-packages/bioblend/galaxy/workflows/__init__.pyc in import_workflow_json(self, workflow_json)
    115         :param workflow_json: dictionary representing the workflow to be imported
    116         """
--> 117         return self.import_workflow_dict(workflow_json)
    118
    119     def import_workflow_from_local_path(self, file_local_path, publish=False):

/home/centos/miniconda3/envs/test/lib/python2.7/site-packages/bioblend/galaxy/workflows/__init__.pyc in import_workflow_dict(self, workflow_dict, publish)
    105         url = self.gi._make_url(self)
    106         url = _join(url, "upload")
--> 107         return self._post(url=url, payload=payload)
    108
    109     def import_workflow_json(self, workflow_json):

/home/centos/miniconda3/envs/test/lib/python2.7/site-packages/bioblend/galaxy/client.pyc in _post(self, payload, id, deleted, contents, url, files_attached)
    150                                     contents=contents)
    151         return self.gi.make_post_request(url, payload=payload,
--> 152                                          files_attached=files_attached)
    153
    154     def _put(self, payload, id=None, url=None, params=None):

/home/centos/miniconda3/envs/galaxy2singularity/lib/python2.7/site-packages/bioblend/galaxyclient.pyc in make_post_request(self, url, payload, params, files_attached)
    144         # @see self.body for HTTP response body
    145         raise ConnectionError("Unexpected HTTP status code: %s" % r.status_code,
--> 146                               body=r.text, status_code=r.status_code)
    147
    148     def make_delete_request(self, url, payload=None, params=None):

ConnectionError: Unexpected HTTP status code: 500: {"err_msg": "Uncaught exception in exposed API method:", "err_code": 0}

Log of Galaxy:

galaxy.web.framework.decorators ERROR 2018-09-12 11:49:17,831 [p:447,w:2,m:0] [uWSGIWorker2Core3] Uncaught exception in exposed API method:
Traceback (most recent call last):
  File "lib/galaxy/web/framework/decorators.py", line 281, in decorator
    rval = func(self, trans, *args, **kwargs)
  File "lib/galaxy/webapps/galaxy/api/workflows.py", line 452, in import_new_workflow_deprecated
    return self.__api_import_new_workflow(trans, payload, **kwd)
  File "lib/galaxy/webapps/galaxy/api/workflows.py", line 589, in __api_import_new_workflow
    workflow, missing_tool_tups = self._workflow_from_dict(trans, data, **from_dict_kwds)
  File "lib/galaxy/web/base/controller.py", line 1252, in _workflow_from_dict
    exact_tools=exact_tools,
  File "lib/galaxy/managers/workflows.py", line 266, in build_workflow_from_dict
    trans.sa_session.flush()
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2380, in _flush
    transaction.rollback(_capture_exception=True)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2344, in _flush
    flush_context.execute()
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
    execute(statement, params)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/galaxy_venv/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
IntegrityError: (psycopg2.IntegrityError) null value in column "user_id" violates not-null constraint
DETAIL:  Failing row contains (1, 2018-09-12 11:49:17.8249, 2018-09-12 11:49:17.82491, null, null, Galaxy101, f, f, null, f).
nsoranzo commented 5 years ago

xref. https://github.com/galaxyproject/galaxy/issues/5898