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

Atheer Abdullatif

05/23/2023, 1:22 PM
Hello I am trying to schedule a dbt etl, however i am not able to see the schedule on dagit although the Scheduler deamon is up and running repository.py:
Copy code
from dagster import schedule, AssetSelection, define_asset_job, RunRequest, ScheduleEvaluationContext, repository,  Definitions, load_assets_from_modules
from dagster_dbt import DbtCliClientResource
from mvp_analytics_pipeline import assets
from mvp_analytics_pipeline.assets import DBT_PROFILES, DBT_PROJECT_PATH
from mvp_analytics_pipeline.jobs.etl import  local_job_transform

resources = {
    "dbt": DbtCliClientResource(
        project_dir=DBT_PROJECT_PATH,
        profiles_dir=DBT_PROFILES,
    ),
}

@schedule(job=local_job_transform, cron_schedule="0 0 * * *")
def configurable_job_schedule(context: ScheduleEvaluationContext):
    scheduled_date = context.scheduled_execution_time.strftime("%Y-%m-%d")
    return RunRequest(
        run_key=None,
        run_config={
            "ops": {"configurable_op": {"config": {"scheduled_date": scheduled_date}}}
        },
        tags={"date": scheduled_date},
    )


defs = Definitions(
    jobs=[local_job_transform],
    schedules=[configurable_job_schedule],
    assets=load_assets_from_modules([assets]), resources=resources
)
jobs/etl.py
Copy code
from dagster_dbt import dbt_cli_resource, dbt_run_op

@job(resource_defs={"dbt":dbt_cli_resource})
def local_job_transform():
    dbt_run_op()
assests/__init__.py
Copy code
from dagster_dbt import load_assets_from_dbt_project

from dagster import file_relative_path


DBT_PROJECT_PATH = file_relative_path(__file__, "../../mvp_analytics_dbt")
DBT_PROFILES = file_relative_path(__file__, "../../mvp_analytics_dbt/config")

dbt_assets = load_assets_from_dbt_project(
    project_dir=DBT_PROJECT_PATH, profiles_dir=DBT_PROFILES, key_prefix=["mvp_analytics_dbt"]
)
o

owen

05/23/2023, 5:57 PM
hi @Atheer Abdullatif! This is definitely strange, I can't see a great reason why this wouldn't work. do you mind sharing a screenshot of your UI where you're not seeing the schedule you've defined? on another note, having both
load_assets_from_dbt_project
and
dbt_run_op
is generally not necessary, as
load_assets_from_dbt_project
already allows you to execute those assets. So you could replace your
local_job_transform
job with:
Copy code
from dagster import define_asset_job, AssetSelection

local_job_transform = define_asset_job(
    "local_job_transform",
    selection=AssetSelection.all(),
)
this will create a job that will materialize all of your dbt assets
a

Atheer Abdullatif

05/25/2023, 7:34 AM
the dbt models in my case are being materialised correctly however i am not able to schedule it, i tried your suggestion it didn’t work out, that’s the schedule page
I managed to fix the issue it was due to the fact that i defined my logic inside repo.py instead of “__init__.py”
🌈 1
o

owen

05/25/2023, 4:24 PM
gotcha -- glad you got it working!
❤️ 1
5 Views