### Example `config.toml` Configuration File Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Defines various project settings including migration environment details, data paths, logging levels, validation tolerances, and performance benchmarking parameters. This file centralizes project-wide configurations. ```TOML [migration] python_env = "neuro-migration-env" data_path = "./data" output_path = "./output" log_level = "info" [validation] tolerance = 1e-6 max_samples = 10000 enable_plotting = true [performance] benchmark_iterations = 100 warmup_iterations = 10 timeout_seconds = 300 ``` -------------------------------- ### Install Rust Toolchain on Windows Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Installs the Rust toolchain on Windows using `winget`, a package manager. Alternatively, users can download and run the `rustup-init.exe` installer from the official Rustup website. The installation is verified by checking the `rustc` and `cargo` versions. ```powershell winget install Rust.Rustup rustc --version cargo --version ``` -------------------------------- ### Install neuro-divergent from Source Repository Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Clones the `neuro-divergent` Git repository to a local directory. It then builds the project in release mode for optimized performance, runs the project's tests to verify functionality, and optionally installs the compiled binary to the Cargo bin directory, making it globally accessible. ```bash git clone https://github.com/your-org/neuro-divergent.git cd neuro-divergent cargo build --release cargo test cargo install --path . ``` -------------------------------- ### Create New Rust Migration Project Structure Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Initializes a new Rust binary project named `neuro-forecast-migration` using `cargo new`. It then navigates into the newly created project directory and sets up a standard directory structure, including folders for models, data, utilities, examples, tests, raw data, notebooks, and scripts, to organize the migration project. ```bash cargo new neuro-forecast-migration --bin cd neuro-forecast-migration mkdir -p {src/models,src/data,src/utils,examples,tests,data,notebooks,scripts} ``` -------------------------------- ### Verify Python NeuralForecast Setup Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md This snippet verifies the Python environment by checking installed versions of NeuralForecast, Pandas, and NumPy, and then tests basic model instantiation using NeuralForecast's LSTM model to confirm a successful setup. ```python import neuralforecast import pandas as pd import numpy as np def verify_python_setup(): print(f"NeuralForecast version: {neuralforecast.__version__}") print(f"Pandas version: {pd.__version__}") print(f"NumPy version: {np.__version__}") # Test basic functionality from neuralforecast.models import LSTM model = LSTM(h=12, input_size=24) print("✅ Python NeuralForecast setup verified") if __name__ == '__main__': verify_python_setup() ``` -------------------------------- ### Install neuro-divergent using Cargo Install Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Installs the `neuro-divergent` crate directly from its Git repository using `cargo install`. This method compiles and installs the binary to the Cargo bin directory. Alternatively, once published, it can be installed directly from `crates.io`. ```bash cargo install --git https://github.com/your-org/neuro-divergent.git # Or from crates.io when published cargo install neuro-divergent ``` -------------------------------- ### Install Rust Toolchain on Linux/macOS Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Installs `rustup`, the official Rust toolchain installer, on Linux or macOS systems. It then reloads the shell environment to make `cargo` and `rustc` available and verifies the installation by checking their versions. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env rustc --version cargo --version ``` -------------------------------- ### Set Up Neuro-Divergent Development Environment Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Instructions for setting up a local development environment for the Neuro-Divergent project. This includes cloning the repository, installing essential development tools like `cargo-watch`, `cargo-expand`, and `cargo-criterion`, and commands for running tests and benchmarks. ```bash git clone https://github.com/your-org/neuro-divergent.git cd neuro-divergent cargo install cargo-watch cargo-expand cargo-criterion cargo test --all-features cargo bench cargo watch -x "test --all-features" ``` -------------------------------- ### Verify Rust Project Installation and Health Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Provides a series of `cargo` commands to verify the Rust toolchain installation and check the overall health of the project. This includes checking compiler and cargo versions, compiling the project, running tests, executing benchmarks, checking code formatting, and performing linting with `clippy`. ```Bash # Verify Rust installation rustc --version cargo --version # Verify neuro-divergent cargo check # Run basic tests cargo test --lib # Benchmark performance cargo bench # Check formatting cargo fmt --check # Run linting cargo clippy ``` -------------------------------- ### Example CSV Format for Time Series Data Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Provides an example of the expected CSV file structure for loading time series data, including 'date', 'sales', and 'category' columns. ```csv date,sales,category 2023-01-01,1250.5,electronics 2023-01-02,1340.2,electronics 2023-01-03,1180.7,electronics ... ``` -------------------------------- ### Build Neuro-Divergent from Source Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Instructions to clone the Neuro-Divergent repository from GitHub and build it locally in release mode, suitable for development or custom installations. ```bash git clone https://github.com/your-org/neuro-divergent.git cd neuro-divergent cargo build --release ``` -------------------------------- ### Install Python Migration and Tracking Utilities Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Installs additional Python libraries crucial for data analysis, visualization, and experiment tracking within the migration workflow. This includes `pandas-profiling` and `ydata-profiling` for data quality reports, `plotly` and `dash` for interactive visualizations, and `mlflow` and `wandb` for experiment tracking and model management. ```bash pip install pandas-profiling ydata-profiling pip install plotly dash pip install mlflow wandb ``` -------------------------------- ### VS Code `launch.json` for Debugging Rust Binaries Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Sets up a VS Code launch configuration using `CodeLLDB` to debug a Rust binary named 'migrate'. It specifies the cargo build arguments, filters for the correct binary, passes `--help` as an argument, and sets the current working directory. ```JSON { "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Debug Migration Tool", "cargo": { "args": ["build", "--bin=migrate"], "filter": { "name": "migrate", "kind": "bin" } }, "args": ["--help"], "cwd": "${workspaceFolder}" } ] } ``` -------------------------------- ### Install Neuro-Divergent on Windows Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Guide for installing Rust and Neuro-Divergent on Windows, covering prerequisites like Visual Studio Build Tools and NVIDIA CUDA Toolkit, and enabling GPU/async features. ```bash # Install Rust # Download and run rustup-init.exe from https://rustup.rs/ # Install Visual Studio Build Tools # Download from Microsoft website # For GPU support # Install CUDA Toolkit 11.0+ from NVIDIA # Add to Cargo.toml and build cargo add neuro-divergent --features="gpu,async" cargo build ``` -------------------------------- ### Serve Forecasting Model via HTTP API with Warp in Rust Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Provides an example of setting up a basic HTTP API endpoint using the `warp` web framework to serve a trained forecasting model, handling POST requests for predictions. ```rust use warp::Filter; let model = Arc::new(nf); let predict_route = warp::path("predict") .and(warp::post()) .and(warp::body::json()) .and(with_model(model.clone())) .and_then(handle_prediction); warp::serve(predict_route) .run(([127, 0, 0, 1], 3030)) .await; ``` -------------------------------- ### Setup Python Validation Environment Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Provides a sequence of Bash commands to create a directory structure for validation scripts and set up a Python virtual environment. It then activates the environment and installs necessary Python libraries like `neuralforecast`, `pandas`, `numpy`, and `matplotlib`. ```Bash # Create validation scripts directory mkdir -p validation/{python,rust,comparison} # Set up Python validation environment cd validation/python python -m venv venv source venv/bin/activate pip install neuralforecast pandas numpy matplotlib ``` -------------------------------- ### Run Neuro-Divergent Forecast Application Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Executes the compiled Rust application, initiating the neural forecast process as defined in the 'src/main.rs' file. ```Bash cargo run ``` -------------------------------- ### Resolve Linker Errors on Linux Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Commands to install necessary build tools and libraries (like `build-essential`, `pkg-config`, `libssl-dev`, `clang`, `lld`) to fix linker errors on Linux systems, specifically for Ubuntu/Debian distributions. ```bash sudo apt-get install build-essential pkg-config libssl-dev sudo apt-get install clang lld ``` -------------------------------- ### Install CUDA Toolkit on Ubuntu 20.04 Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Provides a sequence of shell commands to install the CUDA Toolkit (version 11.8) on Ubuntu 20.04. This includes downloading the repository pin and deb package, installing it, copying GPG keys, updating apt, and finally installing CUDA. It also shows how to add CUDA paths to `~/.bashrc`. ```Bash # Install CUDA toolkit wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb sudo cp /var/cuda-repo-ubuntu2004-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get update sudo apt-get -y install cuda # Add to ~/.bashrc export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} ``` -------------------------------- ### Optimize Rust Performance Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Commands to build Rust projects in release mode (`cargo build --release`) and configure environment variables for optimized profiles (`CARGO_PROFILE_RELEASE_OPT_LEVEL`, `CARGO_PROFILE_RELEASE_LTO`) to significantly improve application performance. ```bash cargo build --release export CARGO_PROFILE_RELEASE_OPT_LEVEL=3 export CARGO_PROFILE_RELEASE_LTO=true ``` -------------------------------- ### Verify Rust Neuro-Divergent Setup Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md This snippet verifies the Rust environment by testing the creation of an LSTM model using the `neuro-divergent` crate and demonstrating basic data frame creation with `polars`, ensuring the core components are functional. ```rust use neuro_divergent::models::LSTM; use polars::prelude::*; fn main() -> anyhow::Result<()> { println!("Verifying neuro-divergent setup..."); // Test basic model creation let model = LSTM::builder() .horizon(12) .input_size(24) .build()?; println!("✅ Model created successfully"); // Test data loading let df = df! [ "ds" => ["2023-01-01", "2023-01-02", "2023-01-03"], "unique_id" => ["series1", "series1", "series1"], "y" => [1.0, 2.0, 3.0] ]?; println!("✅ Data frame created successfully"); println!("✅ neuro-divergent setup verified"); Ok(()) } ``` -------------------------------- ### Set Up Python Virtual Environment for Migration Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Creates and activates a dedicated Python virtual environment named `neuro-migration-env` to isolate project dependencies. It then installs core data science and machine learning libraries, including `neuralforecast`, `pandas`, `polars`, `pyarrow`, `numpy`, `matplotlib`, `seaborn`, `jupyter`, and `ipykernel`, essential for validation and migration utilities. ```bash python -m venv neuro-migration-env source neuro-migration-env/bin/activate pip install neuralforecast pandas polars pyarrow numpy matplotlib seaborn pip install jupyter notebook ipykernel ``` ```powershell neuro-migration-env\Scripts\activate.bat pip install neuralforecast pandas polars pyarrow numpy matplotlib seaborn pip install jupyter notebook ipykernel ``` -------------------------------- ### Diagnose GPU Issues Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Commands to check CUDA installation (`nvidia-smi`, `nvcc --version`) and verify GPU features using `cargo test` with the `gpu` feature, aiding in the diagnosis of GPU-related problems. ```bash nvidia-smi nvcc --version cargo test --features gpu ``` -------------------------------- ### Neural Network Configuration File Examples Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/configuration-mapping.md Examples of configuration files for neural network training, demonstrating how similar parameters are structured in YAML (Python) and TOML (Rust) formats. This highlights the syntax differences for data, model, training, and logging settings across languages. ```YAML # Python NeuralForecast Configuration data: path: "./data/timeseries.csv" freq: "D" static_features: ["category", "region"] future_features: ["holidays", "weather"] models: LSTM: h: 12 input_size: 24 hidden_size: 128 num_layers: 2 dropout: 0.1 learning_rate: 0.001 max_steps: 1000 batch_size: 32 NBEATS: h: 12 input_size: 24 stack_types: ["trend", "seasonality"] n_blocks: [3, 3] training: early_stopping: patience: 50 min_delta: 0.001 validation: split: 0.2 shuffle: false logging: level: "INFO" file: "./logs/training.log" ``` ```TOML # Rust neuro-divergent Configuration [data] path = "./data/timeseries.csv" frequency = "Daily" static_features = ["category", "region"] future_features = ["holidays", "weather"] [models.lstm] horizon = 12 input_size = 24 hidden_size = 128 num_layers = 2 dropout = 0.1 learning_rate = 0.001 max_steps = 1000 batch_size = 32 [models.nbeats] horizon = 12 input_size = 24 stack_types = ["trend", "seasonality"] n_blocks = [3, 3] [training] early_stopping_patience = 50 early_stopping_min_delta = 0.001 validation_split = 0.2 validation_shuffle = false [logging] level = "info" file = "./logs/training.log" ``` -------------------------------- ### Configure Application Logging Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/configuration-mapping.md This snippet demonstrates how to set up logging for the application. It includes configurations for console and file handlers, defining log levels and formats. The Python example uses the standard `logging` module, while the Rust example uses `tracing` and `tracing-subscriber` for initialization and usage. ```python import logging logging_config = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' }, }, 'handlers': { 'default': { 'level': 'INFO', 'formatter': 'standard', 'class': 'logging.StreamHandler', }, 'file': { 'level': 'DEBUG', 'formatter': 'standard', 'class': 'logging.FileHandler', 'filename': './logs/training.log', 'mode': 'a', }, }, 'loggers': { '': { 'handlers': ['default', 'file'], 'level': 'DEBUG', 'propagate': False } } } ``` ```rust use tracing::{info, debug, warn, error}; use tracing_subscriber::{fmt, EnvFilter}; // Initialize logging pub fn init_logging(level: &str, log_file: Option<&str>) -> Result<()> { let filter = EnvFilter::new(level); let subscriber = fmt::Subscriber::builder() .with_env_filter(filter) .with_thread_ids(true) .with_target(true); if let Some(file_path) = log_file { let file = std::fs::OpenOptions::new() .create(true) .append(true) .open(file_path)?; subscriber .with_writer(file) .init(); } else { subscriber.init(); } Ok(()) } // Usage init_logging("info", Some("./logs/training.log"))?; info!("Training started"); ``` -------------------------------- ### Troubleshoot Rust Compilation Errors Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Commands to resolve common Rust compilation issues by clearing the build cache, rebuilding the project, and updating dependencies to ensure a clean and up-to-date build environment. ```bash cargo clean cargo build cargo update ``` -------------------------------- ### Execute Neuro-Divergent Rust Verification Test Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Command to compile and run the provided Rust program to verify the Neuro-Divergent library installation. ```bash cargo run --bin test_installation ``` -------------------------------- ### Install NeuralForecast with pip Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/plans/08-user-migration-guide.md Installs the NeuralForecast library using Python's pip package manager. This is the standard way to set up the Python forecasting library. ```bash pip install neuralforecast ``` -------------------------------- ### VS Code `settings.json` for Rust Development Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Configures VS Code extensions like `rust-analyzer` for Rust development, enabling features such as `clippy` checks, cargo features, proc macro support, file associations, and format-on-save for Rust files. ```JSON { "rust-analyzer.check.command": "clippy", "rust-analyzer.cargo.features": "all", "rust-analyzer.procMacro.enable": true, "files.associations": { "*.rs": "rust" }, "editor.formatOnSave": true, "[rust]": { "editor.defaultFormatter": "rust-lang.rust-analyzer" } } ``` -------------------------------- ### Add Neuro-Divergent and Tokio Dependencies to Cargo.toml Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Adds the 'neuro-divergent' crate and 'tokio' (with full features enabled for async support) as project dependencies in the Cargo.toml configuration file. ```TOML [dependencies] neuro-divergent = "0.1.0" tokio = { version = "1.0", features = ["full"] } # For async support ``` -------------------------------- ### Configure Cargo.toml for neuro-forecast-migration Project Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Defines the package metadata and dependencies for the `neuro-forecast-migration` Rust project. It includes `neuro-divergent`, `polars` with extensive features for data manipulation, `tokio` for asynchronous operations, `anyhow` for error handling, `serde` for serialization, `clap` for command-line argument parsing, and `tracing` for logging. Development dependencies like `approx`, `criterion`, and `tempfile` are also specified, along with binary and benchmark targets. ```toml [package] name = "neuro-forecast-migration" version = "0.1.0" edition = "2021" [dependencies] neuro-divergent = "0.1.0" polars = { version = "0.33", features = [ "lazy", "csv", "parquet", "json", "temporal", "strings", "dtype-datetime" ] } tokio = { version = "1.0", features = ["full"] } anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } clap = { version = "4.0", features = ["derive"] } tracing = "0.1" tracing-subscriber = "0.3" [dev-dependencies] approx = "0.5" criterion = "0.5" tempfile = "3.0" [[bin]] name = "migrate" path = "src/main.rs" [[bench]] name = "comparison" harness = false ``` -------------------------------- ### Create Docker Image for Neuro-Divergent Application Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Provides a Dockerfile to build a Docker image for a Rust application, specifically `neuro-divergent`. It utilizes the official Rust base image, installs the application, copies source code, builds a release binary, and sets the default command for execution. ```dockerfile FROM rust:1.75 # Install Neuro-Divergent RUN cargo install neuro-divergent # Copy your application COPY . /app WORKDIR /app # Build RUN cargo build --release CMD ["./target/release/your-app"] ``` -------------------------------- ### Execute Neuro-Divergent Performance Benchmarks Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Commands to run built-in performance benchmarks for Neuro-Divergent, including a general test and an optional GPU-specific benchmark if GPU features are enabled. ```bash # Basic performance test cargo run --example benchmark --release # GPU performance test (if enabled) cargo run --example gpu_benchmark --release --features="gpu" ``` -------------------------------- ### Verify Neuro-Divergent Installation with Rust Code Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md A Rust program to confirm successful installation of Neuro-Divergent by testing basic functionality, model creation, and reporting GPU/async support status. ```rust use neuro_divergent::prelude::*; fn main() -> Result<(), Box> { // Test basic functionality println!("Neuro-Divergent version: {}", neuro_divergent::info::version()); // Test model creation let config = MLPConfig::new(10, 5); let model = MLP::::new(config)?; println!("✅ Installation successful!"); println!("GPU support: {}", neuro_divergent::info::has_gpu_support()); println!("Async support: {}", neuro_divergent::info::has_async_support()); Ok(()) } ``` -------------------------------- ### Add Rust Development Components and Cross-Compilation Targets Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Adds essential Rust development components such as `clippy` (a linter), `rust-analyzer` (language server), and `rustfmt` (code formatter) for an improved development experience. Optionally, it adds cross-compilation targets for Linux Musl and Windows GNU, enabling compilation for different operating systems. ```bash rustup component add clippy rust-analyzer rustfmt rustup target add x86_64-unknown-linux-musl rustup target add x86_64-pc-windows-gnu ``` -------------------------------- ### Install neuro-divergent with cargo add Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/plans/08-user-migration-guide.md Installs the neuro-divergent library using the `cargo add` command, a convenient way to add dependencies to a Rust project from the command line. ```bash cargo add neuro-divergent ``` -------------------------------- ### Optimize Dockerfile for Rust Application Builds Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/troubleshooting.md A multi-stage Dockerfile example for building Rust applications, demonstrating best practices for efficient Docker builds. It includes caching dependencies, minimizing the final image size by separating build and runtime stages, and installing only necessary runtime libraries, which helps resolve container build failures. ```dockerfile FROM rust:1.70 as builder # Install dependencies RUN apt-get update && apt-get install -y \ pkg-config \ libssl-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy manifests COPY Cargo.toml Cargo.lock ./ # Cache dependencies RUN mkdir src && \ echo "fn main() {}" > src/main.rs && \ cargo build --release && \ rm -rf src # Copy source and build COPY src ./src RUN touch src/main.rs && \ cargo build --release # Runtime stage FROM debian:bullseye-slim RUN apt-get update && apt-get install -y \ ca-certificates \ libssl1.1 \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/target/release/neuro-divergent /usr/local/bin/ CMD ["neuro-divergent"] ``` -------------------------------- ### Rust: Example Integration Test Workflow Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/troubleshooting.md Presents a Rust integration test example using `#[tokio::test]` to simulate an end-to-end workflow, including data loading, model training, prediction, and result validation. ```rust #[cfg(test)] mod integration_tests { use super::*; #[tokio::test] async fn test_end_to_end_workflow() { // Load test data let df = load_test_data("test_data.csv").unwrap(); // Train model let mut nf = create_test_model(); nf.fit(df.clone()).unwrap(); // Make prediction let predictions = nf.predict().unwrap(); // Validate results assert!(!predictions.is_empty()); assert_eq!(predictions.width(), 3); // ds, unique_id, prediction } } ``` -------------------------------- ### Create New Rust Project and Navigate Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Initializes a new Rust project directory named 'my_forecast_project' using Cargo and then changes the current directory into the newly created project. ```Bash cargo new my_forecast_project cd my_forecast_project ``` -------------------------------- ### Set Up Neuro-Divergent Registry Development Environment Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/neuro-divergent-registry/README.md Instructions for cloning the repository, navigating into it, and building/testing the project using `cargo`. ```bash git clone https://github.com/your-org/neuro-divergent-registry cd neuro-divergent-registry cargo build cargo test ``` -------------------------------- ### Define Project Environment Variables Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Provides example environment variables to be set in a `.env` file for the project. These include `NEURALFORECAST_DATA_PATH` for specifying data location, `RUST_LOG` and `RUST_BACKTRACE` for Rust logging and debugging, and optional GPU configuration variables like `CUDA_VISIBLE_DEVICES` and `PYTORCH_CUDA_ALLOC_CONF` for managing GPU usage in PyTorch. ```bash NEURALFORECAST_DATA_PATH=./data RUST_LOG=info RUST_BACKTRACE=1 # GPU configuration (if available) CUDA_VISIBLE_DEVICES=0 PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 ``` -------------------------------- ### Quick Start: Analysis Workflow with Claude-Flow Source: https://github.com/ruvnet/ruv-fann/blob/main/CLAUDE.md Shows how to use the SPARC analyzer mode to identify performance bottlenecks in a codebase and how to launch a data analysis swarm to process user behavior patterns from logs, with output directed to an SQLite database. ```bash # Analyze codebase performance ./claude-flow sparc run analyzer "Identify performance bottlenecks in current codebase" # Data analysis swarm ./claude-flow swarm "Analyze user behavior patterns from logs" --strategy analysis --mode mesh --parallel --output sqlite ``` -------------------------------- ### Neuro-Divergent Project Development Setup Commands Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/README.md Provides essential command-line instructions for setting up the Neuro-Divergent development environment, including repository cloning, running tests, executing benchmarks, checking code style, and generating project documentation. ```bash # Clone the repository git clone https://github.com/your-org/ruv-FANN cd ruv-FANN/neuro-divergent # Run tests cargo test --all-features # Run benchmarks cargo bench # Check formatting and linting cargo fmt --check cargo clippy -- -D warnings # Generate documentation cargo doc --open ``` -------------------------------- ### Update Rust Toolchain to Latest Stable Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Updates the installed Rust toolchain to its latest stable version. This command ensures that all Rust components are up-to-date, and then sets the stable toolchain as the default for future Rust operations. ```bash rustup update stable rustup default stable ``` -------------------------------- ### Quick Start: Development Workflow with Claude-Flow Source: https://github.com/ruvnet/ruv-fann/blob/main/CLAUDE.md Illustrates setting up the orchestration system with a web UI, initiating a Test-Driven Development (TDD) workflow for new features, coordinating a development swarm for complex projects, and checking overall system status. ```bash # Start orchestration system with web UI ./claude-flow start --ui --port 3000 # Run TDD workflow for new feature ./claude-flow sparc tdd "User authentication system with JWT tokens" # Development swarm for complex projects ./claude-flow swarm "Build e-commerce API with payment integration" --strategy development --mode hierarchical --max-agents 8 --monitor # Check system status ./claude-flow status ``` -------------------------------- ### Ruv-FANN Development Environment Setup Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/neuro-divergent-training/README.md Provides shell commands to clone the Ruv-FANN repository, navigate to the training module, build the project with all features, and run all tests for a complete development environment setup. ```bash git clone https://github.com/ruvnet/ruv-FANN.git cd ruv-FANN/neuro-divergent/neuro-divergent-training cargo build --all-features cargo test --all-features ``` -------------------------------- ### Development Setup and Quality Checks for ruv-fann Source: https://github.com/ruvnet/ruv-fann/blob/main/README.md This snippet provides essential `bash` commands for setting up the `ruv-fann` development environment. It includes steps for cloning the repository, navigating into the project directory, running all tests, checking code formatting, and performing static analysis with `clippy`, along with generating project documentation. ```bash # Clone the repository git clone https://github.com/ruvnet/ruv-fann.git cd ruv-fann # Run tests cargo test --all-features # Check formatting cargo fmt --check # Run clippy lints cargo clippy -- -D warnings # Generate documentation cargo doc --open ``` -------------------------------- ### Install Neuro-Divergent on Linux (Ubuntu/Debian) Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Comprehensive guide for installing Rust and Neuro-Divergent dependencies on Ubuntu/Debian systems, including commands for essential build tools and optional CUDA/OpenCL support. ```bash # Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env # Install dependencies sudo apt update sudo apt install build-essential pkg-config libssl-dev # For GPU support (optional) sudo apt install nvidia-cuda-toolkit # CUDA # OR sudo apt install ocl-icd-opencl-dev # OpenCL # Add to Cargo.toml and build cargo add neuro-divergent cargo build ``` -------------------------------- ### Set CUDA Environment Variables Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Configures the necessary environment variables for CUDA, including `CUDA_ROOT`, `PATH`, and `LD_LIBRARY_PATH`. This snippet also includes a verification step using `nvcc` to confirm the setup. ```bash export CUDA_ROOT=/usr/local/cuda-11.8 export PATH=$PATH:$CUDA_ROOT/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64 nvcc --version ``` -------------------------------- ### Solution for 'Could not find CUDA' Error Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Provides a common solution for resolving the 'Could not find CUDA' error encountered during Neuro-Divergent compilation or execution, often related to environment variable setup. ```bash ``` -------------------------------- ### Set Parallel Processing Environment Variables Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Configures environment variables for Rayon and Polars to control the number of threads used for parallel processing, optimizing performance for CPU-bound tasks. ```Bash RAYON_NUM_THREADS=4 POLARS_MAX_THREADS=4 ``` -------------------------------- ### Manually Configure Model Training Parameters in Rust Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Demonstrates how to set up a `TrainingConfig` with specific hyperparameters like max epochs, learning rate, batch size, early stopping, and validation split, then applies it during model fitting. ```rust let training_config = TrainingConfig::new() .with_max_epochs(200) .with_learning_rate(0.001) .with_batch_size(64) .with_early_stopping(patience: 20) .with_validation_split(0.2); nf.fit_with_config(&data, &training_config).await?; ``` -------------------------------- ### Enable Real-time Training Visualization in Rust Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/training.md Shows how to configure `TrainingVisualizer` for live plotting of metrics, displaying a metrics dashboard, visualizing model architecture, and saving plots to a specified directory for detailed analysis. ```rust // Real-time training visualization let visualizer = TrainingVisualizer::new() .with_live_plotting(true) .with_metrics_dashboard(true) .with_model_architecture_plot(true) .with_save_directory("training_plots/"); // Enable visualization let training_config = TrainingConfig::new() .with_visualizer(visualizer); ``` -------------------------------- ### Enable CUDA/GPU Features in `Cargo.toml` Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Modifies the `Cargo.toml` file to enable `cuda` and `gpu` features for the `neuro-divergent` dependency. This configuration allows the Rust project to compile with GPU acceleration support, leveraging NVIDIA CUDA capabilities. ```TOML [dependencies.neuro-divergent] version = "0.1.0" features = ["cuda", "gpu"] ``` -------------------------------- ### Initialize Hyperparameter Grid Search - Python Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/code-conversion.md This snippet begins the setup for a hyperparameter grid search in Python, importing necessary modules like `itertools.product` and `sklearn.model_selection.ParameterGrid`. The full implementation for executing the grid search is not provided in this excerpt. ```python from itertools import product from sklearn.model_selection import ParameterGrid ``` -------------------------------- ### Load Trained Forecasting Model in Rust Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Illustrates how to load a previously saved `NeuralForecast` model, either from a file path or from a byte array, enabling model persistence and reuse. ```rust // Load from file let nf = NeuralForecast::load("my_model.nd")?; // Load from bytes let nf = NeuralForecast::from_bytes(&model_bytes)?; ``` -------------------------------- ### Verify OpenCL Driver Installation Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Command to check if OpenCL drivers are correctly installed on the system, a prerequisite for OpenCL-based GPU acceleration. ```bash # Install OpenCL drivers # Intel: intel-opencl-runtime # AMD: rocm-opencl-runtime # NVIDIA: nvidia-opencl-dev # Verify installation clinfo ``` -------------------------------- ### Rust: Initialize Tracing for Debug Logging Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/troubleshooting.md Provides a Rust code example demonstrating how to set up `tracing` for structured logging, allowing developers to enable debug, info, and error logs based on environment variables. ```rust use tracing::{info, debug, error}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; fn init_logging() { tracing_subscriber::registry() .with(tracing_subscriber::EnvFilter::new( std::env::var("RUST_LOG").unwrap_or_else(|_| "debug".into()), )) .with(tracing_subscriber::fmt::layer()) .init(); } fn main() { init_logging(); info!("Starting application"); // Your code here } ``` -------------------------------- ### Perform Time Series Backtesting for Model Evaluation in Rust Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/quick-start.md Demonstrates how to perform backtesting on time series data, configuring window size, step size, and prediction horizon, and then saves a plot of the results. ```rust let backtest_results = nf.backtest(&data) .with_window_size(30) .with_step_size(7) .with_horizon(14) .run().await?; backtest_results.plot_results("backtest.png")?; ``` -------------------------------- ### Install Neuro-Divergent on macOS Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/user-guide/installation.md Step-by-step instructions for installing Rust and Neuro-Divergent on macOS, highlighting the automatic Metal GPU support on Apple Silicon. ```bash # Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env # Install Xcode command line tools xcode-select --install # For GPU support (M1/M2 Macs) # Metal support is included by default # Add to Cargo.toml and build cargo add neuro-divergent --features="gpu" cargo build ``` -------------------------------- ### Rust Criterion Benchmark for LSTM Training Source: https://github.com/ruvnet/ruv-fann/blob/main/neuro-divergent/docs/migration/installation-setup.md Implements a performance benchmark using the `criterion` crate for training an LSTM model from the `neuro-divergent` library. It loads data from a CSV file using Polars and measures the time taken for the model fitting process. ```Rust // benches/comparison.rs use criterion::{black_box, criterion_group, criterion_main, Criterion}; use neuro_divergent::models::LSTM; use polars::prelude::*; fn benchmark_lstm_training(c: &mut Criterion) { let data = LazyFrame::scan_csv("data/air_passengers.csv", Default::default()) .unwrap() .collect() .unwrap(); c.bench_function("lstm_training", |b| { b.iter(|| { let mut model = LSTM::builder() .horizon(12) .input_size(24) .build() .unwrap(); model.fit(black_box(&data)).unwrap(); }) }); } criterion_group!(benches, benchmark_lstm_training); criterion_main!(benches); ```