Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions brane-api/src/health.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* TIM */

/* HEALTH.rs
* by Lut99
*
Expand Down Expand Up @@ -27,5 +25,3 @@ pub async fn handle() -> Result<impl Reply, Rejection> {

Ok(response)
}

/*******/
2 changes: 0 additions & 2 deletions brane-cli/src/build_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
4 changes: 0 additions & 4 deletions brane-cli/src/build_ecu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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**
Expand Down
2 changes: 0 additions & 2 deletions brane-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ async fn main() -> Result<()> {
}
}

/// **Edited: now returning CliErrors.**
///
/// Runs one of the subcommand as given on the Cli.
///
/// **Arguments**
Expand Down
12 changes: 0 additions & 12 deletions brane-cli/src/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fn insert_package_in_list(infos: &mut Vec<PackageInfo>, info: PackageInfo) {
// Simply add to the list
infos.push(info);
}
/*******/



Expand Down Expand Up @@ -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**
Expand Down Expand Up @@ -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**
Expand Down Expand Up @@ -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::<Vec<_>>().await?;
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions brane-cli/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -404,7 +401,6 @@ pub async fn push(packages: Vec<(String, Version)>) -> Result<(), RegistryError>
// Done!
Ok(())
}
/*******/

pub async fn search(term: Option<String>) -> Result<()> {
#[derive(GraphQLQuery)]
Expand Down
89 changes: 38 additions & 51 deletions brane-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
14 changes: 0 additions & 14 deletions brane-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ impl Error for DependencyError {}


/***** UTILITIES *****/
/// **Edited: Now returning UtilErrors.**
///
/// Checks the runtime dependencies of brane-cli (Docker + BuildKit)
///
/// **Returns**
Expand All @@ -74,8 +72,6 @@ pub async fn check_dependencies() -> Result<Result<(), DependencyError>, 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?
Expand Down Expand Up @@ -118,8 +114,6 @@ pub fn determine_file(dir: &Path) -> Result<PathBuf, UtilError> {



/// **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**
Expand Down Expand Up @@ -173,8 +167,6 @@ pub fn determine_kind(path: &Path) -> Result<PackageKind, UtilError> {



/// **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**
Expand Down Expand Up @@ -219,8 +211,6 @@ pub fn ensure_config_dir(create: bool) -> Result<PathBuf, UtilError> {
Ok(config_dir)
}

/// **Edited: Now returns UtilErrors.**
///
/// Returns the location of the history file for Brane.
///
/// **Returns**
Expand Down Expand Up @@ -313,8 +303,6 @@ pub fn ensure_data_dir(create: bool) -> Result<PathBuf, UtilError> {
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.
Expand Down Expand Up @@ -411,8 +399,6 @@ pub fn ensure_datasets_dir(create: bool) -> Result<PathBuf, UtilError> {
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.
Expand Down
25 changes: 7 additions & 18 deletions brane-let/src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ pub struct Callback {
}

impl Callback {
/// **Edited: now returning CallbackErrors.**
///
/// Constructor for the Callback.
///
/// **Arguments**
Expand Down Expand Up @@ -97,8 +95,6 @@ impl Callback {
})
}

/// **Edited: now returning CallbackErrors.**
///
/// Performs a callback call to the remote callback.
///
/// **Arguments**
Expand Down Expand Up @@ -133,8 +129,6 @@ impl Callback {
}
}

/// **Edited: now returning CallbackErrors.**
///
/// Sends a Ready callback to the remote callback node.
///
/// **Returns**
Expand All @@ -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**
Expand All @@ -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**
Expand All @@ -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**
Expand All @@ -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**
Expand All @@ -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**
Expand All @@ -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**
Expand Down Expand Up @@ -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**
Expand All @@ -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**
Expand Down
2 changes: 0 additions & 2 deletions brane-let/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
Loading
Loading