Roy Kid
12/04/2024, 3:50 PMinputs in app.run(), but can get nothing in states(self, state, context, inputs) but only {'__context': ApplicationContext... . How to fix this? Here is my code:
config = {
"molecules": ['aspirin', 'toluene'],
"instances": 3,
"steps": 1e6,
'batch_size': 10
}
from burr.core import action
@action(reads=[], writes=['single_ds'])
def prepare_data(state: State, molecules: list):
ds = mpot.dataset.rMD17(
molecule=state.molecule,
save_dir=Path(f"./data/{state.molecule}"),
device='cuda',
)
ds.add_process(mpot.process.NeighborList(cutoff=5.0))
return ds, state.update(**{f"single_ds": ds})
class PrepareData(MapStates):
def action(self, state, inputs) -> Action:
return prepare_data
def states(self, state: State, context, inputs:dict) -> Generator[State, None, None]:
for tag in inputs['molecules']:
yield state.update(molecule=tag)
def reduce(self, state: State, results: Generator[State, None, None]) -> State:
all_ds = []
for sub_state in results:
all_ds.append(sub_state["single_ds"])
return state.update(rmd17_ds=all_ds)
@property
def reads(self) -> list[str]:
return []
@property
def writes(self) -> list[str]:
return ['rmd17_ds']
@action(reads=['rmd17_ds'], writes=[])
def print_ds(state: State):
print(state.rmd17_ds)
return state
app = me.Project("rmd17", path="./rmd17").with_actions(
prepare_data=PrepareData(),
print_ds=print_ds
).with_transitions(("prepare_data", "print_ds")).with_entrypoint("prepare_data").build()
app.run(inputs=config)Elijah Ben Izzy
12/04/2024, 4:04 PMRoy Kid
12/04/2024, 4:10 PMmolecule from inputs, and get different datasets.Elijah Ben Izzy
12/04/2024, 4:14 PMElijah Ben Izzy
12/04/2024, 4:14 PMElijah Ben Izzy
12/04/2024, 4:19 PM@property
def inputs(self) -> list[str]:
return super().inputs + list(config.keys())Elijah Ben Izzy
12/04/2024, 4:24 PMRoy Kid
12/04/2024, 4:24 PMElijah Ben Izzy
12/04/2024, 4:24 PMElijah Ben Izzy
12/04/2024, 4:25 PMRoy Kid
12/04/2024, 4:26 PMElijah Ben Izzy
12/04/2024, 4:27 PMRoy Kid
12/04/2024, 4:28 PM