-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example: ```python import os import pandas import shutil from executorlib import Executor from executorlib.standalone.hdf import get_cache_data cache_directory = "./cache" with Executor(backend="local", cache_directory=cache_directory) as exe: future_lst = [exe.submit(sum, [i, i]) for i in range(1, 4)] print([f.result() for f in future_lst]) df = pandas.DataFrame(get_cache_data(cache_directory=cache_directory)) df ```
- Loading branch information
1 parent
ea305da
commit d1e72c4
Showing
2 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import shutil | ||
import unittest | ||
|
||
from executorlib import Executor | ||
|
||
try: | ||
|
||
from executorlib.standalone.hdf import get_cache_data | ||
|
||
skip_h5py_test = False | ||
except ImportError: | ||
skip_h5py_test = True | ||
|
||
|
||
@unittest.skipIf( | ||
skip_h5py_test, "h5py is not installed, so the h5io tests are skipped." | ||
) | ||
class TestCacheFunctions(unittest.TestCase): | ||
def test_cache_data(self): | ||
cache_directory = "./cache" | ||
with Executor(backend="local", cache_directory=cache_directory) as exe: | ||
future_lst = [exe.submit(sum, [i, i]) for i in range(1, 4)] | ||
result_lst = [f.result() for f in future_lst] | ||
|
||
cache_lst = get_cache_data(cache_directory=cache_directory) | ||
self.assertEqual(sum([c["output"] for c in cache_lst]), sum(result_lst)) | ||
self.assertEqual(sum([sum(c["input_args"][0]) for c in cache_lst]), sum(result_lst)) | ||
|
||
def tearDown(self): | ||
if os.path.exists("cache"): | ||
shutil.rmtree("cache") |