Skip to content

Commit

Permalink
Fix job summary for optional unset job data inputs
Browse files Browse the repository at this point in the history
Fixes https://sentry.galaxyproject.org/share/issue/31c83cea41a94a7c9c367a66d89fae37/:
```
AttributeError: 'NoneType' object has no attribute 'id'
  File "starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "starlette_context/middleware/raw_middleware.py", line 92, in __call__
    await self.app(scope, receive, send_wrapper)
  File "starlette/middleware/base.py", line 189, in __call__
    with collapse_excgroups():
  File "contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "starlette/_utils.py", line 93, in collapse_excgroups
    raise exc
  File "starlette/middleware/base.py", line 191, in __call__
    response = await self.dispatch_func(request, call_next)
  File "galaxy/webapps/galaxy/fast_app.py", line 109, in add_x_frame_options
    response = await call_next(request)
  File "starlette/middleware/base.py", line 165, in call_next
    raise app_exc
  File "starlette/middleware/base.py", line 151, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "starlette/routing.py", line 72, in app
    response = await func(request)
  File "fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "fastapi/routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "starlette/concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "anyio/_backends/_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "galaxy/webapps/galaxy/api/jobs.py", line 410, in parameters_display_by_dataset
    return summarize_job_parameters(trans, job)
  File "galaxy/managers/jobs.py", line 1055, in summarize_job_parameters
    parameters = inputs_recursive(tool.inputs, params_objects, depth=1, upgrade_messages=upgrade_messages)
  File "galaxy/managers/jobs.py", line 994, in inputs_recursive
    element_id = element.id
```
which you can reproduce by connecting an optional dataset and a required
dataset to a multiple="true" data parameter and then looking at the tool
input parameters.
  • Loading branch information
mvdbeek committed Aug 30, 2024
1 parent b10e8f8 commit 48ed951
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9132,7 +9132,7 @@ export interface components {
* @description The values of the job parameter
*/
value?:
| components["schemas"]["EncodedJobParameterHistoryItem"][]
| (components["schemas"]["EncodedJobParameterHistoryItem"] | null)[]
| number
| number
| boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<div>
<div v-for="(elVal, pvIndex) in parameter_value" :key="pvIndex">
<span v-if="elVal === null">No input provided</span>
<GenericHistoryItem
v-if="['hda', 'hdca', 'dce'].includes(elVal.src)"
v-else-if="['hda', 'hdca', 'dce'].includes(elVal.src)"
:item-id="elVal.id"
:item-src="elVal.src" />
<span v-else> {{ elVal.hid }}: {{ elVal.name }} </span>
Expand Down
9 changes: 5 additions & 4 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,14 +991,15 @@ def inputs_recursive(input_params, param_values, depth=1, upgrade_messages=None)
):
value = []
for element in listify(input_value):
element_id = element.id
if isinstance(element, model.HistoryDatasetAssociation):
hda = element
value.append({"src": "hda", "id": element_id, "hid": hda.hid, "name": hda.name})
value.append({"src": "hda", "id": element.id, "hid": hda.hid, "name": hda.name})
elif isinstance(element, model.DatasetCollectionElement):
value.append({"src": "dce", "id": element_id, "name": element.element_identifier})
value.append({"src": "dce", "id": element.id, "name": element.element_identifier})
elif isinstance(element, model.HistoryDatasetCollectionAssociation):
value.append({"src": "hdca", "id": element_id, "hid": element.hid, "name": element.name})
value.append({"src": "hdca", "id": element.id, "hid": element.hid, "name": element.name})
elif element is None:
value.append(None)
else:
raise Exception(
f"Unhandled data input parameter type encountered {element.__class__.__name__}"
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/schema/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class JobParameter(Model):
title="Depth",
description="The depth of the job parameter.",
)
value: Optional[Union[List[EncodedJobParameterHistoryItem], float, int, bool, str]] = Field(
value: Optional[Union[List[Optional[EncodedJobParameterHistoryItem]], float, int, bool, str]] = Field(
default=None, title="Value", description="The values of the job parameter", union_mode="left_to_right"
)
notes: Optional[str] = Field(default=None, title="Notes", description="Notes associated with the job parameter.")
Expand Down

0 comments on commit 48ed951

Please sign in to comment.