Francesco Piccoli
05/15/2023, 6:24 PMjamie
05/15/2023, 6:29 PMop
that can move one file from folder A to folder B, you can set up a sensor that will start a run of the op for every file in folder A
https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#defining-a-sensor
you won’t need to worry about moving files twice, the run_key
in the RunRequest
ensures that duplicate `run_key`s don’t actually get run. It’s described more here https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#idempotence-and-cursorsFrancesco Piccoli
05/15/2023, 6:36 PMFrancesco Piccoli
05/15/2023, 6:46 PMjamie
05/15/2023, 7:14 PMFrancesco Piccoli
05/15/2023, 7:20 PMFrancesco Piccoli
05/15/2023, 9:35 PMjamie
05/16/2023, 2:14 PMclass MoveFolderConfig(Config):
filename: str
current_dir: str
destination_dir: str
@op
def move_file(config: MoveFolderConfig):
# use the attributes of config to copy the file
@job
def move_file_job():
move_file()
@sensor(job=move_file_job)
def move_folders():
folder_pairs = [("A", "B"), ("A1", "B1"), ("A2", "B2")]
for (to, from) in folder_pairs:
for filename in to:
yield RunRequest(
run_key=filename,
run_config={
"ops": {"move_file": {"config": {"filename": filename, "current_dir": to, "destination_dir": from}}}
}
Francesco Piccoli
05/16/2023, 6:53 PMFrancesco Piccoli
05/16/2023, 6:55 PMjamie
05/16/2023, 6:56 PMFrancesco Piccoli
05/16/2023, 6:58 PMrun_config={
"ops": {"move_file":
so where dagter know need to execute a job?jamie
05/16/2023, 6:59 PMjob
parameter of the sensor decorator. the run config is to pass along those configuration values to the move_file
op within the jobFrancesco Piccoli
05/16/2023, 7:03 PMjamie
05/16/2023, 7:04 PMFrancesco Piccoli
05/16/2023, 7:07 PMjamie
05/16/2023, 7:07 PMFrancesco Piccoli
05/16/2023, 7:10 PMFrancesco Piccoli
05/17/2023, 6:12 PMjamie
05/17/2023, 6:13 PMjamie
05/17/2023, 6:13 PMFrancesco Piccoli
05/17/2023, 6:15 PMjamie
05/17/2023, 6:15 PMFrancesco Piccoli
05/17/2023, 6:16 PMjamie
05/17/2023, 6:17 PMFrancesco Piccoli
05/17/2023, 6:22 PMjamie
05/17/2023, 6:23 PMFrancesco Piccoli
05/17/2023, 6:25 PMFrancesco Piccoli
05/17/2023, 7:51 PMjamie
05/17/2023, 7:59 PMFrancesco Piccoli
05/17/2023, 8:07 PMjamie
05/17/2023, 8:08 PMFrancesco Piccoli
05/18/2023, 8:41 AMFrancesco Piccoli
05/18/2023, 8:41 AM