-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathdata_store.py
35 lines (24 loc) · 993 Bytes
/
data_store.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
In this example, we show case the ability of jobflow to use multiple stores.
Jobs that use additional stores must be run with a JobStore that supports those stores.
"""
from maggma.stores import MemoryStore
from jobflow import JobStore, job, run_locally
@job(data=True)
def generate_big_data():
"""
Generate some data.
The data=True in the job decorator tells jobflow to store all outputs in the "data"
additional store.
"""
return list(range(1000))
big_data_job = generate_big_data()
# in this example, we use different memory stores for the documents and "data"
# additional store. In practice, any Maggma Store subclass can be used for either store.
docs_store = MemoryStore()
data_store = MemoryStore()
store = JobStore(docs_store, additional_stores={"data": data_store})
# Because our job requires an additional store named "data" we have to use our
# custom store when running the job.
output = run_locally(big_data_job, store=store)
print(output)