Hi, sorry hopefully this is a quick question. I've...
# singer-tap-development
e
Hi, sorry hopefully this is a quick question. I've been trudging through the docs and slack channel all morning and I seem to have missed it. Where would I be able to call a retry for a stream? The context is that one of my API calls is exporting a file so it returns a status, I'm basically waiting for it to say
status="Finished"
so it can pass the information to the child stream. But in the current chain, the stream immediately gets
status="Processing"
so the child stream ends up not having any information.
a
@edward_chen - Is "retry" a good paradigm for your use case? I'm not sure what token tracking you'd need to perform in this use case and if something like this would work for you?: 1. Use validate_response() to check if status is Finished. 2. Throw RetriableAPIError if not. 3. Customize backoff_handler and backoff_wait_generator() to have the right logic for this use case. In theory this is the "retry" scenario but a completely different approach might be to poll and retry within a loop by overriding request_records().
Let me know what you think of these approaches and maybe I can help point you in the right direction given the approach.
e
ooh thank you, I didn't know about
validate_response()
. Seems like that'd be the perfect use case here. Do you happen to have a code example of it?
Copy code
def validate_response(response: requests.models.Response)→ None
    data = response.json()
    if data["status"] == "Finished":
         # Return data
    raise RetriableAPIError
Does raising the RetriableAPIError automatically cause that specific stream to rerun? EDIT: It looks like raising the error just raises an exception. Sorry I misread, i didn't realize it was steps. I thought you meant one of those options.
For anyone else in the future, there's a code sample of the backoff stuff here: https://sdk.meltano.com/en/latest/code_samples.html#custom-backoff
a
Does raising the RetriableAPIError automatically cause that specific stream to rerun?
Yep! 👍
r
How is the backoff_wait_generator in the code sample implemented? I get an error mentioning that it takes 0 arguments but 1 is given.
a
Hi, Robby. I'm not sure what would cause this personally. Do you mind opening an issue or dropping a new thread in #C01PKLU5D1R. This older than might not have as many eyeballs as we need to help you to an answer.