EcoNet-NZ / inaturalist-to-cams

Synchronises observations from iNaturalist to the CAMS Weed App
Apache License 2.0
3 stars 3 forks source link

ValueError: 'CAMSv0.6p-FDRes' is not in list #79

Closed nigelcharman closed 3 months ago

nigelcharman commented 7 months ago

GitHub Actions fails with:

2024-02-09 17:54:02 INFO Syncing iNaturalist observation Observation(id=197415492, taxon=Taxon(id=75499, full_name=Species: Araujia sericifera (Moth Vine)), observed_on=Jan 24, 2024, user=User(id=138584, login=keiths, name=Keith S), place_guess=Birkenhead, Auckland, New Zealand)
2024-02-09 17:54:02 INFO Observed on 2024-01-24T11:11:28
2024-02-09 17:54:02 INFO Found existing CAMS feature with 1 visit rows for iNaturalist id 197415492
2024-02-09 17:54:02 INFO Reading CAMS feature where OBJECTID='[116](https://github.com/EcoNet-NZ/inaturalist-to-cams/actions/runs/7839779532/job/21393360190#step:7:117)778'
2024-02-09 17:54:02 INFO Found visit table row {"attributes": {"OBJECTID": 116778, "GUID_visits": "c5594198-38dd-434f-ba29-ed3c3a0d0059", "DateCheck": 1706047888000, "Area": null, "Height": null, "Treated": null, "HowTreated": null, "Age": null, "Flowering": null, "GlobalID": "cf937efe-cfc8-468c-8171-2c2973afd873", "UrgencyForReturnVisit": null, "Difficulty": null, "CheckedNearbyRadius": null, "VisitType": null, "HoursSpent": 0.2, "NumberOfVolunteers": null, "Sex": null, "NotesAndDetails": "contractors will be digging up bank to build retaining wall", "NbrPodsRemoved": null, "WhoVisitedName": null, "WhoVisitedEmail": null, "ProjectOrJob": null, "NextSteps": null, "NumberOfStems": null, "GUID_Preserve": null, "VisitStage": null, "CreationDate_1": 1706050451199, "Creator_1": "Inat-to-CAMS_econethub", "EditDate_1": 1706137919714, "Editor_1": "ksalmon_econet", "ReqForServiceDetails": null, "ContractorEngaged": null, "DateForReturnVisit": null, "BioControlInd": null, "WeedVisitStatus": "RedGrowth", "TreatmentSubstance": null, "TreatmentDetails": null, "iNatRef": "197415492", "PodsBurst": null, "PlantsRemainingMature": null, "PlantsRemainingImmature": null, "LocationOnProperty": null, "BasicOptionsFlag": "Basic", "HelpNeeded": null, "SeedsDispersed": null, "DifficultyChild": null, "PlantsPresentImmature": null, "PlantsPresentMature": null, "PlantsControlledImmature": null, "PlantsControlledMature": null, "iNaturalistURL": "https://www.inaturalist.org/observations/197415492", "SiteDifficulty": null, "ObservationQuality": "needs_id", "VisitDataSource": "CAMSv0.6p-FDRes", "SendEmail": null, "Visit_Date_Editor_SaveLast": "TurnedOff", "EditDate_SaveLast": null, "Editor_SaveLast": null, "Date_Editor_SaveLast": null, "CommunicationURL": null}}
2024-02-09 17:54:02 INFO Found layer row {"geometry": {"x": 174.7373499970181, "y": -36.820426154587, "spatialReference": {"wkid": 4326, "latestWkid": 4326}}, "attributes": {"OBJECTID": 66671, "DateDiscovered": 1706047888000, "GlobalID": "c5594198-38dd-434f-ba29-ed3c3a0d0059", "SpeciesDropDown": "MothPlant", "SiteSource": "CAMSv0.6p-FDRes", "Urgency": null, "LocationInfo": "Opp 35 Hinemoa -   but will be dug up when retaining wall built", "OtherWeedDetails": null, "LastSeasonStatus": null, "PropertyContactDetails": null, "GeoPrivacy": null, "ParentGuid": null, "CreationDate_1": 1706050450708, "Creator_1": "Inat-to-CAMS_econethub", "EditDate_1": 1706137965261, "Editor_1": "ksalmon_econet", "ParentStatusWithDomain": "RedGrowth", "Elevation": null, "iNatURL": "https://www.inaturalist.org/observations/197415492", "DateVisitMadeFromLastVisit": 1706047888000, "DateForNextVisitFromLastVisit": null, "LatestVisitStage": null, "LatestArea": null, "StatusDisplay": null, "StatusAt202211": null, "AddressAuto": "Autocalc turned off", "LandOwnership": null, "DedupStatus": null, "DateOfLastCreateFromLastVisit": 170605045[119](https://github.com/EcoNet-NZ/inaturalist-to-cams/actions/runs/7839779532/job/21393360190#step:7:120)9, "DateOfLastEditFromLastVisit": 1706137919714, "AddressSortKey": null, "WeedInstanceNotes": null, "UnitOwnership": null, "EditDate_SaveLast": 1706137843470, "Editor_SaveLast": "Audit Trail suspended", "EditorNames_SaveLast": "Salmon (EcoNet), Keith", "DataQualityCheck": null, "StatusAt202310": null, "UseCalcAddr": null, "Date_Editor_SaveLast": null, "UserName": "GetUser($layer).Username", "UserName2": "GetUser($layer).username", "UserEditDateTime": null, "ContactURL": null}}
Traceback (most recent call last):
  File "/home/runner/work/inaturalist-to-cams/inaturalist-to-cams/inat_to_cams/config.py", line 47, in cams_field_key
    return list(field_dict.keys())[list(field_dict.values()).index(value)]
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: 'CAMSv0.6p-FDRes' is not in list

See https://github.com/EcoNet-NZ/inaturalist-to-cams/actions/runs/7839779532/job/21393360190

nigelcharman commented 7 months ago

Resolved by adding all the SiteSource values to the ./config/cams_schema.json file.

Still need to find why it occurred and possibly ensure the configuration is kept up to date with changes to SiteSource.

The problem was caused by one of the features having an iNaturalist URL but also having a SiteSource of "CAMSv0.6p-FDRes". Is the SiteSource updated when you edit the feature? I figured it would stay constant so would always by "iNaturalist" for observations we synced.

If we are updating the SiteSource when changes are made, we'll need to either loosen up our checking, or make sure we add new values to our configuration when they are added to CAMS.

nigelcharman commented 3 months ago

Modified to be a simple text field rather than a list of values in 56d6803