Hey, I am new to dagger but am really excited to learn. I love that dagger offers strict type enforcement on IO from jobs and caching.
I'm trying to create a dagger function using the python sdk that:
- runs a service that can sometimes fail
- if the service succeeds caching occurs (i dont need to rerun in the future)
- if the service fails caching does not occur (next time i run the job i can retry)
The dumbest way i can describe this with a toy example is something like
@function
async def test_cache(self, low: int, high: float, limit: float) -> float:
data = random.uniform( low,high)
if data < limit:
# if i hit this i dont want caching to occu
raise ValueError( f"{data} < {limit}")
return data
And when I run it from dagger shell multiple times id get :
first try random draws a bad value - no caching because we failed
test_cache 0 10 7
ValueError( 6.234 < 7 )
second try random draws a bad value - no caching because we failed
test_cache 0 10 7
ValueError( 1.111 < 7 )
third try random draws a good value
test_cache 0 10 7
8.54
fourth try just uses the cache because we succeed
test_cache 0 10 7
8.54
Is there a way to achieve what I want?