Megan Beckett
06/01/2023, 12:45 PMMegan Beckett
06/01/2023, 12:47 PMAbhishek Agrawal
06/01/2023, 12:57 PMdef gen_dbquery_sensor(bq_client, bq_dataset, job_to_run):
@sensor(
job=job_to_run,
name="db_query_sensor"
)
def _sensor():
query = ""
query_job = bigquery_functions.run_query(bq_client=bq_client,dataset=bq_dataset, query=query)
query_job.result()
if <your condition is satisfied>:
yield RunRequest(
run_key=<your_unique_run_id>
)
return _sensor
Megan Beckett
06/01/2023, 1:44 PMgen_dbquery_sensor()
to define the final sensors elsewhere, like in the Definitions
?Abhishek Agrawal
06/01/2023, 2:23 PMMegan Beckett
06/01/2023, 2:29 PMFĂ©lix Tremblay
06/01/2023, 2:53 PMFĂ©lix Tremblay
06/01/2023, 2:59 PMFĂ©lix Tremblay
06/01/2023, 3:02 PMbuild_resources
Megan Beckett
06/05/2023, 9:58 AMbuild_resources
. I provide the config for the resurces at run time with a schedule normally using a yaml file.
I'm going to investigate the new pythonic Resources. Just not sure if it's still possible to only supply the required config to connect to the resource at run time using a yaml file... ie. I don;t think I want to have to provide the resource to the Definitions
as the connection details differ depending on the run required (ie. connecting to different databases).FĂ©lix Tremblay
06/05/2023, 6:31 PMFĂ©lix Tremblay
06/05/2023, 6:33 PMFĂ©lix Tremblay
06/05/2023, 6:38 PMFĂ©lix Tremblay
06/05/2023, 6:43 PMFĂ©lix Tremblay
06/05/2023, 6:46 PMFĂ©lix Tremblay
06/05/2023, 6:47 PMMegan Beckett
06/06/2023, 8:34 AM@schedule(job=update_db_timeseriesdata_dhis2_job, execution_timezone='Africa/Johannesburg', cron_schedule="0 1 28 * *")
def demo_health_timeseriesdata_dev():
return RunRequest(
run_key=None,
run_config=config_from_files(
[
file_relative_path(__file__, "config/demo_health/database_config_dev.yaml"),
file_relative_path(__file__, "config/demo_health/op_config_timeseries.yaml")
]
),
)
There is also op config that is supplied at run time as the op config varies depending on the type of data pull. So, I have just found this the easiest way.
I want to change these to sensors though, rather than schedules. Hence, my questions. But, it looks like a lot of refactoring to move to the new pythonic resources and the tutorial in the Dagster docs for migrating hasn't been that useful as there are several pieces that aren't explained or are not clear to me yet.