Skip to content

Commit

Permalink
Fix pydantic BaseModel conflict
Browse files Browse the repository at this point in the history
Fixes `E   NameError: Field name "fields" shadows a BaseModel attribute; use a different field name with "alias='fields'".
`
  • Loading branch information
mvdbeek authored and nsoranzo committed Nov 12, 2021
1 parent 5ae2514 commit 10f45ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/model/dataset_collections/types/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_elements(self, elements, **kwds):

def prototype_elements(self, fields=None, **kwds):
if fields is None:
raise RequestParameterMissingException("Missing or null parameter fields required for record types.")
raise RequestParameterMissingException("Missing or null parameter 'fields' required for record types.")
for field in fields:
name = field.get("name", None)
assert name
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,10 @@ class CreateNewCollectionPayload(Model):
default=None,
description="The ID of the history that will contain the collection. Required if `instance_type=library`.",
)
fields: Optional[Union[str, List[Dict['str', 'str']]]] = Field(
fields_: Optional[Union[str, List[Dict['str', 'str']]]] = Field(
default=[],
description="List of fields to create for this collection. Set to 'auto' to guess fields from identifiers."
description="List of fields to create for this collection. Set to 'auto' to guess fields from identifiers.",
alias="fields",
)


Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/services/dataset_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def create(self, trans: ProvidesHistoryContext, payload: CreateNewCollectionPayl
:returns: element view of new dataset collection
"""
# TODO: Error handling...
create_params = api_payload_to_create_params(payload.dict(exclude_unset=True))
create_params = api_payload_to_create_params(payload.dict(exclude_unset=True, by_alias=True))
if payload.instance_type == DatasetCollectionInstanceType.history:
if payload.history_id is None:
raise exceptions.RequestParameterInvalidException("Parameter history_id is required.")
Expand Down

0 comments on commit 10f45ca

Please sign in to comment.