Caleb Parnell Lampen
04/27/2023, 10:12 PMbuild_context
helper functions. Using dagster 1.3.1.
My IOManager is subclassing UPathIOManager
, which I think should automatically provide path
to dump_to_path
and load_from_path
that incorporates the asset_key
and the partition_key
. I'm buidling my output context like this:
output_context = build_output_context(
name="abc",
step_key='mystep',
asset_key="myasset_name",
partition_key="my_partition_name",
dagster_type=XarrayDagsterType,
)
input_context = build_input_context(
upstream_output=output_context,
)
And the UPath manager is this:
class XArrayNetcdfIoManager(UPathIOManager):
"""IOmanager that stores xarray as netcdf"""
extension: str = ".nc"
def dump_to_path(self, context: OutputContext, obj:xr.Dataset, path: UPath): #: xr.Dataset,
print(f"path is {path}")
obj.to_netcdf(path, group=MYGROUP)
def load_from_path(self, context: InputContext, path: UPath) -> xr.Dataset:
print(f"path is {path}")
ds = xr.open_dataset(path, group=MYGROUP)
return ds
I set base_path
equal to "iomanager_base_path" for the test. When I tests for manager.handle_output
and manager.load_input
, the print statements say the path for output is "iomanager_base_path/myasset_name.nc" and "iomanager_base_path/__EPHEMERAL_RUN_ID/mystep/abc.nc" respectfully. My questions are:
• Why aren't the paths the same?
• Why isn't the partition key represented?chris
04/27/2023, 10:26 PMasset_key
and partition_key
on the InputContext too hereCaleb Parnell Lampen
04/27/2023, 10:28 PMchris
04/27/2023, 10:29 PMCaleb Parnell Lampen
04/27/2023, 10:33 PMbuild_output_context
can take either an AssetKey
or a str
for the asset_key
argument.. However, build_input_context
requires an AssetKey
object explicitly? Is that true?E dagster._check.ParameterCheckError: Param "asset_key" is not a AssetKey. Got 'myasset_name' which is type <class 'str'>.
AssetKey()
, just counterintuitive.
Great, the output and input functions now have identical paths.
I'm still not seeing the partition key appear in those paths however.test_xarray_iomanager_roundtri0/iomanager_base_path/myasset_name.nc
. Partition is my_partition_name
.chris
04/27/2023, 10:40 PMCaleb Parnell Lampen
04/27/2023, 10:41 PMchris
04/27/2023, 10:58 PMCaleb Parnell Lampen
04/27/2023, 11:07 PM