Giter VIP home page Giter VIP logo

Comments (6)

JWCook avatar JWCook commented on June 12, 2024

Good catch! After looking over the API docs some more, it looks like this applies to all boolean parameters. For example:

# Returns 1 result (not expected):
get_observations({'id':43039160, 'taxon_is_active': False})
# Returns 0 results (expected):
get_observations({'id':43039160, 'taxon_is_active': 'false'})

I think this would be simple enough to address by applying some more param processing in make_inaturalist_api_get_call(), for example:

def convert_bool_params(params):      
    for k, v in params.items():       
        if isinstance(v, bool):       
            params[k] = str(v).lower()
    return params                     

I'm also going to look through the API docs some more to see if there are any other request parameter types that might need special handling.

from pyinaturalist.

JWCook avatar JWCook commented on June 12, 2024

Looks like we have the following parameter types in the Node API:

Array[integrer]
Array[string]  
boolean        
date           
date-time      
double         
file           
integer        
string         

Arrays should already be handled by concat_list_params(). I can submit a PR for booleans.

from pyinaturalist.

JWCook avatar JWCook commented on June 12, 2024

EDIT: Moved comments on datetimes to Issue #18

from pyinaturalist.

niconoe avatar niconoe commented on June 12, 2024

Thanks for the great PR, @JWCook! That's now merged.

I just keep this issue open so I remember to add an additional "high level" test to ensure that the new conversion functions are actually called from the various user-callable functions (I know they are, it's just for the future). For example:

  • test that get_taxa(q='Lixus bardanae', is_active=False) (the first example at the top of this issue) gives the expected result.
  • also test your other fix (for integer lists) is applied from those methods.

from pyinaturalist.

JWCook avatar JWCook commented on June 12, 2024

@niconoe I just added some more tests to PR #20 (see this commit), since that also involves request param conversion.

That adds both of your example test cases, as well as a test that dynamically gets all functions named pyinaturalist.node_api.get_* (so it will also apply to GET endpoints added in the future), and ensures that they all covert parameters.

Once that and the updates to docs are merged in, I plan to finish dry-run mode for Issue #9 (which is mostly done except for unit tests), update the rest_api endpoints with these changes, and then add a couple more endpoints.

from pyinaturalist.

JWCook avatar JWCook commented on June 12, 2024

I am moving those tests and other related updates to the rest_api module to a separate PR, #22, which is almost done.

from pyinaturalist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.