Closed
Description
Problem Description
I installed td-watson in a fresh environment and received an error when running:
$ docker run -it --rm python:latest /bin/bash
root@4156557dc8cf:/# pip install td-watson
...
root@4156557dc8cf:/# watson status
Traceback (most recent call last):
File "/usr/local/bin/watson", line 5, in <module>
from watson.__main__ import cli
File "/usr/local/lib/python3.9/site-packages/watson/__main__.py", line 2, in <module>
from watson import cli
File "/usr/local/lib/python3.9/site-packages/watson/cli.py", line 441, in <module>
_SHORTCUT_OPTIONS_VALUES = {
File "/usr/local/lib/python3.9/site-packages/watson/cli.py", line 442, in <dictcomp>
k: get_start_time_for_period(k) for k in _SHORTCUT_OPTIONS
File "/usr/local/lib/python3.9/site-packages/watson/utils.py", line 193, in get_start_time_for_period
start_time = get_last_full_moon(now)
File "/usr/local/lib/python3.9/site-packages/watson/fullmoon.py", line 226, in get_last_full_moon
idx = bisect.bisect_right(fullmoons, now)
TypeError: '<' not supported between instances of 'method' and 'int'
The arrow library was updated on Feb 24, 2021 and there are breaking changes.
The default td-watson installation uses the new version, arrow 1.0.0:
root@4156557dc8cf:/# pip freeze
arrow==1.0.0
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
click-didyoumean==0.0.3
idna==2.10
python-dateutil==2.8.1
requests==2.25.1
six==1.15.0
td-watson==1.10.0
urllib3==1.26.3
Workaround
Downgrade to arrow 0.17.0:
root@4156557dc8cf:/# pip uninstall arrow
Found existing installation: arrow 1.0.0
Uninstalling arrow-1.0.0:
Would remove:
/usr/local/lib/python3.9/site-packages/arrow-1.0.0.dist-info/*
/usr/local/lib/python3.9/site-packages/arrow/*
Proceed (y/n)? y
Successfully uninstalled arrow-1.0.0
root@4156557dc8cf:/# pip install arrow==0.17.0
And td-watson works again:
root@4156557dc8cf:/# watson status
No project started.
root@4156557dc8cf:/# watson start testing123
Starting project testing123 at 15:25
root@4156557dc8cf:/# watson stop
Stopping project testing123, started just now and stopped just now. (id: d056c4c)
Quick fix
Update requirements.txt changing the line:
arrow>=0.15.6
To specify the exact version:
arrow==0.17.0
Long-term solution
According to the arrow 1.0.0 migration guide:
The .timestamp property has been removed to improve compatibility with datetime. Use .int_timestamp for the same results.
arrow.utcnow().int_timestamp
1608640233
I tried this and it appears to work.
The changes are:
diff watson/frames.py /usr/local/lib/python3.9/site-packages/watson/frames.py
38,40c38,40
< start = self.start.to('utc').timestamp
< stop = self.stop.to('utc').timestamp
< updated_at = self.updated_at.timestamp
---
> start = self.start.to('utc').int_timestamp
> stop = self.stop.to('utc').int_timestamp
> updated_at = self.updated_at.int_timestamp
diff watson/fullmoon.py /usr/local/lib/python3.9/site-packages/watson/fullmoon.py
225c225,226
< now = d.timestamp
---
> now = d.int_timestamp
diff watson/watson.py /usr/local/lib/python3.9/site-packages/watson/watson.py
104c104
< return date.timestamp
---
> return date.int_timestamp