techmatters / soil-id-algorithm

GNU Affero General Public License v3.0
1 stars 0 forks source link

rank soils crashes at -82.57032,35.62864 #135

Closed paulschreiber closed 1 month ago

paulschreiber commented 2 months ago

Description

rank soils crashes at -82.57032,35.62864.

It fails in this block of code:

        # -------------------------------------------------------------------------------------------
        # Load in component data from soilIDList
>       soilIDRank_output_pd = pd.read_csv(io.StringIO(list_output_data.rank_data_csv))
E       AttributeError: 'str' object has no attribute 'rank_data_csv'

list_output_data is "Soil ID not available in this area" (and not a CSV).

You can detect the condition like so:

    if (isinstance(list_output_data, soil_id.us_soil.SoilListOutputData)):
        soilIDRank_output_pd = pd.read_csv(io.StringIO(list_output_data.rank_data_csv))
        mucompdata_pd = pd.read_csv(io.StringIO(list_output_data.map_unit_component_data_csv))
    else:
       # do something
shrouxm commented 2 months ago

i can't reproduce this, if i query staging backend for that lat/lon i get data back. see e.g. this CURL snippet:

curl --request POST \
  --url https://api.staging.terraso.net/graphql/ \
  --header 'Content-Type: application/json' \
  --data '{"query":"query soilId($latitude: Float!, $longitude: Float!, $data: SoilIdInputData!) {\n\tsoilId {\n\t\tdataBasedSoilMatches(\n\t\t\tlatitude: $latitude\n\t\t\tlongitude: $longitude\n\t\t\tdata: $data\n\t\t) {\n\t\t\t... on DataBasedSoilMatches { matches {\n\t\t\t\tlocationMatch {\n\t\t\t\t\tscore\n\t\t\t\t\trank\n\t\t\t\t}\n\t\t\t\tdataMatch {\n\t\t\t\t\tscore\n\t\t\t\t\trank\n\t\t\t\t}\n\t\t\t\tcombinedMatch {\n\t\t\t\t\tscore\n\t\t\t\t\trank\n\t\t\t\t}\n\t\t\t\tsoilInfo {\n\t\t\t\t\tsoilSeries {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}}\n\t}\n}\n","operationName":"soilId","variables":{"latitude":35.62864,"longitude":-82.57032,"data":{"depthDependentData":[]}}}'
paulschreiber commented 2 months ago

Can you reproduce it if you add these coordinates to test_locations and run make test?

shrouxm commented 2 months ago

@paulschreiber no, i can't reproduce that way either!

jjmaynard commented 2 months ago

I can't reproduce this either. However, if list_output_data is "Soil ID not available in this area" (and not a CSV), you won't be able to run the rank_soil function. And practically this shouldn't happen in the app. The rank_soil function is only called when a user enters data and wants to compare it the soil data mapped at their location. If there is no data initially returned then the app shouldn't call the rank_soil function.

DerekCaelin commented 1 month ago

@paulschreiber how do you want to handle this issue.

DerekCaelin commented 1 month ago

@paulschreiber will test again to see if it reproduces.

paulschreiber commented 1 month ago

This is no longer crashing for me. Closing.