From 371e78fe4c80dbdf24904112f293cdde90ae5e28 Mon Sep 17 00:00:00 2001 From: vandomej Date: Fri, 8 Mar 2024 17:06:54 -0800 Subject: [PATCH] Update dependencies and remove unused code --- gemla/Cargo.toml | 20 +++++++++--------- gemla/cli.yml | 9 -------- gemla/src/bin/bin.rs | 41 ++++++++++++++++++------------------- gemla/src/constants/args.rs | 2 -- gemla/src/constants/mod.rs | 1 - gemla/src/core/mod.rs | 2 +- gemla/src/lib.rs | 1 - 7 files changed, 31 insertions(+), 45 deletions(-) delete mode 100644 gemla/cli.yml delete mode 100644 gemla/src/constants/args.rs delete mode 100644 gemla/src/constants/mod.rs diff --git a/gemla/Cargo.toml b/gemla/Cargo.toml index 77c42e1..4fc28e1 100644 --- a/gemla/Cargo.toml +++ b/gemla/Cargo.toml @@ -15,18 +15,18 @@ categories = ["simulation"] [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -uuid = { version = "0.8", features = ["serde", "v4"] } -clap = { version = "~2.27.0", features = ["yaml"] } -toml = "0.5.8" +uuid = { version = "1.7", features = ["serde", "v4"] } +clap = { version = "4.5.2", features = ["derive"] } +toml = "0.8.10" regex = "1" file_linked = { version = "0.1.0", path = "../file_linked" } thiserror = "1.0" anyhow = "1.0" -rand = "0.8.4" -log = "0.4.14" -env_logger = "0.9.0" -futures = "0.3.17" -smol = "1.2.5" +rand = "0.8.5" +log = "0.4.21" +env_logger = "0.11.3" +futures = "0.3.30" +smol = "2.0.0" smol-potat = "1.1.2" -num_cpus = "1.13.0" -easy-parallel = "3.1.0" \ No newline at end of file +num_cpus = "1.16.0" +easy-parallel = "3.3.1" diff --git a/gemla/cli.yml b/gemla/cli.yml deleted file mode 100644 index bb8a0cc..0000000 --- a/gemla/cli.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: GEMLA -version: "0.1" -autor: Jacob VanDomelen -about: Uses a genetic algorithm to generate a machine learning algorithm. -args: - - FILE: - help: Sets the input/output file for the program. - required: true - index: 1 \ No newline at end of file diff --git a/gemla/src/bin/bin.rs b/gemla/src/bin/bin.rs index 69bfdac..c12cd33 100644 --- a/gemla/src/bin/bin.rs +++ b/gemla/src/bin/bin.rs @@ -1,4 +1,3 @@ -#[macro_use] extern crate clap; extern crate gemla; #[macro_use] @@ -6,17 +5,23 @@ extern crate log; mod test_state; -use anyhow::anyhow; -use clap::App; use easy_parallel::Parallel; use gemla::{ - constants::args::FILE, core::{Gemla, GemlaConfig}, error::{log_error, Error}, }; use smol::{channel, channel::RecvError, future, Executor}; use std::{path::PathBuf, time::Instant}; use test_state::TestState; +use clap::Parser; + +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Args { + /// The file to read/write the dataset from/to. + #[arg(short, long)] + file: String, +} /// Runs a simluation of a genetic algorithm against a dataset. /// @@ -42,27 +47,21 @@ fn main() -> anyhow::Result<()> { smol::block_on(async { drop(signal); - // Command line arguments are parsed with the clap crate. And this program uses - // the yaml method with clap. - let yaml = load_yaml!("../../cli.yml"); - let matches = App::from_yaml(yaml).get_matches(); + // Command line arguments are parsed with the clap crate. + let args = Args::parse(); // Checking that the first argument is a valid file - if let Some(file_path) = matches.value_of(FILE) { - let mut gemla = log_error(Gemla::::new( - &PathBuf::from(file_path), - GemlaConfig { - generations_per_node: 3, - overwrite: true, - }, - ))?; + let mut gemla = log_error(Gemla::::new( + &PathBuf::from(args.file), + GemlaConfig { + generations_per_node: 3, + overwrite: true, + }, + ))?; - log_error(gemla.simulate(3).await)?; + log_error(gemla.simulate(3).await)?; - Ok(()) - } else { - Err(Error::Other(anyhow!("Invalid argument for FILE"))) - } + Ok(()) }) }); diff --git a/gemla/src/constants/args.rs b/gemla/src/constants/args.rs deleted file mode 100644 index d833fd1..0000000 --- a/gemla/src/constants/args.rs +++ /dev/null @@ -1,2 +0,0 @@ -/// Corresponds to the FILE command line argument used in accordance with the clap crate. -pub const FILE: &str = "FILE"; diff --git a/gemla/src/constants/mod.rs b/gemla/src/constants/mod.rs deleted file mode 100644 index 6e10f4a..0000000 --- a/gemla/src/constants/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod args; diff --git a/gemla/src/core/mod.rs b/gemla/src/core/mod.rs index 7564423..4a75b6c 100644 --- a/gemla/src/core/mod.rs +++ b/gemla/src/core/mod.rs @@ -20,7 +20,7 @@ type SimulationTree = Box>>; /// Provides configuration options for managing a [`Gemla`] object as it executes. /// /// # Examples -/// ``` +/// ```rust,ignore /// #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] /// struct TestState { /// pub score: f64, diff --git a/gemla/src/lib.rs b/gemla/src/lib.rs index 77d1371..d69f277 100644 --- a/gemla/src/lib.rs +++ b/gemla/src/lib.rs @@ -1,5 +1,4 @@ #[macro_use] pub mod tree; -pub mod constants; pub mod core; pub mod error;