pyinat / pyinaturalist

Python client for iNaturalist
https://pyinaturalist.readthedocs.io
MIT License
130 stars 17 forks source link

Error `WARNING Parameters missing or invalid:1/1 cannot come before 1/1"` using pyinaturalist #548

Closed nigelcharman closed 7 months ago

nigelcharman commented 7 months ago

The problem

The hourly GitHub Actions job for https://github.com/EcoNet-NZ/inaturalist-to-cams is failing with "WARNING Parameters missing or invalid:1/1 cannot come before 1/1"

The error appears to be coming from pyrate-limiter being called from pyinaturalist:

client = pyinaturalist.iNatClient()
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyinaturalist/client.py", line 114, in __init__
    self.session = session or ClientSession(**kwargs)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyinaturalist/session.py", line 121, in __init__
    super().__init__(  # type: ignore  # false positive
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests_cache/session.py", line 79, in __init__
    super().__init__(**get_valid_kwargs(super().__init__, kwargs))  # type: ignore
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/requests_ratelimiter/requests_ratelimiter.py", line 66, in __init__
    self.limiter = limiter or Limiter(
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyrate_limiter/limiter.py", line [34](https://github.com/EcoNet-NZ/inaturalist-to-cams/actions/runs/7692396401/job/20959237167#step:7:35), in __init__
    self._validate_rate_list(rates)
  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyrate_limiter/limiter.py", line 58, in _validate_rate_list
    raise InvalidParams(msg)
pyrate_limiter.exceptions.InvalidParams: Parameters missing or invalid:1/1 cannot come before 1/1

See https://github.com/EcoNet-NZ/inaturalist-to-cams/issues/75 for full stack trace.

Expected behavior

The code has been working for about a year and no code changes were made before this issue occurred.

We do a pip install -r requirements.txt prior to each GitHub Actions run (with results being cached). See https://github.com/EcoNet-NZ/inaturalist-to-cams/blob/main/requirements.txt.

The GitHub Actions log is https://github.com/EcoNet-NZ/inaturalist-to-cams/actions/runs/7692270856/job/20958903852.

Steps to reproduce the behavior

I think it's coming from the import pyinaturalist line.

Workarounds

None known

Environment

Ubuntu 22.0.3 LTS Python 3.9.18 pyinaturalist 0.18.0

Collecting pyrate-limiter<3.0 (from requests-ratelimiter>=0.3.2->pyinaturalist==0.18.0->-r requirements.txt (line 1)) Using cached pyrate_limiter-2.10.0-py3-none-any.whl (16 kB)

nigelcharman commented 7 months ago

Seems to have been an issue in requests-ratelimiter 0.5.0 released an hour ago. Seems to be fixed in 0.5.1 released 20 minutes ago.

See https://pypi.org/project/requests-ratelimiter/#history

JWCook commented 7 months ago

Yeah, it looks like the job ran within a 43-minute window of time in which there was a bug in the latest version of requests-ratelimiter. Sorry about that.

JWCook commented 7 months ago

I'd recommend installing dependencies from a full lockfile (or output of pip freeze). That requirements.txt has pinned versions of its top-level dependencies, but any transitive dependencies (including requests-ratelimiter) will use the latest version available.

nigelcharman commented 7 months ago

Yeah, we tend to be susceptible to that sort of thing by running hourly with a pip install each time. I'll lock at using the full lockfile (or output of pip freeze).

JWCook commented 7 months ago

If you do want to try using a tool that handles lockfiles (like poetry, pipenv, or pdm), I would be happy to help set that up.

Meanwhile, a simple short-term option is: