From 613377e16cc80ae9c90e4e1fe340df910b870a11 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 12 Nov 2021 10:21:31 +0100 Subject: [PATCH] Fix pydantic BaseModel conflict Fixes `E NameError: Field name "fields" shadows a BaseModel attribute; use a different field name with "alias='fields'". ` --- lib/galaxy/schema/schema.py | 5 +++-- lib/galaxy/webapps/galaxy/services/dataset_collections.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/schema/schema.py b/lib/galaxy/schema/schema.py index 4d3e89d4b1d2..d121934fad25 100644 --- a/lib/galaxy/schema/schema.py +++ b/lib/galaxy/schema/schema.py @@ -998,9 +998,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", ) diff --git a/lib/galaxy/webapps/galaxy/services/dataset_collections.py b/lib/galaxy/webapps/galaxy/services/dataset_collections.py index acf07110c007..d1f0887e53de 100644 --- a/lib/galaxy/webapps/galaxy/services/dataset_collections.py +++ b/lib/galaxy/webapps/galaxy/services/dataset_collections.py @@ -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.")