@@ -78,14 +78,15 @@ def handle_input_artifact(name, sign, slices=None, data_root="/tmp",
78
78
path_object = assemble_path_object (art_path )
79
79
path_object = get_slices (path_object , prefix )
80
80
81
- path_object = get_slices (path_object , slices )
82
-
83
81
sign_type = sign .type
84
82
if getattr (sign_type , "__origin__" , None ) == Union :
85
83
args = sign_type .__args__
86
84
if HDF5Datasets in args :
87
- if isinstance (path_object , list ) and all ([isinstance (
88
- p , str ) and p .endswith (".h5" ) for p in path_object ]):
85
+ if isinstance (path_object , list ) and len (path_object ) > 0 and all ([
86
+ isinstance (p , str ) and p .endswith (".h5" )
87
+ for p in path_object ]):
88
+ sign_type = HDF5Datasets
89
+ elif art_path .endswith (".h5" ):
89
90
sign_type = HDF5Datasets
90
91
elif args [0 ] == HDF5Datasets :
91
92
sign_type = args [1 ]
@@ -94,6 +95,8 @@ def handle_input_artifact(name, sign, slices=None, data_root="/tmp",
94
95
95
96
if sign_type == HDF5Datasets :
96
97
import h5py
98
+ if os .path .isfile (art_path ):
99
+ path_object = [art_path ]
97
100
assert isinstance (path_object , list )
98
101
res = None
99
102
for path in path_object :
@@ -108,6 +111,10 @@ def handle_input_artifact(name, sign, slices=None, data_root="/tmp",
108
111
if res is None :
109
112
res = {}
110
113
res .update (datasets )
114
+ res = get_slices (res , slices )
115
+ else :
116
+ path_object = get_slices (path_object , slices )
117
+
111
118
if sign_type in [str , Path ]:
112
119
if path_object is None or isinstance (path_object , str ):
113
120
res = path_object
@@ -146,7 +153,7 @@ def handle_input_artifact(name, sign, slices=None, data_root="/tmp",
146
153
return None
147
154
148
155
_cls = res .__class__
149
- res = artifact_classes [ _cls ] (res )
156
+ res = artifact_classes . get ( _cls , lambda x : x ) (res )
150
157
res .art_root = root
151
158
return res
152
159
@@ -230,6 +237,9 @@ def handle_output_artifact(name, value, sign, slices=None, data_root="/tmp",
230
237
d .attrs ["type" ] = "dir"
231
238
d .attrs ["path" ] = str (v )
232
239
d .attrs ["dtype" ] = "binary"
240
+ elif isinstance (v , HDF5Dataset ):
241
+ d = f .create_dataset (s , data = v .dataset [()])
242
+ d .attrs .update (v .dataset .attrs )
233
243
else :
234
244
d = f .create_dataset (s , data = v )
235
245
d .attrs ["type" ] = "data"
0 commit comments