https://dagster.io/ logo
#ask-community
Title
# ask-community
u

Umar Hussain

02/01/2023, 12:32 AM
Hello lovely community - are there any examples of posting a slack message via a sensor using the
dagster-slack
integration? i.e I have a ~30s sensor that looks for new files in a google drive - when found I'd like to send an alert with some metadata from that sensor before it kicks off a job: I guess another method could be to create an
@op
and add that to my
define_asset_job
selection? (see pic below)
Copy code
@sensor(job=cool_job, , minimum_interval_seconds=30):
def check_for_new_files(context):
    metadata = cool_assets.getmetadata()
    if metadata['new_files'] == True:
      #post message here if possible:
thanks!
z

Zach P

02/01/2023, 2:18 AM
Seems like the easiest way to do this may be to use the resource and just send the message from the op/sda itself
u

Umar Hussain

02/01/2023, 12:49 PM
thanks @Zach P I just didn't want to re-run the
getmetdata()
function twice to grab the same data as it's not passed via the sensor to an OP. Not a major issue but thought I could do it from the sensor 🙂 thanks mate
z

Zach P

02/01/2023, 2:10 PM
No worries, there may be another way of doing it here. I'm so missing the context of the whole sort of way you're planning on using it and that could also change how easy/hard something is :)
👍 1
A good alternative would be to get the sensor you have that detects the files to post to slack via the resources however adding resources to sensors is slightly harder
j

jamie

02/01/2023, 4:30 PM
since we have a
slack_on_failure
sensor you should be able to copy a lot of the code we have in this file for formatting your messages and stuff!
👀 1
🙌 1
u

Umar Hussain

02/01/2023, 6:49 PM
thanks @jamie this is exactly what I needed
6 Views