Jérémy Trudel

    Jérémy Trudel

    1 year ago
    Hi folks! I'm wondering if there's a way to code a Task that would be mapped, but initialized only once. I want to map a rollbar task onto a result (list) from a previous task, but ideally I would like to call the rollbar.init() only once. Anyone know how I could do that?
    Kevin Kho

    Kevin Kho

    1 year ago
    Hi @Jérémy Trudel ! Not entirely what you’re trying to do, but are you aware of Unmapped inputs ?
    Jérémy Trudel

    Jérémy Trudel

    1 year ago
    Yes! I'm using an api (rollbar) to send message. One message for each item of a previous task. Normally you initialize rollbar once with an access token within a script
    rollbar.init(access_token)
    I wanted to know if it was possible to have an object that would be mapped (so the run method would be called multiple times), but the
    __init__()
    would be called only once. Does that make sense? I'm trying to avoid having a separate task for initialization, so that the mapped task could be easily reusable in different scripts without always setting up first an initialization unstream task. I hope that makes sense
    Kevin Kho

    Kevin Kho

    1 year ago
    I think I understand. I think the only way this can be done is to split it in different tasks, and pass the rollbar into the mapped call as an
    unmapped
    input. The issue is that I think the rollbar object may be unserializable, and task outputs need to be serializable to be distributable to
    DaskExecutor
    workers.
    Jérémy Trudel

    Jérémy Trudel

    1 year ago
    I see, thank you. I'll try that and if not I'll just make it two separate tasks