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

ptus

07/18/2022, 10:59 AM
Hi all! Is there a way to "load" a specific asset data via the
DagsterInstance
and
AssetKey
. What I'm trying to achieve is to have an interactive way to experiment with some defined assets. For example, let's say I have an "iris dataset" asset. I'd now like to have a Jupyer notebook where I could interactively experiment with the "iris asset", without having to re-implement the code that produces it. I have been thinking that connecting to the Dagster instance and somehow loading the asset would be the right way to do this:
Copy code
from dagster import DagsterInstance

instance = DagsterInstance.get()
asset_keys = instance.get_asset_keys()
# would like to "load a specific asset now"
I have also looked into
Dagstermill
, but I didn't find a way to "interactively" load asset data into the notebook. Unless I missed something, it seems that Dagstermill is suited for end-to-end running of notebooks, while I just need a way to load an asset into the notebook, and then interactively experiment wiht it. Thanks all!
dagster bot responded by community 1
It seems that using the "output notebook" produced by a dagstermill asset might be the way to achieve this? If anyone suggests any other way to achieve similar, please do let me know.
z

Zach

07/18/2022, 1:52 PM
If you wanted to do it natively through the Dagster instance I think you'd need to get your asset key and then pass it through whatever IOManager you used to materialize the asset - this is set at runtime so the Dagster instance doesn't really know where the asset is stored, it passes the asset key to the IOManager configured for that run, and the IOManager is responsible for calculating the location of the asset. So it seems like you could instantiate the IOManager you used to materialize the asset and then use its
load_input
method to get your asset if you have the asset key (you'd have to build an input context using
build_input_context
). Alternatively you could add the location of the asset as metadata to your AssetMaterialization or as an AssetObservation, then retrieve the materialization through the graphql assetsOrError endpoint and parse the metadata from that. In fact, I think the default
fs_io_manager
already adds the location as metadata under the
path
label.
s

sandy

07/19/2022, 10:46 PM
+1 to what Zach said. here's an issue where we're tracking adding more native support for this: https://github.com/dagster-io/dagster/issues/4488
2 Views