BridgesUNCC / bridges-python

Python client library for Bridges
http://bridgesuncc.github.io
MIT License
2 stars 4 forks source link

gutenberg api caching.. #80

Closed krs-world closed 3 years ago

krs-world commented 3 years ago

Matthew:

We need to fix the caching on the python api - right now its writing to a cache folder in the current directory. We need it to write to the following: ~/.cache/bridges-data/python/

Look at the Java and C++ versions, it is writing to the cxx and java subfolders fo the above path. Then some modification needs to be done to the gutenberg api for getting full text as it now returns th efull text as a JSON. The gutenberg test server is updated so use that to test. Add a -t at the end of the server name to switch to the test server.

I dont quite understand the yoru python code with files and paths to muck with it.

esaule commented 3 years ago

Check the java code carefully for where it places the caching directory as the directory placement depends on the operating system and we probably want to place it using the same logic.

krs-world commented 3 years ago

Ok, I fixed it. Would one of you check

lru_cache.py data_source.py (this should be ok, only changes in gutenberg_get_book_text () and minor

Now, all cache files will be in. ~/.cache/bridges_data{cxx, java, python}

I learnt the mysterious f strings in Python - its crazy the format some of these languages use -- like hte lambda functions in C++ -:(

krs-world commented 3 years ago

I just tested with one book and it works fine..

krs-world commented 3 years ago

The python test is not working now. There was a change in the JSON for getting the full text. The query:

http://bridges-data-server-gutenberg-t.bridgesuncc.org//book?id=2701

brings back the Moby Dick text. Somehow this is not written into the cache correctly. Assigning to Matthew. Only getting the full text part is not working (relevant function : gutenbert_book_text() )

krs-world commented 3 years ago

Error comes in json.loads() call..

krs-world commented 3 years ago

Fixed..