magsol / wildlife-cameras

🐍️ Scripts related to the outdoor wildlife cameras.
MIT License
1 stars 0 forks source link

Astral version issues and errors #25

Closed magsol closed 1 year ago

magsol commented 1 year ago

Despite the latest version of Astral being 3.2, the version that is packaged with debian is 1.6.1, and so has a dramatically different API. Which also seem to have their own problems.

The Location object (different from 3.2's LocationInfo) will use more or less the same information, but the initialization of the object doesn't even work before throwing back the following error:

from astral import Location
l = Location("Athens", "Georgia", 33.9519, -83.3576, "US/Eastern", 0)
Traceback (most recent call last):
  File "/workspaces/wildlife-cameras/testing/astral.py", line 1, in <module>
    from astral import Location
  File "/workspaces/wildlife-cameras/testing/astral.py", line 1, in <module>
    from astral import Location
ImportError: cannot import name 'Location' from partially initialized module 'astral' (most likely due to a circular import) (/workspaces/wildlife-cameras/testing/astral.py)

To be blunt, I'm not interested in chasing down a circular dependency in a deprecated API, so #13 as written in the code samples won't work. I'm left with the following options:

  1. Use the location for Atlanta, instead of Athens, as this seems to be pre-recorded in the internal list of locations. It's close enough for what we're trying to do.
  2. Switch to python3-suntime, which is even older than the debian astral package (most of the code is 4+ years old), but this hasn't been tested yet either.

We'll start with 1.

magsol commented 1 year ago

oh ffs

The file I'd created for testing was named astral.py, and that was the cause of the circular dependency issues. Renaming it to astral_testing.py fixed them.

I did have to make a minor fix to the OP code:

from astral import Location
l = Location(("Athens", "Georgia", 33.9519, -83.3576, "US/Eastern", 0))
print(l.sun())

(note the arguments to Location are now a single tuple, rather than 6 distinct items as before)

This works. We'll go with this.