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

Kevin Haynes

05/19/2022, 3:41 PM
Hi there 👋 I am trying to set up an S3 sensor and I'm definitely doing something wrong but I can't spot it. If a key enters the bucket that isn't just a new folder and isn't in the
processed/
folder, then I want to run
my_job
and give it the name of a SQL script to run. The idea is that we may want to run different scripts depending on the file, but I haven't set that part up yet. When a file is processed, an op copies that file into a
processed/
folder in the same S3 bucket, thus why I want to yield a SkipReason for those files as well. When I turn on this sensor, I'm getting the following error:
Copy code
dagster.check.CheckError: Failure condition: Expected a single SkipReason or one or more RunRequests: received both RunRequest and SkipReason
I'll add the sensor definition in thread (slightly altered to hide my bucket name)
dagster bot responded by community 2
🤖 1
s

Stephen Bailey

05/19/2022, 4:58 PM
within your loop, it looks like it is possible for one key to match the first condition, which yield a
SkipReason
, and the next key to pass all filters and yield a
RunRequest
.
you might want to do something like,
if any(passes_checks(x) for x in new_s3_keys): ...
and have that return your runrequest
k

Kevin Haynes

05/19/2022, 7:18 PM
Okay I see what you're saying. Hmm. I guess what I was trying to account for is when multiple keys get added in the S3 bucket at a time but I only want to run the job for some of the keys and not others. In that case, should I instead just not yield a SkipReason for the keys I don't want, but still yield RunRequests for the keys I do want?
s

Stephen Bailey

05/19/2022, 7:40 PM
yeah, you'll need to just rely on logging those exempted keys if you're going to yield at least one RunRequest, it looks like
i think
SkipReason
is really just for the sensors UI, so you wouldn't actually be seeing anything anyway
k

Kevin Haynes

05/20/2022, 2:19 AM
That did the trick. Thanks a lot for the help!
6 Views