Thread
#show-us-what-you-got
    m

    matta

    1 year ago
    Made a new version of the Task that triggers Google Cloud Functions - this one will actually fail if the Cloud Function doesn't work (my last version failed silently)
    @task(max_retries=3, retry_delay=datetime.timedelta(seconds=30))
    def trigger_cloud_fn(secret: PrefectSecret, url: str, body: t.Dict = dict()):
        logger = prefect.context.get("logger")
        <http://logger.info|logger.info>(body)
        credentials = service_account.IDTokenCredentials.from_service_account_info(
            secret, target_audience=url
        )
        authed_session = AuthorizedSession(credentials)
        response = <http://authed_session.post|authed_session.post>(url=url, json=body)
        if not (isinstance(response, requests.models.Response) and response.ok):
            raise signals.FAIL()
        authed_session.close()
        return response
    I think logging the request body is also useful, cuz then you know which ones caused errors!
    Kevin Kho

    Kevin Kho

    1 year ago
    @Marvin archive “Task to Trigger Google Cloud Function”"
    Marvin

    Marvin

    1 year ago