Open jayrbolton opened 5 years ago
It would be nice to be able to pass the cache_id as a parameter, rather than saving it to the class. This way, you can more easily deal with multiple cache files:
This looks like a better solution, and I will start implementing this. When generating new cache ids, would probably require two requests one to /download and parse json make sure cache_id doesn't already exist, my thought here was handling the cache id internally to prevent cache_id overlap.
I will also move all the exceptions to a seperate files and write this custom non-existent cache exception.
@jayrbolton
I think addressed all the concerns here and made some clean up improvements. Let me know if you want me to change anything.
Ryan
I think what we have already is good to publish. But here are some further thoughts:
It would be nice to be able to pass the cache_id as a parameter, rather than saving it to the class. This way, you can more easily deal with multiple cache files:
A specific error for a nonexistent cache might be more useful than ValueError. This could be used to do a try/except on the download:
Or we could even shortcut the above with a utility such as:
Where
expensive_file_generator
is a function that returns the file path to upload to the cache. This function only gets run if we cannot download the cache. Themy_cache_params
object would be passed to the function. It would also be used to generate the cache id.