Hi, I try to use burr parallelism, but I find both...
# hamilton-help
r
Hi, I try to use burr parallelism, but I find both github example/parallelism and the document are out of date. There are too many differences with 0.34 docstring. I try to fix some problem, but still one confuse me: I pass
inputs
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:
Copy 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)
e
Hey! Good q for the burr discrod as well, but happy to answer it here. We had just fixed a ton of the docstrings/docs to make them up to date — what are some of the differences? Otherwise looking in to see if I can repro
r
Sorry for ask in wrong place, next question I will put it in Burr’s Slack if you have. If you just fix document seconds ago, I will read it hours later. You can reproduce my error by using example I provide — just replace all my code with print. I wan to generate different state with key
molecule
from inputs, and get different datasets.
e
We have a discord — yep I was able to reproduce
Coming up with a fix soon! Willr elease
OK, so not a bug, more just not as well documented. You have to explicitly declare inputs in the class:
Copy code
@property
    def inputs(self) -> list[str]:
        return super().inputs + list(config.keys())
Will update docs (although I thought we did, will see what happened with the docs build…)
r
thx! i will apply it! i am trying to move my old code to Burr. If i have more stupid questions please forgive me!
e
Exciting! Yeah ping us, the discrod is also good
r
may i ask why not use slack as well? my discord account is banned because inactive 🤣
e
heh, it was just the decision we made, the crowd for Burr (more startup-y, AI-focused) was much more excited about discord 🤷
r
sure, see you later in Burr
🫡 1