elijahbenizzy commented on issue #761:
URL: https://github.com/apache/burr/issues/761#issuecomment-4468208447
Ok so this is a new feature -- you need the ability to *not* reload from
cache on parallel runs. Sequence ID will go up but we don't want that to bust
the cache.
Thinking something like an opt-in flag on the parallel action -- default
keeps current behavior (sub-apps with persisted state get resumed, which is
what enables the retry-on-failure pattern in
`test_end_to_end_parallel_collatz_many_unreliable_tasks`), users explicitly
clobber when they want fresh execution:
```python
class Fan(MapStates):
fresh_each_invocation = True # opt out of resume-from-cache
def states(self, state, context, inputs):
for _ in range(3):
yield state
def action(self, state, inputs):
return create_action(pick, "pick")
def reduce(self, state, results):
return state.update(xs=[s["x"] for s in results])
@property
def reads(self): return []
@property
def writes(self): return ["xs"]
```
Internally, when `fresh_each_invocation` is True, we salt
`task.application_id` at the start of each `run_and_update` with a
per-invocation token (e.g. `uuid.uuid4()` generated right when the parallel
action enters). When False (the default), nothing changes -- deterministic
sub-app IDs stay stable, cascading initializer can still resume in-progress
sub-apps on parent rebuild, retry-on-failure keeps working.
Workaround you already posted
(`hashlib.sha256(f"{task.application_id}:{context.sequence_id}".encode())`) is
essentially this idea but tied to sequence_id, which is why I tripped over it
earlier -- sequence_id increments on parent rebuilds too, so it ends up
clobbering the retry cache. A fresh uuid per `run_and_update` entry sidesteps
that.
Does that match what you had in mind? Or do you want something more
flexible, like a user-defined salt callable so you can pin it to a business key
/ state hash / your own counter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]