From bcdf1b22c186737417e3a0b83ace973f52cce7f0 Mon Sep 17 00:00:00 2001 From: Nick Schrock Date: Mon, 9 Oct 2023 09:44:07 -0400 Subject: [PATCH] external asset toy --- .../dagster_test/toys/extenral_assets.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 python_modules/dagster-test/dagster_test/toys/extenral_assets.py diff --git a/python_modules/dagster-test/dagster_test/toys/extenral_assets.py b/python_modules/dagster-test/dagster_test/toys/extenral_assets.py new file mode 100644 index 0000000000000..715f34848fea5 --- /dev/null +++ b/python_modules/dagster-test/dagster_test/toys/extenral_assets.py @@ -0,0 +1,26 @@ +from dagster import AssetMaterialization, AssetSpec, Definitions, OpExecutionContext, job, op +from dagster._core.definitions.external_asset import external_assets_from_specs + +asset_one = AssetSpec("asset_one") + +asset_two = AssetSpec("asset_two", deps=[asset_one]) + + +@op +def insert_materializations(context: OpExecutionContext) -> None: + context.log_event( + AssetMaterialization(asset_one.key, metadata={"nrows": 10, "source": "From this script."}) + ) + context.log_event( + AssetMaterialization(asset_two.key, metadata={"nrows": 12, "source": "From this script."}) + ) + + +@job +def insert_materializations_job() -> None: + insert_materializations() + + +defs = Definitions( + assets=external_assets_from_specs([asset_one, asset_two]), jobs=[insert_materializations_job] +)