Skip to content

Commit

Permalink
bug: Fixes deserialization issues with attachments and outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaz-Vieira committed Sep 25, 2024
1 parent ad2e830 commit 0c58bba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bioimg_runtime/src/zoo_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl ZooModel{
.collect::<Result<_, _>>()?;

let attachments: Vec<FileSource> = model_rdf.attachments.into_iter()
.map(|att| match att{
.map(|att| match att.source{
rdf::FileReference::Url(_) => return Err(ModelLoadingError::UrlFileReferenceNotSupportedYet),
rdf::FileReference::Path(fs_path) => {
Ok(FileSource::FileInZipArchive { outer_path: Arc::from(path), inner_path: Arc::from(String::from(fs_path).as_str()) })
Expand Down Expand Up @@ -173,7 +173,7 @@ impl ZooModel {
cov.dump(&mut writer)
}).collect::<Result<Vec<_>, _>>()?;
let attachments = self.attachments.iter().map(|file|{
file.rdf_dump_as_file_reference(&mut writer)
file.dump_as_file_description(&mut writer)
}).collect::<Result<Vec<_>, _>>()?;
let icon: Option<rdf::Icon> = match &self.icon{
Some(icon) => Some(icon.dump(&mut writer)?),
Expand Down
3 changes: 2 additions & 1 deletion bioimg_spec/src/rdf/model/model_rdf_0_5.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::rdf::FileDescription;
use crate::rdf::{
self,
version::Version_0_5_x, Author2, CiteEntry2, CoverImageSource, FileReference, HttpUrl, Icon, LicenseId,
Expand Down Expand Up @@ -31,7 +32,7 @@ pub struct ModelRdfV0_5 {

/// file attachments
#[serde(default)]
pub attachments: Vec<FileReference>,
pub attachments: Vec<FileDescription>,

/// citations
pub cite: NonEmptyList<CiteEntry2>,
Expand Down
5 changes: 5 additions & 0 deletions bioimg_spec/src/rdf/model/output_tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub struct OutputTensorDescr {
}


fn _default_to_output() -> TensorId{
TensorId::try_from("output").unwrap()
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(try_from = "OutputTensorMetadataMsg")]
#[serde(into = "OutputTensorMetadataMsg")]
Expand All @@ -41,6 +45,7 @@ impl OutputTensorMetadata{

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OutputTensorMetadataMsg{
#[serde(default="_default_to_output")]
pub id: TensorId,
#[serde(default)]
pub postprocessing: Vec<PostprocessingDescr>,
Expand Down
1 change: 1 addition & 0 deletions bioimg_spec/src/rdf/model/preprocessing/scale_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub struct ScaleRangeDescr{
/// Epsilon for numeric stability.
/// `out = (tensor - v_lower) / (v_upper - v_lower + eps)`;
/// with `v_lower,v_upper` values at the respective percentiles.
#[serde(default)]
pub eps: PreprocessingEpsilon,

// Tensor name to compute the percentiles from. Default: The tensor itself.
Expand Down

0 comments on commit 0c58bba

Please sign in to comment.