glasgow-ipl / ietfdata

Python libraries to access the IETF DataTracker and RFC Index
BSD 2-Clause "Simplified" License
17 stars 13 forks source link

RFCIndex() NotImplementedError when cache is disabled #152

Open sbenthall opened 1 month ago

sbenthall commented 1 month ago

I'm running the same file in two slightly different ways, and getting different results.

If I git clone this repository, then install it locally with pip install -e ., and then do python3 examples/drafts-for-rfc.py, I get the following (expected)

$ python3 examples/drafts-for-rfc.py 
INFO:ietfdata:cache enabled: sqlite dir=. timeout=(auto)
INFO:ietfdata:datatracker at https://datatracker.ietf.org
WARNING:rfcindex:cache enabled: dir=None
    draft-irtf-hrpc-research                           | 14 | 2017-07-17
    draft-irtf-hrpc-research                           | 13 | 2017-05-18
    draft-irtf-hrpc-research                           | 12 | 2017-04-10
    draft-irtf-hrpc-research                           | 11 | 2017-02-25
    draft-irtf-hrpc-research                           | 10 | 2017-02-08
    draft-irtf-hrpc-research                           | 09 | 2017-02-02
    draft-irtf-hrpc-research                           | 08 | 2017-01-20
    draft-irtf-hrpc-research                           | 07 | 2016-11-28
    draft-irtf-hrpc-research                           | 06 | 2016-11-25
    draft-irtf-hrpc-research                           | 05 | 2016-11-14
    draft-irtf-hrpc-research                           | 04 | 2016-11-13
    draft-irtf-hrpc-research                           | 03 | 2016-10-23
    draft-irtf-hrpc-research                           | 02 | 2016-10-18
    draft-irtf-hrpc-research                           | 01 | 2016-10-09
    draft-irtf-hrpc-research                           | 00 | 2016-09-19
    draft-tenoever-hrpc-research                       | 05 | 2016-08-27
    draft-tenoever-hrpc-research                       | 04 | 2016-07-18
    draft-tenoever-hrpc-research                       | 03 | 2016-07-06
    draft-tenoever-hrpc-research                       | 02 | 2016-05-13
    draft-tenoever-hrpc-research                       | 01 | 2016-05-05
    draft-tenoever-hrpc-research                       | 00 | 2016-03-17
    draft-varon-hrpc-methodology                       | 04 | 2016-02-09
    draft-varon-hrpc-methodology                       | 03 | 2016-01-27
    draft-varon-hrpc-methodology                       | 02 | 2015-12-04
    draft-dkg-hrpc-glossary                            | 01 | 2015-10-16
    draft-varon-hrpc-methodology                       | 01 | 2015-10-16
    draft-varon-hrpc-methodology                       | 00 | 2015-07-06
    draft-dkg-hrpc-glossary                            | 00 | 2015-07-05

Oddly, if I have the same file in another directory, and try to run it, I get a different output:

$ python3 tmp-rfc-example.py 
WARNING:ietfdata:CACHE DISABLED
Traceback (most recent call last):
  File "/home/sb/projects/bigbang/tmp-rfc-example.py", line 37, in <module>
    ri = RFCIndex()
  File "/home/sb/projects/bigbang/bigbang-env/lib/python3.9/site-packages/ietfdata/rfcindex.py", line 527, in __init__
    raise NotImplementedError
NotImplementedError

I suppose this has to do with some way the cache is configured.

The broader issue I have is that I'm trying to use ietfdata as a dependency in another library. I would prefer not to use the optional cache in these cases. I'm getting the same error as above when trying to run this as part of a larger program.

Any guidance on how to proceed?

sbenthall commented 1 month ago

I was able to work around this issue by adding a configuration option to the library that points the path of the ietf-dt-cache.sqlite file, and adding this to the Python sys.path before trying to initialize the RFCIndex.

As far as I know, this isn't documented, and I'm not sure when this sqlite file is created.

Where would it be if ietfdata is pip installed?

I should note that part of the fix was pip installing ietfdata from git master, rather than the latest release.