From 8aa943b0bf953787368f4eccec0e4291fff53d29 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Tue, 29 Jul 2025 11:30:17 +0200 Subject: [PATCH] html io manager --- apps/stocks/src/resources.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 apps/stocks/src/resources.py diff --git a/apps/stocks/src/resources.py b/apps/stocks/src/resources.py new file mode 100644 index 0000000..a6da440 --- /dev/null +++ b/apps/stocks/src/resources.py @@ -0,0 +1,20 @@ +from shared.resources import BaseIOManager +from upath import UPath + +import dagster as dg + + +class HtmlIOManager(BaseIOManager): + extension: str = ".html" # Automatically adds a .json extension + + def dump_to_path( + self, context: dg.OutputContext, obj: object, path: "UPath" + ) -> None: + """This saves the output of an asset to a file path.""" + with path.open("w") as fp: + fp.write(obj) + + def load_from_path(self, context: dg.InputContext, path: "UPath") -> object: + """This loads an input for a downstream asset from a file path.""" + with path.open("r") as fp: + return fp.read()