diff --git a/brane-api/src/health.rs b/brane-api/src/health.rs index b5ef8879..c18c7f05 100644 --- a/brane-api/src/health.rs +++ b/brane-api/src/health.rs @@ -1,5 +1,3 @@ -/* TIM */ - /* HEALTH.rs * by Lut99 * @@ -27,5 +25,3 @@ pub async fn handle() -> Result { Ok(response) } - -/*******/ diff --git a/brane-cli/src/build_common.rs b/brane-cli/src/build_common.rs index e2784129..b11448f1 100644 --- a/brane-cli/src/build_common.rs +++ b/brane-cli/src/build_common.rs @@ -51,8 +51,6 @@ pub const BRANELET_URL: &str = /***** COMMON FUNCTIONS *****/ -/// **Edited: now returning BuildErrors. Also leaving .lock removal to the main handle function.** -/// /// Cleans the resulting build directory from the build files (but only if the build files should be removed). /// /// **Arguments** diff --git a/brane-cli/src/build_ecu.rs b/brane-cli/src/build_ecu.rs index 92b0b836..17e2b1e8 100644 --- a/brane-cli/src/build_ecu.rs +++ b/brane-cli/src/build_ecu.rs @@ -172,8 +172,6 @@ async fn build( Ok(()) } -/// **Edited: now returning BuildErrors.** -/// /// Generates a new DockerFile that can be used to build the package into a Docker container. /// /// **Arguments** @@ -277,8 +275,6 @@ fn generate_dockerfile(document: &ContainerInfo, context: &Path, override_branel Ok(contents) } -/// **Edited: now returning BuildErrors.** -/// /// Prepares the build directory for building the package. /// /// **Arguments** diff --git a/brane-cli/src/main.rs b/brane-cli/src/main.rs index 8250f61c..7012df74 100644 --- a/brane-cli/src/main.rs +++ b/brane-cli/src/main.rs @@ -83,8 +83,6 @@ async fn main() -> Result<()> { } } -/// **Edited: now returning CliErrors.** -/// /// Runs one of the subcommand as given on the Cli. /// /// **Arguments** diff --git a/brane-cli/src/packages.rs b/brane-cli/src/packages.rs index 19477563..8338feac 100644 --- a/brane-cli/src/packages.rs +++ b/brane-cli/src/packages.rs @@ -54,7 +54,6 @@ fn insert_package_in_list(infos: &mut Vec, info: PackageInfo) { // Simply add to the list infos.push(info); } -/*******/ @@ -189,9 +188,6 @@ pub fn inspect(name: String, version: Version, syntax: String) -> Result<()> { -/* TIM */ -/// **Edited: updated to deal with get_packages_dir() returning ExecutorErrors. Also added option to only show latest packages and also standard packages.** -/// /// Lists the packages locally build and available. /// use console::style; /// **Arguments** @@ -264,12 +260,9 @@ pub fn list(latest: bool) -> Result<(), PackageError> { table.printstd(); Ok(()) } -/*******/ -/// **Edited: now working with new versions.** -/// /// Loads the given package to the local Docker daemon. /// /// **Arguments** @@ -301,16 +294,13 @@ pub async fn load(name: String, version: Version) -> Result<()> { println!("Image doesn't exist in Docker deamon: importing..."); let options = ImportImageOptions { quiet: true }; - /* TIM */ let file_handle = TFile::open(&image_file).await; if let Err(reason) = file_handle { let code = reason.raw_os_error().unwrap_or(-1); eprintln!("Could not open image file '{}': {}.", image_file.to_string_lossy(), reason); std::process::exit(code); } - // let file = TFile::open(image_file).await?; let file = file_handle.ok().unwrap(); - /*******/ let byte_stream = FramedRead::new(file, BytesCodec::new()).map(|r| r.unwrap().freeze()); let result = docker.import_image_stream(options, byte_stream, None).try_collect::>().await?; @@ -334,8 +324,6 @@ pub async fn load(name: String, version: Version) -> Result<()> { -/// **Edited: now working with new versions.** -/// /// Removes the given list of packages from the local repository. /// /// # Arguments diff --git a/brane-cli/src/registry.rs b/brane-cli/src/registry.rs index cca03d0c..2c6b8b1c 100644 --- a/brane-cli/src/registry.rs +++ b/brane-cli/src/registry.rs @@ -274,9 +274,6 @@ pub async fn pull(packages: Vec<(String, Version)>) -> Result<(), RegistryError> Ok(()) } -/* TIM */ -/// **Edited: the version is now optional.** -/// /// Pushes the given package to the remote instance that we're currently logged into. /// /// **Arguments** @@ -404,7 +401,6 @@ pub async fn push(packages: Vec<(String, Version)>) -> Result<(), RegistryError> // Done! Ok(()) } -/*******/ pub async fn search(term: Option) -> Result<()> { #[derive(GraphQLQuery)] diff --git a/brane-cli/src/run.rs b/brane-cli/src/run.rs index 1fef7472..61be510e 100644 --- a/brane-cli/src/run.rs +++ b/brane-cli/src/run.rs @@ -356,63 +356,50 @@ pub async fn process_instance( // We only print if result != FullValue::Void { println!("\nWorkflow returned value {}", style(format!("'{result}'")).bold().cyan()); + } - // Treat some values special - match result { - // Print sommat additional if it's an intermediate result. - FullValue::IntermediateResult(_) => { - println!("(Intermediate results are not available locally; promote it using 'commit_result()')"); - }, - - // If it's a dataset, attempt to download it - FullValue::Data(name) => { - // Compute the directory to write to - let data_dir: PathBuf = datasets_dir.join(name.to_string()); - - // Fetch a new, local DataIndex to get up-to-date entries - let data_addr: String = format!("{api_endpoint}/data/info"); - let index: DataIndex = match brane_tsk::api::get_data_index(&data_addr).await { - Ok(dindex) => dindex, - Err(err) => { - return Err(Error::RemoteDataIndexError { address: data_addr, err }); - }, - }; + // Treat some values special + match result { + // Print sommat additional if it's an intermediate result. + FullValue::IntermediateResult(_) => { + println!("(Intermediate results are not available locally; promote it using 'commit_result()')"); + }, - // Fetch the method of its availability - let info: &DataInfo = match index.get(&name) { - Some(info) => info, - None => { - return Err(Error::UnknownDataset { name: name.into() }); - }, - }; - let access: AccessKind = match info.access.get(LOCALHOST) { - Some(access) => access.clone(), - None => { - // Attempt to download it instead - match data::download_data(api_endpoint, proxy_addr, certs_dir, data_dir, &name, &info.access).await { - Ok(Some(access)) => access, - Ok(None) => { - return Err(Error::UnavailableDataset { name: name.into(), locs: info.access.keys().cloned().collect() }); - }, - Err(err) => { - return Err(Error::DataDownloadError { err }); - }, - } - }, - }; + // If it's a dataset, attempt to download it + FullValue::Data(name) => { + // Compute the directory to write to + let data_dir: PathBuf = datasets_dir.join(name.to_string()); + + // Fetch a new, local DataIndex to get up-to-date entries + let data_addr: String = format!("{api_endpoint}/data/info"); + let index: DataIndex = + brane_tsk::api::get_data_index(&data_addr).await.map_err(|err| Error::RemoteDataIndexError { address: data_addr, err })?; + + // Fetch the method of its availability + let info: &DataInfo = index.get(&name).ok_or_else(|| Error::UnknownDataset { name: name.clone().into() })?; + + let access: AccessKind = match info.access.get(LOCALHOST).cloned() { + Some(access) => access, + None => { + // Attempt to download it instead + data::download_data(api_endpoint, proxy_addr, certs_dir, data_dir, &name, &info.access) + .await + .map_err(|source| Error::DataDownloadError { err: source })? + .ok_or_else(|| Error::UnavailableDataset { name: name.into(), locs: info.access.keys().cloned().collect() })? + }, + }; - // Write the method of access - match access { - AccessKind::File { path } => println!("(It's available under '{}')", path.display()), - } - }, + // Write the method of access + match access { + AccessKind::File { path } => println!("(It's available under '{}')", path.display()), + } + }, - // Nothing for the rest - _ => {}, - } + // Nothing for the rest + _ => {}, } - // DOne + // Done Ok(()) } diff --git a/brane-cli/src/utils.rs b/brane-cli/src/utils.rs index 5fb6c298..7c1e70e6 100644 --- a/brane-cli/src/utils.rs +++ b/brane-cli/src/utils.rs @@ -61,8 +61,6 @@ impl Error for DependencyError {} /***** UTILITIES *****/ -/// **Edited: Now returning UtilErrors.** -/// /// Checks the runtime dependencies of brane-cli (Docker + BuildKit) /// /// **Returns** @@ -74,8 +72,6 @@ pub async fn check_dependencies() -> Result, UtilErr -/// **Edited: now returning CliErrors.** -/// /// Tries to determine the package file in the pulled repository. /// /// TODO: This is rather dumb, why does it not just check the contents of the file? @@ -118,8 +114,6 @@ pub fn determine_file(dir: &Path) -> Result { -/// **Edited: not taking a context anymore, returning CliErrors and a PackageKind instead of a string.** -/// /// Tries to deduce the package kind from the given file. /// /// **Arguments** @@ -173,8 +167,6 @@ pub fn determine_kind(path: &Path) -> Result { -/// **Edited: uses dirs instead of appdirs and returns UtilErrors when it goes wrong.** -/// /// Returns the path of the configuration directory. Is guaranteed to be an absolute path when it returns successfully (but _not_ that it also exists!). /// /// **Returns** @@ -219,8 +211,6 @@ pub fn ensure_config_dir(create: bool) -> Result { Ok(config_dir) } -/// **Edited: Now returns UtilErrors.** -/// /// Returns the location of the history file for Brane. /// /// **Returns** @@ -313,8 +303,6 @@ pub fn ensure_data_dir(create: bool) -> Result { Ok(data_dir) } -/// **Edited: Changed to return UtilErrors.** -/// /// Returns the general package directory based on the user's home folder. /// Basically, tries to resolve the folder '~/.local/share/brane/packages`. /// Note that this does not mean that this directory exists. @@ -411,8 +399,6 @@ pub fn ensure_datasets_dir(create: bool) -> Result { Ok(data_dir) } -/// **Edited: Now returning UtilErrors.** -/// /// Gets the directory where we likely stored the package. /// If the given version is omitted, just returns the package directory for this name. /// If the given version is latest, tries to find the latest version directory to return that; otherwise, errors that there are no versions to choose from. diff --git a/brane-let/src/callback.rs b/brane-let/src/callback.rs index c8f69e74..dc873711 100644 --- a/brane-let/src/callback.rs +++ b/brane-let/src/callback.rs @@ -59,8 +59,6 @@ pub struct Callback { } impl Callback { - /// **Edited: now returning CallbackErrors.** - /// /// Constructor for the Callback. /// /// **Arguments** @@ -97,8 +95,6 @@ impl Callback { }) } - /// **Edited: now returning CallbackErrors.** - /// /// Performs a callback call to the remote callback. /// /// **Arguments** @@ -133,8 +129,6 @@ impl Callback { } } - /// **Edited: now returning CallbackErrors.** - /// /// Sends a Ready callback to the remote callback node. /// /// **Returns** @@ -155,8 +149,7 @@ impl Callback { pub async fn initialize_failed(&mut self, err: String) -> Result<(), CallbackError> { self.call(CallbackKind::InitializeFailed, Some(err.as_bytes().to_vec())).await } - /// **Edited: now returning CallbackErrors.** - /// + /// Sends an Initialized callback to the remote callback node. /// /// **Returns** @@ -177,8 +170,7 @@ impl Callback { pub async fn start_failed(&mut self, err: String) -> Result<(), CallbackError> { self.call(CallbackKind::StartFailed, Some(err.as_bytes().to_vec())).await } - /// **Edited: now returning CallbackErrors.** - /// + /// Sends a Started callback to the remote callback node. /// /// **Returns** @@ -188,8 +180,6 @@ impl Callback { self.call(CallbackKind::Started, None).await } - /// **Edited: now returning CallbackErrors.** - /// /// Sends a Heartbeat callback to the remote callback node. /// /// **Returns** @@ -198,6 +188,7 @@ impl Callback { pub async fn heartbeat(&mut self) -> Result<(), CallbackError> { self.call(CallbackKind::Heartbeat, None).await } + /// Sends a CompleteFailed callback to the remote callback node. /// /// **Arguments** @@ -209,6 +200,7 @@ impl Callback { pub async fn complete_failed(&mut self, err: String) -> Result<(), CallbackError> { self.call(CallbackKind::CompleteFailed, Some(err.as_bytes().to_vec())).await } + /// Sends a Completed callback to the remote callback node. /// /// **Returns** @@ -229,8 +221,7 @@ impl Callback { pub async fn decode_failed(&mut self, err: String) -> Result<(), CallbackError> { self.call(CallbackKind::DecodeFailed, Some(err.as_bytes().to_vec())).await } - /// **Edited: now returning CallbackErrors.** - /// + /// Sends a Stopped callback to the remote callback node. /// /// **Arguments** @@ -259,8 +250,7 @@ impl Callback { // Write the string version of the signal self.call(CallbackKind::Stopped, Some(signal_name.as_bytes().to_vec())).await } - /// **Edited: now returning CallbackErrors.** - /// + /// Sends a Failed callback to the remote callback node. /// /// **Arguments** @@ -281,8 +271,7 @@ impl Callback { // Perform the call self.call(CallbackKind::Failed, Some(payload)).await } - /// **Edited: now returning CallbackErrors.** - /// + /// Sends a Finished callback to the remote callback node. /// /// **Arguments** diff --git a/brane-let/src/common.rs b/brane-let/src/common.rs index ac79b95b..20ea6499 100644 --- a/brane-let/src/common.rs +++ b/brane-let/src/common.rs @@ -95,8 +95,6 @@ fn assert_type(got: &DataType, expected: &DataType) -> bool { /***** INITIALIZATION *****/ -/// **Edited: now returning LetErrors.** -/// /// Tries to confirm that what we're told to put in the function is the same as the function accepts. /// /// **Arguments** diff --git a/brane-let/src/exec_ecu.rs b/brane-let/src/exec_ecu.rs index 14439b88..50b9c985 100644 --- a/brane-let/src/exec_ecu.rs +++ b/brane-let/src/exec_ecu.rs @@ -45,8 +45,6 @@ const PREFIX: &str = "~~>"; /***** ENTRYPOINT *****/ -/// **Edited: working with new callback interface + events.** -/// /// Handles a package containing ExeCUtable code (ECU). /// /// **Arguments** @@ -140,8 +138,6 @@ pub async fn handle( /***** INITIALIZATION *****/ -/// **Edited: returning LetErrors + now also doing the steps before the specific working dir initialization.** -/// /// Initializes the environment for the nested package by reading the container.yml and preparing the working directory. /// /// **Arguments** @@ -277,8 +273,6 @@ fn start( Ok((command, process)) } -/// **Edited: now returning LetErrors.** -/// /// Creates a map with enviroment variables for the nested package based on the given arguments. /// /// **Arguments** @@ -490,8 +484,6 @@ async fn complete( Ok(PackageReturnState::Finished { stdout }) } -/// **Edited: returns LetErrors + changed to accept string instead of split stuff.** -/// /// Preprocesses stdout by only leaving the stuff that is relevant for the branelet (i.e., only that which is marked as captured by the mode). /// /// **Arguments** diff --git a/brane-let/src/main.rs b/brane-let/src/main.rs index e93d5597..67925cbc 100644 --- a/brane-let/src/main.rs +++ b/brane-let/src/main.rs @@ -146,8 +146,6 @@ async fn main() { } } -/// **Edited: instantiating callback earlier, updated callback policy (new callback interface + new events). Also returning LetErrors.** -/// /// Runs the job that this branelet is in charge of. /// /// **Arguments** @@ -247,8 +245,6 @@ async fn run( } } -/// **Edited: now returning LetErrors.** -/// /// Decodes the given base64 string as JSON to the desired output type. /// /// **Arguments** diff --git a/brane-shr/src/jobs.rs b/brane-shr/src/jobs.rs index 596f5f8b..e866e518 100644 --- a/brane-shr/src/jobs.rs +++ b/brane-shr/src/jobs.rs @@ -14,8 +14,6 @@ // -/// **Edited: added comments + synced with new events.** -/// /// Lists the possible states that a job can have from the brane-drv perspective. #[repr(u8)] #[derive(Debug, Clone, Eq, PartialEq)] @@ -122,4 +120,3 @@ impl JobStatus { impl PartialEq<&JobStatus> for JobStatus { fn eq(&self, other: &&JobStatus) -> bool { self == *other } } -/*******/ diff --git a/specifications/src/common.rs b/specifications/src/common.rs index 37c276f9..cfcbc7e7 100644 --- a/specifications/src/common.rs +++ b/specifications/src/common.rs @@ -379,11 +379,9 @@ pub struct FunctionExt { pub version: Version, } -/* TIM */ impl std::fmt::Display for FunctionExt { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "@{}()", self.name) } } -/*******/ diff --git a/specifications/src/container.rs b/specifications/src/container.rs index 57a0985b..94f8aa52 100644 --- a/specifications/src/container.rs +++ b/specifications/src/container.rs @@ -524,7 +524,7 @@ pub struct ContainerInfo { } impl ContainerInfo { - /// Returns a `ContainerInfo` by constructing it from the file at the given path. +/// Returns a `ContainerInfo` by constructing it from the file at the given path. /// /// **Generic types** /// * `P`: The Path-like type of the given target location. diff --git a/specifications/src/package.rs b/specifications/src/package.rs index c222fdd2..c55c32fd 100644 --- a/specifications/src/package.rs +++ b/specifications/src/package.rs @@ -338,9 +338,7 @@ impl PackageInfo { PackageInfo { created, id, digest: None, name, version, kind, owners, description, detached, functions, types } } - /// **Edited: changed to return appropriate errors. Also added docstring.** - /// - /// Constructor for the `PackageInfo` that tries to construct it from the file at the given location. + /// Constructor for the PackageInfo that tries to construct it from the file at the given location. /// /// **Arguments** /// * `path`: The path to load. @@ -364,9 +362,7 @@ impl PackageInfo { } } - /// **Edited: changed to return appropriate errors. Also added docstring.** - /// - /// Constructor for the `PackageInfo` that tries to deserialize it. + /// Constructor for the PackageInfo that tries to deserialize it. /// /// **Arguments** /// * `contents`: The string that contains the contents for the `PackageInfo`. @@ -569,7 +565,15 @@ impl PackageIndex { PackageIndex::from_reader(buf_reader) } +<<<<<<< HEAD /// Tries to construct a new `PackageIndex` from the given reader. +||||||| parent of e08ed90b (chore: Remove old redundant comments) + /// **Edited: Returns PackageIndexErrors now.** + /// + /// Tries to construct a new PackageIndex from the given reader. +======= + /// Tries to construct a new PackageIndex from the given reader. +>>>>>>> e08ed90b (chore: Remove old redundant comments) /// /// **Arguments** /// * `r`: The reader that contains the data to construct the `PackageIndex` from. @@ -589,7 +593,15 @@ impl PackageIndex { PackageIndex::from_value(v) } +<<<<<<< HEAD /// Tries to construct a new `PackageIndex` from a JSON file at the given URL. +||||||| parent of e08ed90b (chore: Remove old redundant comments) + /// **Edited: Returns PackageIndexErrors now.** + /// + /// Tries to construct a new PackageIndex from a JSON file at the given URL. +======= + /// Tries to construct a new PackageIndex from a JSON file at the given URL. +>>>>>>> e08ed90b (chore: Remove old redundant comments) /// /// **Arguments** /// * `url`: The location of the JSON file to parse. @@ -621,7 +633,15 @@ impl PackageIndex { PackageIndex::from_value(json) } +<<<<<<< HEAD /// Tries to construct a new `PackageIndex` from the given JSON-parsed value. +||||||| parent of e08ed90b (chore: Remove old redundant comments) + /// **Edited: Returns PackageIndexErrors now.** + /// + /// Tries to construct a new PackageIndex from the given JSON-parsed value. +======= + /// Tries to construct a new PackageIndex from the given JSON-parsed value. +>>>>>>> e08ed90b (chore: Remove old redundant comments) /// /// **Arguments** /// * `v`: The JSON root value of the tree to parse. @@ -641,7 +661,15 @@ impl PackageIndex { PackageIndex::from_packages(known_packages) } +<<<<<<< HEAD /// Tries to construct a new `PackageIndex` from a list of [`PackageInfo`]s. +||||||| parent of e08ed90b (chore: Remove old redundant comments) + /// **Edited: Returns PackageIndexErrors now.** + /// + /// Tries to construct a new PackageIndex from a list of PackageInfos. +======= + /// Tries to construct a new PackageIndex from a list of PackageInfos. +>>>>>>> e08ed90b (chore: Remove old redundant comments) /// /// **Arguments** /// * `known_packages`: List of [`PackageInfo`]s to incorporate in the `PackageIndex`.