@@ -217,7 +217,7 @@ def _get_input_tensor(path, name, step, min_shape, data_range, axes, preprocessi
217217 data_range = _get_data_range (data_range , test_in .dtype )
218218 kwargs = {}
219219 if preprocessing is not None :
220- kwargs ["preprocessing" ] = [{ "name" : k , "kwargs" : v } for k , v in preprocessing . items ()]
220+ kwargs ["preprocessing" ] = preprocessing
221221
222222 inputs = model_spec .raw_nodes .InputTensor (
223223 name = "input" if name is None else name ,
@@ -245,7 +245,7 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
245245 data_range = _get_data_range (data_range , test_out .dtype )
246246 kwargs = {}
247247 if postprocessing is not None :
248- kwargs ["postprocessing" ] = [{ "name" : k , "kwargs" : v } for k , v in postprocessing . items ()]
248+ kwargs ["postprocessing" ] = postprocessing
249249 if halo is not None :
250250 kwargs ["halo" ] = halo
251251
@@ -260,9 +260,16 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
260260 return outputs
261261
262262
263- # TODO The citation entry should be improved so that we can properly derive doi vs. url
264- def _build_cite (cite : Dict [str , str ]):
265- citation_list = [spec .rdf .raw_nodes .CiteEntry (text = k , url = v ) for k , v in cite .items ()]
263+ def _build_cite (cite : List [Dict [str , str ]]):
264+ citation_list = []
265+ for entry in cite :
266+ if "doi" in entry :
267+ spec_entry = spec .rdf .raw_nodes .CiteEntry (text = entry ["text" ], doi = entry ["doi" ])
268+ elif "url" in entry :
269+ spec_entry = spec .rdf .raw_nodes .CiteEntry (text = entry ["text" ], url = entry ["url" ])
270+ else :
271+ raise ValueError (f"Expect one of doi or url in citation enrty { entry } " )
272+ citation_list .append (spec_entry )
266273 return citation_list
267274
268275
@@ -346,7 +353,7 @@ def _get_deepimagej_config(
346353 if any (preproc is not None for preproc in preprocessing ):
347354 assert len (preprocessing ) == 1
348355 preprocess_ij = [
349- _get_deepimagej_macro (name , kwargs , export_folder ) for name , kwargs in preprocessing [0 ]. items ()
356+ _get_deepimagej_macro (preproc [ " name" ], preproc [ " kwargs" ] , export_folder ) for preproc in preprocessing [0 ]
350357 ]
351358 attachments = [preproc ["kwargs" ] for preproc in preprocess_ij ]
352359 else :
@@ -356,7 +363,7 @@ def _get_deepimagej_config(
356363 if any (postproc is not None for postproc in postprocessing ):
357364 assert len (postprocessing ) == 1
358365 postprocess_ij = [
359- _get_deepimagej_macro (name , kwargs , export_folder ) for name , kwargs in postprocessing [0 ]. items ()
366+ _get_deepimagej_macro (postproc [ " name" ], postproc [ " kwargs" ] , export_folder ) for postproc in postprocessing [0 ]
360367 ]
361368 if attachments is None :
362369 attachments = [postproc ["kwargs" ] for postproc in postprocess_ij ]
@@ -595,7 +602,7 @@ def build_model(
595602 authors : List [Dict [str , str ]],
596603 tags : List [Union [str , Path ]],
597604 documentation : Union [str , Path ],
598- cite : Dict [str , str ],
605+ cite : List [ Dict [str , str ] ],
599606 output_path : Union [str , Path ],
600607 # model specific optional
601608 architecture : Optional [str ] = None ,
@@ -614,8 +621,8 @@ def build_model(
614621 output_offset : Optional [List [List [int ]]] = None ,
615622 output_data_range : Optional [List [List [Union [int , str ]]]] = None ,
616623 halo : Optional [List [List [int ]]] = None ,
617- preprocessing : Optional [List [Dict [str , Dict [str , Union [int , float , str ]]]]] = None ,
618- postprocessing : Optional [List [Dict [str , Dict [str , Union [int , float , str ]]]]] = None ,
624+ preprocessing : Optional [List [List [ Dict [str , Dict [str , Union [int , float , str ] ]]]]] = None ,
625+ postprocessing : Optional [List [List [ Dict [str , Dict [str , Union [int , float , str ] ]]]]] = None ,
619626 pixel_sizes : Optional [List [Dict [str , float ]]] = None ,
620627 # general optional
621628 maintainers : Optional [List [Dict [str , str ]]] = None ,
@@ -625,7 +632,7 @@ def build_model(
625632 attachments : Optional [Dict [str , Union [str , List [str ]]]] = None ,
626633 packaged_by : Optional [List [str ]] = None ,
627634 run_mode : Optional [str ] = None ,
628- parent : Optional [Tuple [str , str ]] = None ,
635+ parent : Optional [Dict [str , str ]] = None ,
629636 config : Optional [Dict [str , Any ]] = None ,
630637 dependencies : Optional [Union [Path , str ]] = None ,
631638 links : Optional [List [str ]] = None ,
@@ -655,7 +662,7 @@ def build_model(
655662 tags=["segmentation", "light sheet data"],
656663 license="CC-BY-4.0",
657664 documentation="./documentation.md",
658- cite={"Architecture ": "https://my_architecture.com"} ,
665+ cite=[{"text ": "Ronneberger et al. U-Net", "doi": "10.1007/978-3-319-24574-4_28"}] ,
659666 output_path="my-model.zip"
660667 )
661668 ```
@@ -671,7 +678,7 @@ def build_model(
671678 authors: the authors of this model.
672679 tags: list of tags for this model.
673680 documentation: relative file path to markdown documentation for this model.
674- cite: citations for this model.
681+ cite: references for this model.
675682 output_path: where to save the zipped model package.
676683 architecture: the file with the source code for the model architecture and the corresponding class.
677684 Only required for models with pytorch_state_dict weight format.
@@ -701,7 +708,7 @@ def build_model(
701708 attachments: list of additional files to package with the model.
702709 packaged_by: list of authors that have packaged this model.
703710 run_mode: custom run mode for this model.
704- parent: id of the parent model from which this model is derived and sha256 of the corresponding weight file.
711+ parent: id of the parent model from which this model is derived and sha256 of the corresponding rdf file.
705712 config: custom configuration for this model.
706713 dependencies: relative path to file with dependencies for this model.
707714 root: optional root path for relative paths. This can be helpful when building a spec from another model spec.
@@ -882,7 +889,7 @@ def build_model(
882889 kwargs ["maintainers" ] = [model_spec .raw_nodes .Maintainer (** m ) for m in maintainers ]
883890 if parent is not None :
884891 assert len (parent ) == 2
885- kwargs ["parent" ] = { "uri" : parent [ 0 ], "sha256" : parent [ 1 ]}
892+ kwargs ["parent" ] = parent
886893
887894 try :
888895 model = model_spec .raw_nodes .Model (
0 commit comments