From 7a3340f0136acb3568300598b71b81c41cb4cbf8 Mon Sep 17 00:00:00 2001 From: mynameisvinn Date: Sun, 30 Apr 2017 13:44:27 -0400 Subject: [PATCH] include local caching --- pyNASA/__init__.py | 6 ++++++ requirements.txt | 2 ++ 2 files changed, 8 insertions(+) diff --git a/pyNASA/__init__.py b/pyNASA/__init__.py index 7dc2540..d0a8f59 100644 --- a/pyNASA/__init__.py +++ b/pyNASA/__init__.py @@ -2,6 +2,11 @@ import json import pkg_resources from sodapy import Socrata +from joblib import Memory +from tempfile import mkdtemp + +cachedir = mkdtemp() +memory = Memory(cachedir=cachedir, verbose=0) # TODO: find temp dir class pyNASA: def __init__(self, token=None, secret=None): @@ -25,6 +30,7 @@ def rec(self, limit=50000, offset=0): setattr(pyNASA, name, rec) + @memory.cache def resource(self, resource_name, limit=50000, offset=0): records = self.client.get(resource_name, limit=limit, offset=offset) diff --git a/requirements.txt b/requirements.txt index 0dc54e1..05f7020 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ pandas==0.18.1 setuptools==34.2.0 requests==2.12.1 sodapy==1.4.3 +joblib +tempfile \ No newline at end of file