summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-cache-decorator.spec171
-rw-r--r--sources1
3 files changed, 173 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..e8eb96d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/cache_decorator-2.1.14.tar.gz
diff --git a/python-cache-decorator.spec b/python-cache-decorator.spec
new file mode 100644
index 0000000..3c24491
--- /dev/null
+++ b/python-cache-decorator.spec
@@ -0,0 +1,171 @@
+%global _empty_manifest_terminate_build 0
+Name: python-cache-decorator
+Version: 2.1.14
+Release: 1
+Summary: a simple decorator to cache the results of computationally heavy functions
+License: MIT
+URL: https://github.com/zommiommy/cache_decorator
+Source0: https://mirrors.aliyun.com/pypi/web/packages/82/97/a3dd4feacebc2206c8cb37c800d908ab6d801d215fa7639b4ed782bbeebe/cache_decorator-2.1.14.tar.gz
+BuildArch: noarch
+
+
+%description
+|pip| |downloads|
+A simple decorator to cache the results of computationally heavy functions.
+The package automatically serialize and deserialize depending on the format of the save path.
+By default it supports ``.json .json.gz .json.bz .json.lzma`` and ``.pkl .pkl.gz .pkl.bz .pkl.lzma .pkl.zip``
+but other extensions can be used if the following packages are installed:
+numpy: ``.npy .npz``
+pandas: ``.csv .csv.gz .csv.bz2 .csv.zip .csv.xz``
+Also there is an optimized format for numerical dataframes:
+pandas: ``.embedding .embedding.gz .embedding.bz2 .embedding.xz``
+This creates an optionally compressed tar archive with pickles of the index and
+columns and a ``.npy`` of the values.
+ import time
+ import numpy as np
+ import pandas as pd
+ from cache_decorator import Cache
+ @Cache(
+ cache_path={
+ "info": "/tmp/{function_name}/{_hash}.json.xz",
+ "data": "/tmp/{function_name}/{_hash}.csv.gz",
+ },
+ validity_duration="24d",
+ args_to_ignore=("verbose",),
+ enable_cache_arg_name="enable_cache",
+ )
+ def function_to_cache(seed: int, verbose: bool = True):
+ np.random.seed(seed)
+ if verbose:
+ print(f"using seed {seed}")
+ return {
+ "info": {"timestamp": time.time(), "seed": seed,},
+ "data": pd.DataFrame(
+ np.random.randint(0, 100, size=(100, 4)), columns=list("ABCD")
+ ),
+ }
+
+%package -n python3-cache-decorator
+Summary: a simple decorator to cache the results of computationally heavy functions
+Provides: python-cache-decorator
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-cache-decorator
+|pip| |downloads|
+A simple decorator to cache the results of computationally heavy functions.
+The package automatically serialize and deserialize depending on the format of the save path.
+By default it supports ``.json .json.gz .json.bz .json.lzma`` and ``.pkl .pkl.gz .pkl.bz .pkl.lzma .pkl.zip``
+but other extensions can be used if the following packages are installed:
+numpy: ``.npy .npz``
+pandas: ``.csv .csv.gz .csv.bz2 .csv.zip .csv.xz``
+Also there is an optimized format for numerical dataframes:
+pandas: ``.embedding .embedding.gz .embedding.bz2 .embedding.xz``
+This creates an optionally compressed tar archive with pickles of the index and
+columns and a ``.npy`` of the values.
+ import time
+ import numpy as np
+ import pandas as pd
+ from cache_decorator import Cache
+ @Cache(
+ cache_path={
+ "info": "/tmp/{function_name}/{_hash}.json.xz",
+ "data": "/tmp/{function_name}/{_hash}.csv.gz",
+ },
+ validity_duration="24d",
+ args_to_ignore=("verbose",),
+ enable_cache_arg_name="enable_cache",
+ )
+ def function_to_cache(seed: int, verbose: bool = True):
+ np.random.seed(seed)
+ if verbose:
+ print(f"using seed {seed}")
+ return {
+ "info": {"timestamp": time.time(), "seed": seed,},
+ "data": pd.DataFrame(
+ np.random.randint(0, 100, size=(100, 4)), columns=list("ABCD")
+ ),
+ }
+
+%package help
+Summary: Development documents and examples for cache-decorator
+Provides: python3-cache-decorator-doc
+%description help
+|pip| |downloads|
+A simple decorator to cache the results of computationally heavy functions.
+The package automatically serialize and deserialize depending on the format of the save path.
+By default it supports ``.json .json.gz .json.bz .json.lzma`` and ``.pkl .pkl.gz .pkl.bz .pkl.lzma .pkl.zip``
+but other extensions can be used if the following packages are installed:
+numpy: ``.npy .npz``
+pandas: ``.csv .csv.gz .csv.bz2 .csv.zip .csv.xz``
+Also there is an optimized format for numerical dataframes:
+pandas: ``.embedding .embedding.gz .embedding.bz2 .embedding.xz``
+This creates an optionally compressed tar archive with pickles of the index and
+columns and a ``.npy`` of the values.
+ import time
+ import numpy as np
+ import pandas as pd
+ from cache_decorator import Cache
+ @Cache(
+ cache_path={
+ "info": "/tmp/{function_name}/{_hash}.json.xz",
+ "data": "/tmp/{function_name}/{_hash}.csv.gz",
+ },
+ validity_duration="24d",
+ args_to_ignore=("verbose",),
+ enable_cache_arg_name="enable_cache",
+ )
+ def function_to_cache(seed: int, verbose: bool = True):
+ np.random.seed(seed)
+ if verbose:
+ print(f"using seed {seed}")
+ return {
+ "info": {"timestamp": time.time(), "seed": seed,},
+ "data": pd.DataFrame(
+ np.random.randint(0, 100, size=(100, 4)), columns=list("ABCD")
+ ),
+ }
+
+%prep
+%autosetup -n cache_decorator-2.1.14
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-cache-decorator -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri Jun 09 2023 Python_Bot <Python_Bot@openeuler.org> - 2.1.14-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..e24d0ca
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+eaa96907168945db685ea72501083972 cache_decorator-2.1.14.tar.gz