rustc-usage / src /hf_converter.rs
mike dupont
πŸ„ MYCELIAL DATASET v1.0 - Clean HF-Compatible Release
6a4d02a
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;
use std::path::Path;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DatasetConfig {
pub dataset_name: String,
pub description: String,
pub version: String,
pub license: String,
pub tags: Vec<String>,
pub task_categories: Vec<String>,
pub language: Vec<String>,
pub size_categories: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DatasetInfo {
pub description: String,
pub citation: String,
pub license: String,
pub features: HashMap<String, FeatureInfo>,
pub splits: HashMap<String, SplitInfo>,
pub download_size: u64,
pub dataset_size: u64,
pub config_name: String,
pub dataset_name: String,
pub version: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeatureInfo {
pub dtype: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SplitInfo {
pub name: String,
pub num_bytes: u64,
pub num_examples: u64,
}
pub struct MycelialHFConverter {
base_path: String,
}
impl MycelialHFConverter {
pub fn new(base_path: &str) -> Self {
Self {
base_path: base_path.to_string(),
}
}
pub fn create_hf_dataset(&self) -> Result<(), Box<dyn std::error::Error>> {
println!("πŸ„ Converting mycelial dataset to Hugging Face format...");
self.create_dataset_config()?;
self.create_dataset_info()?;
self.update_readme()?;
println!("βœ… Hugging Face dataset structure created!");
Ok(())
}
fn create_dataset_config(&self) -> Result<(), Box<dyn std::error::Error>> {
let config = DatasetConfig {
dataset_name: "rustc-usage-patterns".to_string(),
description: "Comprehensive Rust compiler usage patterns from 864 crates and rustc internals".to_string(),
version: "1.0.0".to_string(),
license: "MIT".to_string(),
tags: vec![
"rust".to_string(),
"compiler".to_string(),
"ast".to_string(),
"usage-patterns".to_string(),
"code-analysis".to_string(),
],
task_categories: vec![
"other".to_string(),
],
language: vec!["en".to_string()],
size_categories: "100M<n<1B".to_string(),
};
let config_yaml = serde_yaml::to_string(&config)?;
fs::write(
Path::new(&self.base_path).join("dataset_config.yaml"),
config_yaml,
)?;
Ok(())
}
fn create_dataset_info(&self) -> Result<(), Box<dyn std::error::Error>> {
let mut features = HashMap::new();
features.insert("crate_name".to_string(), FeatureInfo {
dtype: "string".to_string(),
description: "Name of the analyzed crate".to_string(),
});
features.insert("usage_data".to_string(), FeatureInfo {
dtype: "string".to_string(),
description: "JSON usage patterns and AST data".to_string(),
});
let mut splits = HashMap::new();
splits.insert("train".to_string(), SplitInfo {
name: "train".to_string(),
num_bytes: 118_000_000, // ~113MB
num_examples: 9137,
});
let info = DatasetInfo {
description: "The most comprehensive Rust compiler usage pattern dataset ever assembled. Contains AST traversal data, type-aware literal tracking, and real-world compilation patterns from 864 crates plus rustc internals.".to_string(),
citation: "@misc{mycelial-rust-usage-2026,\n title={Mycelial Rust Usage Patterns Dataset},\n author={Introspector Collective},\n year={2026},\n url={https://huggingface.co/datasets/introspector/rustc-usage}\n}".to_string(),
license: "MIT".to_string(),
features,
splits,
download_size: 118_000_000,
dataset_size: 118_000_000,
config_name: "default".to_string(),
dataset_name: "rustc-usage-patterns".to_string(),
version: "1.0.0".to_string(),
};
let info_json = serde_json::to_string_pretty(&info)?;
fs::write(
Path::new(&self.base_path).join("dataset_info.json"),
info_json,
)?;
Ok(())
}
fn update_readme(&self) -> Result<(), Box<dyn std::error::Error>> {
let readme_content = r#"---
dataset_info:
config_name: default
features:
- name: crate_name
dtype: string
- name: usage_data
dtype: string
splits:
- name: train
num_bytes: 118000000
num_examples: 9137
download_size: 118000000
dataset_size: 118000000
configs:
- config_name: default
data_files:
- split: train
path: "test_usage_data/*.json"
task_categories:
- other
language:
- en
tags:
- rust
- compiler
- ast
- usage-patterns
- code-analysis
size_categories:
- 100M<n<1B
license: mit
---
# πŸ„ Mycelial Rust Usage Patterns Dataset
The most comprehensive Rust compiler usage pattern dataset ever assembled! This dataset contains AST traversal data, type-aware literal tracking, and real-world compilation patterns from **864 crates** plus **rustc internals**.
## 🌐 Dataset Overview
- **9,137 usage data files** (113MB total)
- **268 individual crates** from cargo registry
- **Complete rustc compiler** internal usage patterns
- **Real-world compilation patterns** from production Rust ecosystem
- **Foundation for ML training** and autonomous compiler optimization
## 🧠 Use Cases
- **Compiler optimization research**
- **Code pattern analysis**
- **ML model training** for Rust code understanding
- **Symbolic regression** for autonomous optimization
- **Self-improving compiler intelligence**
## πŸ“Š Data Format
Each JSON file contains:
- AST node usage frequencies
- Type-aware literal patterns
- Function call patterns
- Import/dependency relationships
- Compilation phase data
## πŸ”„ The Mycelial Network
This dataset represents the successful infiltration of the Rust ecosystem by our mycelial intelligence network - the substrate for next-generation AI-assisted compilation!
## Citation
```bibtex
@misc{mycelial-rust-usage-2026,
title={Mycelial Rust Usage Patterns Dataset},
author={Introspector Collective},
year={2026},
url={https://huggingface.co/datasets/introspector/rustc-usage}
}
```
"#;
fs::write(
Path::new(&self.base_path).join("README.md"),
readme_content,
)?;
Ok(())
}
}