Skip to content

WB Validation exception: get() returned more than one Picklist -- it returned 2 #1064

@maxpatiiuk

Description

@maxpatiiuk

Describe the bug
An exception occurred during data set validation process.
I did not have this happen before with this data set, so it might just be a database issue

To Reproduce

  1. Upload data set
  2. Use mappings that are suggested by the automaker
  3. Try to validate the data set

Expected behavior
Validation completes

Screenshots
Screen Shot 2021-11-12 at 9 45 14 AM

Desktop (please complete the following information):

  • OS: macOS
  • Browser Google Chrome
  • Specify 7 Version: a11y branch

Additional context
Data set: test-workbench-data.csv.zip

Exception:

specify7-specify7-worker-1  | [2021-11-12 15:40:41,624: INFO/MainProcess] Received task: specifyweb.workbench.tasks.upload[7537d3a1-ef13-455d-a554-20be24a8e4fc]
specify7-specify7-worker-1  | [12/Nov/2021 15:40:43] [ERROR] [specifyweb.celery:30] Celery task failure!!!1
specify7-specify7-worker-1  | Traceback (most recent call last):
specify7-specify7-worker-1  |   File "/opt/specify7/ve/lib/python3.6/site-packages/celery/app/trace.py", line 405, in trace_task
specify7-specify7-worker-1  |     R = retval = fun(*args, **kwargs)
specify7-specify7-worker-1  |   File "/opt/specify7/ve/lib/python3.6/site-packages/celery/app/trace.py", line 697, in __protected_call__
specify7-specify7-worker-1  |     return self.run(*args, **kwargs)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/tasks.py", line 41, in upload
specify7-specify7-worker-1  |     do_upload_dataset(collection, uploading_agent_id, ds, no_commit, allow_partial, progress)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/upload.py", line 113, in do_upload_dataset
specify7-specify7-worker-1  |     base_table, upload_plan = get_ds_upload_plan(collection, ds)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/upload.py", line 160, in get_ds_upload_plan
specify7-specify7-worker-1  |     return base_table, plan.apply_scoping(collection)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/upload_table.py", line 29, in apply_scoping
specify7-specify7-worker-1  |     return apply_scoping(self, collection)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 94, in apply_scoping_to_uploadtable
specify7-specify7-worker-1  |     toMany={f: [set_order_number(i, r.apply_scoping(collection)) for i, r in enumerate(rs)] for f, rs in ut.toMany.items()},
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 94, in <dictcomp>
specify7-specify7-worker-1  |     toMany={f: [set_order_number(i, r.apply_scoping(collection)) for i, r in enumerate(rs)] for f, rs in ut.toMany.items()},
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 94, in <listcomp>
specify7-specify7-worker-1  |     toMany={f: [set_order_number(i, r.apply_scoping(collection)) for i, r in enumerate(rs)] for f, rs in ut.toMany.items()},
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/tomany.py", line 20, in apply_scoping
specify7-specify7-worker-1  |     return apply_scoping(self, collection)
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 143, in apply_scoping_to_tomanyrecord
specify7-specify7-worker-1  |     wbcols={f: extend_columnoptions(colopts, collection, table.name, f) for f, colopts in tmr.wbcols.items()},
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 143, in <dictcomp>
specify7-specify7-worker-1  |     wbcols={f: extend_columnoptions(colopts, collection, table.name, f) for f, colopts in tmr.wbcols.items()},
specify7-specify7-worker-1  |   File "/opt/specify7/specifyweb/workbench/upload/scoping.py", line 70, in extend_columnoptions
specify7-specify7-worker-1  |     picklist = picklistname and getattr(models, 'Picklist').objects.get(name=picklistname, collection=collection)
specify7-specify7-worker-1  |   File "/opt/specify7/ve/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
specify7-specify7-worker-1  |     return getattr(self.get_queryset(), name)(*args, **kwargs)
specify7-specify7-worker-1  |   File "/opt/specify7/ve/lib/python3.6/site-packages/django/db/models/query.py", line 412, in get
specify7-specify7-worker-1  |     (self.model._meta.object_name, num)
specify7-specify7-worker-1  | specifyweb.specify.models.Picklist.MultipleObjectsReturned: get() returned more than one Picklist -- it returned 2!
specify7-specify7-worker-1  | [2021-11-12 15:40:43,244: ERROR/ForkPoolWorker-1] Task specifyweb.workbench.tasks.upload[7537d3a1-ef13-455d-a554-20be24a8e4fc] raised unexpected: MultipleObjectsReturned('get() returned more than one Picklist -- it returned 2!',)
s

Upload plan:

