kiran
01/31/2023, 5:06 PM/my_path/.venv/lib/python3.10/site-packages/prefect/utilities/dispatch.py:162: UserWarning: Type 'SlackWebhook' at /my_path/.venv/lib/python3.10/site-packages/prefect_slack/credentials.py:43 has key 'slack-webhook' that matches existing registered type 'SlackWebhook' from /my_path/.venv/lib/python3.10/site-packages/prefect/blocks/notifications.py:83. The existing type will be overridden.
TypeError: Block.__new__() takes 1 positional argument but 2 were given
But the writing here still seems to be like how I’ve been using it (not using a Block). Maybe I missed another documentation update somewhere?
Using:
prefect 2.7.10
prefect-slack 0.1.1Zanie
01/31/2023, 5:12 PMkiran
01/31/2023, 5:15 PM# from prefect.blocks.notifications import SlackWebhook
from prefect_slack import SlackWebhook
but it shows up slightly differently than the other way (from blocks)Andrew Huang
01/31/2023, 5:24 PMkiran
01/31/2023, 5:28 PMZanie
01/31/2023, 5:28 PMAndrew Huang
01/31/2023, 5:30 PMkiran
01/31/2023, 5:30 PMfrom prefect_slack import SlackCredentials
from prefect_slack.messages import send_chat_message
Andrew Huang
01/31/2023, 5:32 PMkiran
01/31/2023, 5:35 PMBlock._new_() takes 1 positional argument but 2 were given
so is there a way around this?Andrew Huang
01/31/2023, 5:35 PMkiran
01/31/2023, 5:38 PMfrom prefect import flow
from prefect.blocks.system import Secret
from prefect_slack import SlackCredentials
from prefect_slack.messages import send_chat_message
@flow
def begin_notify_flow(channel_name: str, flow_name: str):
TOKEN = Secret.load("slack-bot-token").get()
send_chat_message(
slack_credentials=SlackCredentials(TOKEN),
channel=channel_name,
text=f":`{flow_name}` flow run is starting",
)
return
Andrew Huang
01/31/2023, 5:41 PMSlackCredentials(TOKEN)
do you use token=TOKEN
I don’t think you can instantiate blocks without kwargskiran
01/31/2023, 5:42 PMAndrew Huang
01/31/2023, 5:42 PMkiran
01/31/2023, 5:47 PMtoken=TOKEN
worked, when I never had to do it before@kiran
Andrew Huang
01/31/2023, 5:50 PMkiran
01/31/2023, 5:53 PMtoken=TOKEN
and the warning isn’t breaking anything, I think I’ll keep my current way of doing it for nowprefect==2.7.10
. Do you want me to file a new issue about the warning for that? Also, is there an issue template? (np if there’s not — I just want to make sure to use it if it there is, for the slack mentions issue)Andrew Huang
01/31/2023, 6:30 PMkiran
01/31/2023, 6:31 PMAndrew Huang
01/31/2023, 6:33 PMkiran
01/31/2023, 6:34 PM