Chang Hai Bin
02/09/2023, 10:53 AMAssetMaterialization
outside of a dagit
environment?
@op
def sample_op(context: OpExecutionContext):
context.log_event(AssetMaterialization(
asset_key=["aaa", "bbb", "ccc"]
))
context: OpExecutionContext = build_op_context()
sample_op(context)
print(context.instance.get_event_records(EventRecordsFilter(event_type=DagsterEventType.ASSET_MATERIALIZATION)))
I am running this as a normal Python code (i.e. not using dagit
), and I could not get the context to log the AssetMaterialization. (and the last line returns an empty list)Chang Hai Bin
02/10/2023, 1:08 AM@op
def sample_op(context: OpExecutionContext):
context.log_event(AssetMaterialization(asset_key=["aaa", "bbb", "ccc"]))
return 100
@op
def sample_verification(context: OpExecutionContext, dummy: int):
print(context.instance.get_event_records (EventRecordsFilter (event_type=DagsterEventType.ASSET_MATERIALIZATION)))
@job
def sample_job():
dummy = sample_op()
sample_verification(dummy)
sample_job.execute_in_process()
Chang Hai Bin
02/10/2023, 1:10 AMjob or op