mbari-org / vars-gridview

VARS GridView is a tool for reviewing and correcting VARS localizations in bulk.
MIT License
2 stars 0 forks source link

Query fail: TypeError: '<=' not supported #32

Closed lonnylundsten closed 12 months ago

lonnylundsten commented 1 year ago

Trying to do a concept + descendants query for concept=trash and got the following error:

Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/scripts/run.py", line 340, in _do_query
    self.image_mosaic = ImageMosaic(
                        ^^^^^^^^^^^^
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 196, in __init__
    mp4_video_data = self.find_mp4_video_data(video_sequence_name, moment_timestamp)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 394, in find_mp4_video_data
    if not (video_start_timestamp <= timestamp <= video_end_timestamp):  # Timestamp not in range
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'
### Tasks
lonnylundsten commented 1 year ago

It seems this is affecting all queries, just tried for Gersmia juliepackardae:

Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/scripts/run.py", line 340, in _do_query
    self.image_mosaic = ImageMosaic(
                        ^^^^^^^^^^^^
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 196, in __init__
    mp4_video_data = self.find_mp4_video_data(video_sequence_name, moment_timestamp)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 394, in find_mp4_video_data
    if not (video_start_timestamp <= timestamp <= video_end_timestamp):  # Timestamp not in range
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'
lonnylundsten commented 1 year ago

I'm still having this issue, rendering grid view unusable:

TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str' Traceback (most recent call last): File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/scripts/run.py", line 340, in _do_query self.image_mosaic = ImageMosaic( ^^^^^^^^^^^^ File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 196, in init mp4_video_data = self.find_mp4_video_data(video_sequence_name, moment_timestamp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lonny/.pyenv/versions/3.11.5/lib/python3.11/site-packages/vars_gridview/lib/image_mosaic.py", line 394, in find_mp4_video_data if not (video_start_timestamp <= timestamp <= video_end_timestamp): # Timestamp not in range ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: '<=' not supported between instances of 'datetime.datetime' and 'str'

kevinsbarnard commented 1 year ago

Hi @lonnylundsten, I haven't been able to replicate this bug on my end; both of the queries you gave seem to run and load fine. I'm wondering if it's an issue in your dependencies -- could you run a pip freeze and send me the results?

lonnylundsten commented 1 year ago

❯ pip freeze absl-py==2.0.0 addict==2.4.0 aiofiles==23.2.1 aiohttp==3.8.5 aiohttp-retry==2.8.3 aiosignal==1.3.1 altair==5.1.1 amqp==5.1.1 annotated-types==0.5.0 antlr4-python3-runtime==4.13.1 anyio==4.0.0 appdirs==1.4.4 appnope==0.1.3 argcomplete==3.1.2 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 astor==0.8.1 asttokens==2.4.0 astunparse==1.6.3 async-lru==2.0.4 async-timeout==4.0.3 asyncssh==2.13.2 atpublic==4.0 attrs==23.1.0 autocommand==2.2.2 Babel==2.12.1 backcall==0.2.0 beautifulsoup4==4.12.2 beholder-client==0.1.0 billiard==4.1.0 black==23.9.1 bleach==6.0.0 blinker==1.6.2 bokeh==3.2.2 boto3==1.28.56 botocore==1.31.56 boxdiff==0.1.1 boxjelly==0.3.3 bracex==2.4 Brotli==1.1.0 build==0.10.0 CacheControl==0.13.1 cachelib==0.10.2 cachetools==5.3.1 Cartopy==0.22.0 cattrs==23.1.2 celery==5.3.4 certifi==2023.7.22 cffi==1.15.1 charset-normalizer==3.2.0 cheroot==10.0.0 CherryPy==18.8.0 cleo==2.0.1 click==8.1.7 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 colorama==0.4.6 comm==0.1.4 configobj==5.0.8 connectorx==0.3.2 contourpy==1.1.1 coremltools==7.0 crashtest==0.4.1 cryptography==41.0.4 cycler==0.11.0 Cython==3.0.2 cytoolz==0.12.2 dacite==1.8.1 dataclasses==0.6 dataclasses-json==0.6.1 datasets==2.14.5 debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 Deprecated==1.2.14 dictdiffer==0.9.0 dill==0.3.7 diskcache==5.6.3 distlib==0.3.7 distro==1.8.0 dnspython==2.4.2 dpath==2.1.6 dulwich==0.21.6 dvc==3.23.0 dvc-data==2.16.4 dvc-http==2.30.2 dvc-objects==1.0.1 dvc-render==0.6.0 dvc-studio-client==0.15.0 dvc-task==0.3.0 entrypoints==0.4 et-xmlfile==1.1.0 executing==1.2.0 fastapi==0.103.1 fastjsonschema==2.18.0 fiftyone==0.22.0 fiftyone-brain==0.13.1 fiftyone-db==0.4.0 filelock==3.12.4 Flask==2.3.3 Flask-Caching==2.0.2 flatbuffers==23.5.26 flatten-dict==0.4.2 flufl.lock==8.0.2 fonttools==4.42.1 fqdn==1.5.1 freetype-py==2.4.0 frozenlist==1.4.0 fsspec==2023.9.2 ftfy==6.1.1 funcy==2.0 future==0.18.3 fvcore==0.1.5.post20221221 gast==0.5.4 GDAL==3.7.2 gevent==23.9.1 geventhttpclient==2.0.10 gitdb==4.0.10 GitPython==3.1.37 glob2==0.7 google-auth==2.23.1 google-auth-oauthlib==1.0.0 google-pasta==0.2.0 grandalf==0.8 graphql-core==3.2.3 greenlet==3.0.0rc3 grpcio==1.58.0 gto==1.3.0 h11==0.14.0 h2==4.1.0 h5py==3.9.0 hpack==4.0.0 hsluv==5.0.4 httpcore==0.18.0 httpx==0.25.0 huggingface-hub==0.17.3 hydra-core==1.3.2 hypercorn==0.14.4 hyperframe==6.0.1 idna==3.4 imageio==2.31.4 imagesize==1.4.1 importlib-metadata==6.8.0 inflate64==0.3.1 inflect==7.0.0 installer==0.7.0 intervaltree==3.1.0 iopath==0.1.10 ipykernel==6.25.2 ipython==8.15.0 ipywidgets==8.1.1 isoduration==20.11.0 iterative-telemetry==0.0.8 itsdangerous==2.1.2 jaraco.classes==3.3.0 jaraco.collections==4.3.0 jaraco.context==4.3.0 jaraco.functools==3.9.0 jaraco.text==3.11.1 jax==0.4.16 jedi==0.19.0 Jinja2==3.1.2 jmespath==1.0.1 joblib==1.3.2 json-stream==2.3.2 json-stream-rs-tokenizer==0.4.23 json5==0.9.14 jsonlines==4.0.0 jsonpointer==2.4 jsonschema==4.17.3 jsonschema-specifications==2023.7.1 jstyleson==0.0.2 jupyter-events==0.7.0 jupyter-lsp==2.2.0 jupyter_client==8.3.1 jupyter_core==5.3.2 jupyter_server==2.7.3 jupyter_server_terminals==0.4.4 jupyterlab==4.0.6 jupyterlab-pygments==0.2.2 jupyterlab-widgets==3.0.9 jupyterlab_server==2.25.0 kaleido==0.2.1 kangas==2.4.2 keras==2.14.0 keyring==24.2.0 kiwisolver==1.4.5 kombu==5.3.2 lab==7.4 lapx==0.5.4 lazy_loader==0.3 libclang==16.0.6 lxml==4.9.3 Markdown==3.4.4 markdown-it-py==3.0.0 marko==2.0.0 MarkupSafe==2.1.3 marshmallow==3.20.1 matplotlib==3.8.0 matplotlib-inline==0.1.6 mdurl==0.1.2 meerkat-ml==0.4.11 mistune==3.0.1 mizani==0.10.0 ml-dtypes==0.3.1 mongoengine==0.27.0 more-itertools==10.1.0 motor==3.3.1 mpmath==1.3.0 msgpack==1.0.6 multidict==6.0.4 multiprocess==0.70.15 multivolumefile==0.2.3 mypy-extensions==1.0.0 nbclient==0.8.0 nbconvert==7.8.0 nbformat==5.9.2 nest-asyncio==1.5.8 networkx==3.1 nibabel==5.1.0 nodejs-bin==16.15.1a4 notebook_shim==0.2.3 numpy==1.26.0 oauthlib==3.2.2 objectpath==0.6.1 omegaconf==2.3.0 opencv-python==4.8.0.76 opencv-python-headless==4.8.0.76 openpyxl==3.1.2 openvino==2023.1.0 openvino-dev==2023.1.0 openvino-telemetry==2023.1.1 opt-einsum==3.3.0 orjson==3.9.7 overrides==7.4.0 ovmsclient==2023.1 packaging==23.1 pafy==0.5.5 pandas==2.1.1 pandocfilters==1.5.0 parso==0.8.3 pascal-voc-writer==0.1.4 pathspec==0.11.2 patsy==0.5.3 pexpect==4.8.0 pickleshare==0.7.5 Pillow==9.5.0 pip-chill==1.0.3 pipdate==0.5.6 pkginfo==1.9.6 platformdirs==3.10.0 plotly==5.17.0 plotnine==0.12.3 poetry==1.6.1 poetry-core==1.7.0 poetry-plugin-export==1.5.0 polars==0.19.5 portalocker==2.8.2 portend==3.2.0 pprintpp==0.4.0 priority==2.0.0 progressbar==2.5 progressbar2==4.2.0 prometheus-client==0.17.1 prompt-toolkit==3.0.39 protobuf==4.24.3 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 py-cpuinfo==9.0.0 py7zr==0.20.6 pyaml==23.9.6 pyarrow==13.0.0 pyasn1==0.5.0 pyasn1-modules==0.3.0 pybcj==1.0.1 pycocotools==2.0.7 pycparser==2.21 pycryptodomex==3.19.0 pydantic==2.4.1 pydantic_core==2.10.1 pydeck==0.8.0 pydot==1.4.2 pyemd==1.0.0 pygit2==1.13.1 Pygments==2.16.1 pygtrie==2.5.0 pymediainfo==6.0.1 pymongo==4.5.0 Pympler==1.0.1 pymssql==2.2.8 pyngrok==7.0.0 pyodbc @ file:///Users/lonny/Desktop/pyodbc-4.0.39.tar.gz#sha256=e528bb70dd6d6299ee429868925df0866e3e919c772b9eff79c8e17920d8f116 pyparsing==3.1.1 pyppmd==1.0.0 pyproj==3.6.1 pyproject_hooks==1.0.0 PyQt6==6.5.2 PyQt6-Qt6==6.5.2 PyQt6-sip==13.5.2 pyqtgraph==0.13.3 pyrsistent==0.19.3 pyshp==2.3.1 python-dateutil==2.8.2 python-dotenv==1.0.0 python-json-logger==2.0.7 python-rapidjson==1.11 python-utils==3.8.1 pytz==2023.3.post1 pytz-deprecation-shim==0.1.0.post0 PyWavelets==1.4.1 PyYAML==6.0.1 pyzmq==25.1.1 pyzstd==0.15.9 QDarkStyle==3.1 QtPy==2.4.0 rapidfuzz==2.15.1 rarfile==4.1 referencing==0.30.2 regex==2023.8.8 requests==2.31.0 requests-oauthlib==1.3.1 requests-toolbelt==1.0.0 retrying==1.3.4 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rich==13.5.3 rpds-py==0.10.3 rsa==4.9 ruamel.yaml==0.17.32 ruamel.yaml.clib==0.2.7 Rx==3.2.0 s3transfer==0.7.0 safetensors==0.3.3 scikit-image==0.21.0 scikit-learn==1.3.1 scipy==1.11.3 scmrepo==1.3.1 seaborn==0.12.2 semver==3.0.1 Send2Trash==1.8.2 shapely==2.0.1 sharktopoda-client==0.4.3 shellingham==1.5.3 shortuuid==1.0.11 shtab==1.6.4 simplejson==3.19.1 simplekml==1.3.6 six==1.16.0 smmap==5.0.1 sniffio==1.3.0 sortedcontainers==2.4.0 soupsieve==2.5 SQLAlchemy==2.0.21 sqltrie==0.7.0 sse-starlette==1.6.5 sseclient-py==1.8.0 stack-data==0.6.2 starlette==0.31.1 statsmodels==0.14.0 strawberry-graphql==0.209.2 streamlit==1.27.0 supervision==0.14.0 sympy==1.12 tabulate==0.9.0 tempora==5.5.0 tenacity==8.2.3 tensorboard==2.14.1 tensorboard-data-server==0.7.1 tensorboardX==2.6.2.2 tensorflow==2.14.0 tensorflow-estimator==2.14.0 tensorflow-io-gcs-filesystem==0.34.0 tensorflow-macos==2.14.0 tensorflow-metal==1.0.1 termcolor==2.3.0 terminado==0.17.1 texttable==1.6.7 threadpoolctl==3.2.0 tifffile==2023.9.26 tinycss2==1.2.1 tokenizers==0.14.0 toml==0.10.2 tomlkit==0.12.1 toolz==0.12.0 torch==2.0.1 torchvision==0.15.2 tornado==6.3.3 tqdm==4.66.1 traitlets==5.10.1 transformers==4.33.3 tritonclient==2.36.0 trove-classifiers==2023.9.19 txt2tags==3.8 typer==0.9.0 typing-inspect==0.9.0 typing_extensions==4.8.0 tzdata==2023.3 tzlocal==5.0.1 ujson==5.8.0 ultralytics==8.0.188 universal-analytics-python3==1.1.1 uri-template==1.3.0 urllib3==2.0.5 uvicorn==0.23.2 validators==0.22.0 vars-gridview==0.3.10 vine==5.0.0 virtualenv==20.24.5 vispy==0.14.0 voluptuous==0.13.1 voxel51-eta==0.12.0 waitress==2.1.2 wcmatch==8.5 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.3 Werkzeug==2.3.7 wget==3.2 widgetsnbextension==4.0.9 wrapt==1.15.0 wsproto==1.2.0 xattr==0.10.1 xlrd==2.0.1 xmltodict==0.13.0 xxhash==3.3.0 xyzservices==2023.7.0 yacs==0.1.8 yarl==1.9.2 youtube-dl==2021.12.17 zc.lockfile==3.0.post1 zipp==3.17.0 zmq==0.0.0 zope.event==5.0 zope.interface==6.0

lonnylundsten commented 1 year ago

I think the issue may be due to pymssql 2.2.8. This is the only version I can get installed on my M2 Mac (apple silicone). I think vars-gridview currently requires < 2.2.8

kevinsbarnard commented 12 months ago

Hi @lonnylundsten, this should be fixed in v0.3.11, and I relaxed the constraint in v0.3.12 so you can install on your M2. Let me know if that doesn't solve the issue.

lonnylundsten commented 12 months ago

Hi @kevinsbarnard this update created a new issue:

qt.qpa.fonts: Populating font family aliases took 139 ms. Replace uses of missing font family "MS Shell Dlg 2" with one that exists to avoid this cost. 
2023-10-04 15:16:34,296 - vars-gridview - WARNING - Could not connect to Sharktopoda
Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/lib/util.py", line 62, in parse_iso
    return datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2015-02-28 18:16:50.0000000' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 339, in _do_query
    self.image_mosaic = ImageMosaic(
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/lib/image_mosaic.py", line 170, in __init__
    recorded_timestamp = parse_iso(recorded_timestamp)
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/lib/util.py", line 64, in parse_iso
    return datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ")
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2015-02-28 18:16:50.0000000' does not match format '%Y-%m-%dT%H:%M:%SZ'

I installed a clean python 3.9.17 and installed only vars-gridview and its requirements, hoping that a clean environment would make this work. Here's a pip freeze:

❯ pip freeze
beholder-client==0.1.0
certifi==2023.7.22
charset-normalizer==3.3.0
idna==3.4
numpy==1.26.0
opencv-python==4.8.1.78
packaging==23.2
Pillow==9.5.0
pymssql==2.2.8
PyQt6==6.5.2
PyQt6-Qt6==6.5.2
PyQt6-sip==13.5.2
pyqtgraph==0.13.3
QDarkStyle==3.1
QtPy==2.4.0
requests==2.31.0
sharktopoda-client==0.4.3
urllib3==2.0.6
vars-gridview==0.3.12
kevinsbarnard commented 12 months ago

@lonnylundsten Ah, my bad, I assumed the database was serving ISO-8601. I'll put in a patch for that now.

kevinsbarnard commented 12 months ago

@lonnylundsten Ok, released v0.3.13. Can you give that a spin? Fingers crossed, it should handle all the datetimes that SQL server will throw out.

lonnylundsten commented 12 months ago

OK. Its working! Thanks!

lonnylundsten commented 12 months ago

It does seem to be working but when I select an ROI errors are popping up in the terminal. Again, it seems to be working but...

Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 548, in rect_clicked
    rect.annotation_datetime().strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'
Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 548, in rect_clicked
    rect.annotation_datetime().strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'
Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 548, in rect_clicked
    rect.annotation_datetime().strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'
Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 548, in rect_clicked
    rect.annotation_datetime().strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'
Traceback (most recent call last):
  File "/Users/lonny/.pyenv/versions/3.9.17/lib/python3.9/site-packages/vars_gridview/scripts/run.py", line 548, in rect_clicked
    rect.annotation_datetime().strftime("%Y-%m-%d %H:%M:%S")
AttributeError: 'str' object has no attribute 'strftime'
kevinsbarnard commented 12 months ago

That's what I get for duplicating code... 😅 I just released v0.3.14 which should fix this (and anywhere else the Apple Silicon datetime bug should arise).

lonnylundsten commented 12 months ago

Fixed. Thank you.