Drew You
07/04/2023, 5:52 PMasset, job, and schedule
defined almost exactly according to the partitioned asset tutorials and I'm getting the following error: dagster._core.errors.DagsterInvariantViolationError: Cannot access partition_key for a non-partitioned run
. Code below.Drew You
07/04/2023, 5:52 PM@asset(
required_resource_keys={"duckdb"},
partitions_def=fund_structure_partition,
)
def my_asset(context):
context.partition_key
...
Jacob Marcil
07/04/2023, 5:54 PMJacob Marcil
07/04/2023, 5:56 PMcontext.asset_partition_key_for_output()
Drew You
07/04/2023, 5:56 PMasset_job = define_asset_job(
"asset",
selection=["group/my_asset"],
partitions_def=fund_structure_partition,
)
Drew You
07/04/2023, 5:56 PMJacob Marcil
07/04/2023, 5:57 PMselection=["group/asset"],
should point to the asset name.
if that case group/my_asset
I think.Drew You
07/04/2023, 5:59 PMDrew You
07/04/2023, 6:00 PMmy_asset_schedule = ScheduleDefinition(
job=asset_job,
cron_schedule="*/5 * * * *",
default_status=DefaultScheduleStatus.RUNNING,
)
Jacob Marcil
07/04/2023, 6:02 PMmy_asset_schedule = build_schedule_from_partitioned_job(
asset_job,
default_status=DefaultScheduleStatus.RUNNING,
)
I think you need a partitionned schedule in order to run a partition job. I can be wrong, be using build_schedule_from_partitioned_job()
with all my assets works fine.Drew You
07/04/2023, 6:04 PMDrew You
07/04/2023, 6:05 PMfund_structure_partition = StaticPartitionsDefinition(list(FUND_STRUCTURE.keys()))
Drew You
07/04/2023, 6:05 PMbuild_schedule_from_partitioned_job
only works for `TimeWindowPartition`sJacob Marcil
07/04/2023, 6:10 PMScheduleDefinition
.
Looking at the documentation event with static partitions they configure it by issuing RunRequest
so I think you should try this.
https://docs.dagster.io/concepts/partitions-schedules-sensors/partitions#creating-schedules-from-partitioned-jobs
https://docs.dagster.io/concepts/partitions-schedules-sensors/schedules#schedules-that-provide-custom-run-config-and-tagsJacob Marcil
07/04/2023, 6:12 PM