Skip to main content

fpm_rs/tabular/parquet/
manifest.rs

1use std::{collections::BTreeMap, path::PathBuf};
2
3use serde::{Deserialize, Serialize};
4
5use crate::reconstruction::RuntimeInfo;
6
7/// Current reconstruction result-bundle manifest format version.
8pub const BUNDLE_FORMAT_VERSION: u32 = 2;
9
10/// Options controlling result-bundle identity and preview generation.
11#[derive(Clone, Debug, Default)]
12pub struct BundleExportOptions {
13    /// Optional caller-defined unique run ID; a UUID is generated when absent.
14    pub run_id: Option<String>,
15    /// Optional human-readable result label.
16    pub label: Option<String>,
17    /// Whether to write derived PNG previews in addition to lossless arrays and tables.
18    pub include_previews: bool,
19}
20
21#[derive(Clone, Debug, Serialize, Deserialize)]
22#[serde(deny_unknown_fields)]
23pub(crate) struct BundleManifest {
24    pub bundle_format_version: u32,
25    pub run_id: String,
26    pub label: Option<String>,
27    pub crate_version: String,
28    pub provenance: BTreeMap<String, String>,
29    pub dataset: Option<DatasetIdentity>,
30    pub runtime: RuntimeInfo,
31    pub result: ResultDescriptor,
32    pub artifacts: Vec<ManifestArtifact>,
33}
34
35#[derive(Clone, Debug, Serialize, Deserialize)]
36#[serde(deny_unknown_fields)]
37pub(crate) struct DatasetIdentity {
38    pub name: String,
39    pub version: Option<String>,
40}
41
42#[derive(Clone, Debug, Serialize, Deserialize)]
43#[serde(deny_unknown_fields)]
44pub(crate) struct ResultDescriptor {
45    pub reconstruction_shape: [u64; 2],
46    pub image_shape: [u64; 2],
47}
48
49#[derive(Clone, Debug, Serialize, Deserialize)]
50#[serde(deny_unknown_fields)]
51pub(crate) struct ManifestArtifact {
52    pub role: String,
53    pub relative_path: PathBuf,
54    pub media_type: String,
55    pub byte_size: u64,
56    pub sha256: String,
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub dtype: Option<String>,
59    #[serde(default, skip_serializing_if = "Option::is_none")]
60    pub shape: Option<Vec<u64>>,
61}
62
63pub(crate) const TABLE_SUMMARY: &str = "tables.summary";
64pub(crate) const TABLE_HISTORY: &str = "tables.history";
65pub(crate) const TABLE_ALGORITHM_METRICS: &str = "tables.algorithm_metrics";
66pub(crate) const TABLE_ITERATION_DIAGNOSTICS: &str = "tables.iteration_diagnostics";
67pub(crate) const TABLE_FRAME_DIAGNOSTICS: &str = "tables.frame_diagnostics";
68pub(crate) const TABLE_RAW_FRAME_STATISTICS: &str = "tables.raw_frame_statistics";
69pub(crate) const TABLE_FRAME_EVALUATION: &str = "tables.frame_evaluation";
70pub(crate) const TABLE_ILLUMINATION_CALIBRATION: &str = "tables.illumination_calibration";
71pub(crate) const TABLE_FRAME_CALIBRATION: &str = "tables.frame_calibration";
72pub(crate) const TABLE_SCALAR_DIAGNOSTICS: &str = "tables.scalar_diagnostics";
73pub(crate) const TABLE_METADATA: &str = "tables.metadata";
74
75pub(crate) const ARRAY_OBJECT: &str = "arrays.object";
76pub(crate) const ARRAY_OBJECT_SPECTRUM: &str = "arrays.object_spectrum";
77pub(crate) const ARRAY_PUPIL: &str = "arrays.pupil";
78pub(crate) const ARRAY_PUPIL_SUPPORT: &str = "arrays.pupil_support";
79pub(crate) const ARRAY_ILLUMINATION_CALIBRATION: &str = "arrays.illumination_calibration";
80pub(crate) const ARRAY_FRAME_GAINS: &str = "arrays.frame_gains";
81pub(crate) const ARRAY_BACKGROUND: &str = "arrays.background";
82
83pub(crate) const PREVIEW_OBJECT_AMPLITUDE: &str = "previews.object_amplitude";
84pub(crate) const PREVIEW_OBJECT_PHASE: &str = "previews.object_phase";
85pub(crate) const PREVIEW_PUPIL_AMPLITUDE: &str = "previews.pupil_amplitude";
86pub(crate) const PREVIEW_PUPIL_PHASE: &str = "previews.pupil_phase";
87pub(crate) const PREVIEW_FOURIER_COVERAGE: &str = "previews.fourier_coverage";
88
89pub(crate) const DOMAIN_DIAGNOSTICS: &str = "domain.diagnostics";
90pub(crate) const DOMAIN_EVALUATION: &str = "domain.evaluation";
91pub(crate) const DOMAIN_PHYSICAL_ILLUMINATION: &str = "domain.physical_illumination";
92
93pub(crate) const KNOWN_ROLES: &[&str] = &[
94    TABLE_SUMMARY,
95    TABLE_HISTORY,
96    TABLE_ALGORITHM_METRICS,
97    TABLE_ITERATION_DIAGNOSTICS,
98    TABLE_FRAME_DIAGNOSTICS,
99    TABLE_RAW_FRAME_STATISTICS,
100    TABLE_FRAME_EVALUATION,
101    TABLE_ILLUMINATION_CALIBRATION,
102    TABLE_FRAME_CALIBRATION,
103    TABLE_SCALAR_DIAGNOSTICS,
104    TABLE_METADATA,
105    ARRAY_OBJECT,
106    ARRAY_OBJECT_SPECTRUM,
107    ARRAY_PUPIL,
108    ARRAY_PUPIL_SUPPORT,
109    ARRAY_ILLUMINATION_CALIBRATION,
110    ARRAY_FRAME_GAINS,
111    ARRAY_BACKGROUND,
112    PREVIEW_OBJECT_AMPLITUDE,
113    PREVIEW_OBJECT_PHASE,
114    PREVIEW_PUPIL_AMPLITUDE,
115    PREVIEW_PUPIL_PHASE,
116    PREVIEW_FOURIER_COVERAGE,
117    DOMAIN_DIAGNOSTICS,
118    DOMAIN_EVALUATION,
119    DOMAIN_PHYSICAL_ILLUMINATION,
120];