Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 4 Project Submission #66

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docker_week_3_sensor
  • Loading branch information
ianyoung committed Sep 4, 2022
commit 0213ded7180b283ab1afd5c5b4590af3a425e81f
33 changes: 30 additions & 3 deletions week_3/project/week_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,33 @@ def docker_config():
docker_week_3_schedule = ScheduleDefinition(job=docker_week_3_pipeline, cron_schedule="0 * * * *")


@sensor
def docker_week_3_sensor():
pass
@sensor(
job=docker_week_3_pipeline,
minimum_interval_seconds=30,
description="Check S3 bucket for new files every 30 seconds."
)
def docker_week_3_sensor(context):

# Check for new files in the S3 bucket.
new_files = get_s3_keys(
bucket="dagster",
prefix="prefix",
endpoint_url="http://host.docker.internal:4566"
)

if not new_files:
yield SkipReason("No new s3 files found in bucket.")
return

log = get_dagster_logger()
log.info(f"RunRequest for {new_files}")

# RunRequest for every new file.
for new_file in new_files:
yield RunRequest(
run_key=new_file,
run_config={
"resources": {**docker["resources"]},
"ops": {"get_s3_data": {"config": {"s3_key": new_file}}},
}
)