{
  "baseTableName": "collectionobject",
  "uploadable": {
    "uploadTable": {
      "wbcols": {},
      "static": {},
      "toOne": {
        "collectingevent": {
          "uploadTable": {
            "wbcols": {
              "startdate": "Start Date Collected",
              "enddate": "End Date Collected",
              "method": "Collection Method"
            },
            "static": {},
            "toOne": {
              "locality": {
                "uploadTable": {
                  "wbcols": {
                    "minelevation": "Min Depth (M)",
                    "maxelevation": "Max Depth (M)",
                    "latitude1": "Latitude1",
                    "latitude2": "Latitude2",
                    "longitude1": "Longitude1",
                    "longitude2": "Longitude2",
                    "latlongtype": "Lat Long Type"
                  },
                  "static": {},
                  "toOne": {
                    "geography": {
                      "treeRecord": {
                        "ranks": {
                          "Country": {
                            "treeNodeCols": {
                              "name": "Country"
                            }
                          },
                          "State": {
                            "treeNodeCols": {
                              "name": "State/Prov/Pref"
                            }
                          },
                          "Continent": {
                            "treeNodeCols": {
                              "name": "Continent/Ocean"
                            }
                          }
                        }
                      }
                    }
                  },
                  "toMany": {}
                }
              }
            },
            "toMany": {
              "collectors": [
                {
                  "wbcols": {},
                  "static": {},
                  "toOne": {
                    "agent": {
                      "uploadTable": {
                        "wbcols": {
                          "title": "Collector 1 Title",
                          "firstname": "Collector 1 First Name",
                          "middleinitial": "Collector 1 Middle Initial",
                          "lastname": "Collector 1 Last Name"
                        },
                        "static": {},
                        "toOne": {},
                        "toMany": {}
                      }
                    }
                  }
                },
                {
                  "wbcols": {},
                  "static": {},
                  "toOne": {
                    "agent": {
                      "uploadTable": {
                        "wbcols": {
                          "title": "Collector 2 Title",
                          "firstname": "Collector 2 First Name",
                          "middleinitial": "Collector 2 Middle Initial",
                          "lastname": "Collector 2 Last name"
                        },
                        "static": {},
                        "toOne": {},
                        "toMany": {}
                      }
                    }
                  }
                },
                {
                  "wbcols": {},
                  "static": {},
                  "toOne": {
                    "agent": {
                      "uploadTable": {
                        "wbcols": {
                          "title": "Collector 3 Title",
                          "firstname": "Collector 3 First Name",
                          "middleinitial": "Collector 3 Middle Initial",
                          "lastname": "Collector 3 Last Name"
                        },
                        "static": {},
                        "toOne": {},
                        "toMany": {}
                      }
                    }
                  }
                },
                {
                  "wbcols": {},
                  "static": {},
                  "toOne": {
                    "agent": {
                      "uploadTable": {
                        "wbcols": {
                          "title": "Collector 4 Title",
                          "firstname": "Collector 4 First Name",
                          "middleinitial": "Collector 4 Middle Initial",
                          "lastname": "Collector 4 Last Name"
                        },
                        "static": {},
                        "toOne": {},
                        "toMany": {}
                      }
                    }
                  }
                }
              ]
            }
          }
        },
        "accession": {
          "uploadTable": {
            "wbcols": {
              "accessionnumber": "Accession No."
            },
            "static": {},
            "toOne": {},
            "toMany": {}
          }
        },
        "cataloger": {
          "uploadTable": {
            "wbcols": {
              "lastname": "Cataloged by"
            },
            "static": {},
            "toOne": {},
            "toMany": {}
          }
        }
      },
      "toMany": {
        "determinations": [
          {
            "wbcols": {
              "determineddate": "ID Date",
              "typestatusname": "ID Status"
            },
            "static": {},
            "toOne": {
              "taxon": {
                "treeRecord": {
                  "ranks": {
                    "Class": {
                      "treeNodeCols": {
                        "name": "Class"
                      }
                    },
                    "Family": {
                      "treeNodeCols": {
                        "name": "Family"
                      }
                    },
                    "Genus": {
                      "treeNodeCols": {
                        "name": "Genus"
                      }
                    },
                    "Species": {
                      "treeNodeCols": {
                        "name": "Species",
                        "author": "Species Author"
                      }
                    },
                    "Subspecies": {
                      "treeNodeCols": {
                        "name": "Subspecies",
                        "author": "Subspecies Author"
                      }
                    }
                  }
                }
              },
              "determiner": {
                "uploadTable": {
                  "wbcols": {
                    "firstname": "Who ID First Name",
                    "title": "Determiner 1 Title",
                    "middleinitial": "Determiner 1 Middle Initial",
                    "lastname": "Determiner 1 Last Name"
                  },
                  "static": {},
                  "toOne": {},
                  "toMany": {}
                }
              }
            }
          },
          {
            "wbcols": {},
            "static": {},
            "toOne": {
              "determiner": {
                "uploadTable": {
                  "wbcols": {
                    "firstname": "Determiner 1 First Name"
                  },
                  "static": {},
                  "toOne": {},
                  "toMany": {}
                }
              }
            }
          }
        ],
        "preparations": [
          {
            "wbcols": {},
            "static": {},
            "toOne": {
              "preptype": {
                "mustMatchTable": {
                  "wbcols": {
                    "name": "Prep Type 1"
                  },
                  "static": {},
                  "toOne": {},
                  "toMany": {}
                }
              }
            }
          }
        ]
      }
    }
  }
}

Metadata

Metadata

Assignees

Labels

1 - BugIncorrect behavior of the product2 - WorkBenchIssues that are related to the WorkBench

Type

No type

Projects

Status

✅ Done

Status

Shipped

Relationships

None yet

Development

No branches or pull requests

Issue actions