Skip to content

Commit 81d1240

Browse files
docs: update documentation
1 parent a93ec8f commit 81d1240

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

pre-compute/src/compute/pre_compute_app.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ impl PreComputeAppTrait for PreComputeApp {
3838
/// Runs the complete pre-compute pipeline.
3939
///
4040
/// This method orchestrates the entire pre-compute process:
41-
/// 1. Reads configuration arguments
42-
/// 2. Validates the output folder exists
43-
/// 3. Downloads and decrypts the dataset (if required)
44-
/// 4. Downloads all input files
41+
/// 1. Reads the output directory from environment variable `IEXEC_PRE_COMPUTE_OUT`
42+
/// 2. Reads and validates configuration arguments from environment variables
43+
/// 3. Validates the output folder exists
44+
/// 4. Downloads and decrypts all datasets (if required)
45+
/// 5. Downloads all input files
46+
///
47+
/// The method collects all errors encountered during execution and returns them together,
48+
/// allowing partial completion when possible (e.g., if one dataset fails, others are still processed).
4549
///
4650
/// # Returns
4751
///
4852
/// - `Ok(())` if all operations completed successfully
49-
/// - `Err(ReplicateStatusCause)` if any step failed
53+
/// - `Err(Vec<ReplicateStatusCause>)` containing all errors encountered during execution
5054
///
5155
/// # Example
5256
///
@@ -123,18 +127,19 @@ impl PreComputeAppTrait for PreComputeApp {
123127
/// Downloads the input files listed in `pre_compute_args.input_files` to the specified `output_dir`.
124128
///
125129
/// Each URL is hashed (SHA-256) to generate a unique local filename.
126-
/// If any download fails, the function returns an error.
130+
/// The method continues downloading all files even if some downloads fail.
127131
///
128-
/// # Returns
132+
/// # Behavior
129133
///
130-
/// - `Ok(())` if all files are downloaded successfully.
131-
/// - `Err(ReplicateStatusCause::PreComputeInputFileDownloadFailed(url))` if any file fails to download.
134+
/// - Downloads continue even when individual files fail
135+
/// - Successfully downloaded files are saved with SHA-256 hashed filenames
136+
/// - All download failures are collected and returned together
132137
///
133-
/// # Panics
138+
/// # Returns
134139
///
135-
/// This function panics if:
136-
/// - `pre_compute_args` is `None`.
137-
/// - `chain_task_id` is `None`.
140+
/// - `Ok(())` if all files are downloaded successfully
141+
/// - `Err(Vec<ReplicateStatusCause>)` containing a `PreComputeInputFileDownloadFailed` error
142+
/// for each file that failed to download
138143
fn download_input_files(&self) -> Result<(), Vec<ReplicateStatusCause>> {
139144
let mut exit_causes: Vec<ReplicateStatusCause> = Vec::new();
140145
let args = &self.pre_compute_args;

pre-compute/src/compute/pre_compute_args.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ pub struct PreComputeArgs {
2323
impl PreComputeArgs {
2424
/// Constructs a validated `PreComputeArgs` instance by reading and validating environment variables.
2525
///
26+
/// This method collects all errors encountered during validation instead of failing on the first error,
27+
/// allowing for complete error reporting and partial processing where possible.
28+
///
2629
/// # Environment Variables
2730
/// This method reads the following environment variables:
2831
/// - Required for all tasks:
29-
/// - `IEXEC_PRE_COMPUTE_OUT`: Output directory path
3032
/// - `IEXEC_DATASET_REQUIRED`: Boolean ("true"/"false") indicating dataset requirement
3133
/// - `IEXEC_INPUT_FILES_NUMBER`: Number of input files to load
3234
/// - `IEXEC_BULK_SLICE_SIZE`: Number of bulk datasets (0 means no bulk processing)
@@ -42,22 +44,22 @@ impl PreComputeArgs {
4244
/// - `IEXEC_DATASET_#_KEY`: Dataset decryption key
4345
/// - Input file URLs (`IEXEC_INPUT_FILE_URL_1`, `IEXEC_INPUT_FILE_URL_2`, etc.)
4446
///
45-
/// # Errors
46-
/// Returns `ReplicateStatusCause` error variants for:
47-
/// - Missing required environment variables
48-
/// - Invalid boolean values in `IEXEC_DATASET_REQUIRED`
49-
/// - Invalid numeric format in `IEXEC_INPUT_FILES_NUMBER` or `IEXEC_BULK_SLICE_SIZE`
50-
/// - Missing dataset parameters when required
51-
/// - Missing input file URLs
52-
/// - Missing bulk dataset parameters when bulk processing is enabled
47+
/// # Returns
48+
///
49+
/// Returns a tuple containing:
50+
/// - `PreComputeArgs`: The constructed arguments (with `output_dir` set to empty string)
51+
/// - `Vec<ReplicateStatusCause>`: A vector of all errors encountered (empty if successful)
5352
///
5453
/// # Example
5554
///
5655
/// ```rust
5756
/// use tee_worker_pre_compute::compute::pre_compute_args::PreComputeArgs;
5857
///
59-
/// // Typically called with task ID from execution context
60-
/// let args = PreComputeArgs::read_args();
58+
/// let (mut args, errors) = PreComputeArgs::read_args();
59+
/// if !errors.is_empty() {
60+
/// eprintln!("Encountered {} error(s) while reading arguments", errors.len());
61+
/// }
62+
/// args.output_dir = "/path/to/output".to_string(); // Set output_dir separately
6163
/// ```
6264
pub fn read_args() -> (PreComputeArgs, Vec<ReplicateStatusCause>) {
6365
info!("Starting to read pre-compute arguments from environment variables");

0 commit comments

Comments
 (0)