Repository: intake/intake

Issue:
persist ttl argument should check that it's an int.
I just tried to use persist for the first time and passed a file name to the `ttl` argument (don't ask me why but I kind of thought `ttl` might be a terrible abbreviation of title). Passing a string to ttl did not through an error, but when I try to call `is_persisted` on the source, I am getting a comparison failure. 

As part of this, might be nice to add to the persist docstring. 

Discussion:

Patch:
diff --git a/intake/source/base.py b/intake/source/base.py
index f3abbbb..79fc62e 100644
--- a/intake/source/base.py
+++ b/intake/source/base.py
@@ -259,13 +259,26 @@ class DataSource(DictSerialiseMixin):
         return self.plot
 
     def persist(self, ttl=None, **kwargs):
-        """Save data from this source to local persistent storage"""
+        """Save data from this source to local persistent storage
+
+        Parameters
+        ----------
+        ttl: numeric, optional
+            Time to live in seconds. If provided, the original source will
+            be accessed and a new persisted version written transparently
+            when more than ``ttl`` seconds have passed since the old persisted
+            version was written.
+        kargs: passed to the _persist method on the base container.
+        """
         from ..container import container_map
         from ..container.persist import PersistStore
         import time
         if 'original_tok' in self.metadata:
             raise ValueError('Cannot persist a source taken from the persist '
                              'store')
+        if ttl is not None and not isinstance(ttl, (int, float)):
+            raise ValueError('Cannot persist using a time to live that is '
+                             f'non-numeric. User-provided ttl was {ttl}')
         method = container_map[self.container]._persist
         store = PersistStore()
         out = method(self, path=store.getdir(self), **kwargs)


Test patch:
diff --git a/intake/container/tests/test_persist.py b/intake/container/tests/test_persist.py
index d914d25..96a831f 100644
--- a/intake/container/tests/test_persist.py
+++ b/intake/container/tests/test_persist.py
@@ -44,6 +44,12 @@ def test_backtrack(temp_cache):
     assert s3 == s
 
 
+def test_persist_with_nonnumeric_ttl_raises_error(temp_cache):
+    s = TextFilesSource("*.py")
+    with pytest.raises(ValueError, match="User-provided ttl was a string"):
+        s.persist(ttl='a string')
+
+
 class DummyDataframe(DataSource):
     name = 'dummy'
     container = 'dataframe'