File size: 9,956 Bytes
071cd07 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | #!/usr/bin/env python3
"""Safely copy SNN Baby Brain runtime companions and existing user data into v41's folder.
Default layout:
Old files: D:\\ais\\my_ai
v41 folder: D:\\ais\\my_ai\\new
Best use: place this script in D:\\ais\\my_ai\\new beside 41.py, then run:
python .\\copy_v41_needed_files.py
Safety rules:
- Never overwrites an existing destination file.
- Never copies old versioned .py scripts (20.py ... 40.py) over v41.
- Copies only a curated list of runtime state, model weights, and useful datasets.
- Use --dry-run first to preview, or --source/--destination to override paths.
"""
from __future__ import annotations
import argparse
import fnmatch
import json
import shutil
import sys
from datetime import datetime
from pathlib import Path
from typing import Iterable
DEFAULT_SOURCE = Path(r"D:\ais\my_ai")
DEFAULT_DESTINATION = Path(r"D:\ais\my_ai\new")
# Local runtime modules. The newer bundle's files are preserved whenever already present.
COMPANION_MODULES = {
"dev_workbench.py",
"human_workflow.py",
"ai_delegation.py",
"chronos_cognitive_module.py", # Optional; provides time-awareness helpers.
}
# Configuration files used by runtime features; only copied if destination lacks them.
CONFIG_FILES = {
"ai_workers.json",
"always_on_config.json",
"always_on_perception_config.json",
"always_on_desktop_config.json",
"system_prompt.txt",
}
# Main model state and training progress. Existing destination versions are never replaced.
CORE_STATE_FILES = {
"snn_brain_active.safetensors",
"brain_metadata.json",
"tokenizer_vocab.json",
"chat_data.json",
"replay_buffer.json",
"reasoning_log.jsonl",
"unsupervised_log.jsonl",
"skill_adapters.safetensors",
"skill_learning_state.json",
"skill_parameter_importance.safetensors",
"training_loss_log.csv",
"neurogenesis_events.jsonl",
"rl_feedback_log.csv",
"actor_critic.pt",
"jspace_workspace.safetensors",
"jspace_workspace_state.json",
"jspace_jacobian_lens.safetensors",
"jspace_jacobian_lens_state.json",
"training_autosave_progress.json",
"hippocampus_memory.jsonl",
"hippocampus_texts.json",
"hippocampus_vectors.npy",
"hippocampus_semantic_vectors.npy",
"memory.json",
"brain_memory.json",
"master_brain_state.json",
"bio_learning_v16.json",
"bio_memory_v16.json",
"capability_graph_v16.json",
"agi_retention.jsonl",
"agi_validation.jsonl",
"agi_manifest.json",
"identity.jsonl",
"identity_fast.jsonl",
"v15_cognitive_state.json",
"v15_goals.json",
"v15_skills.json",
"v15_world_model.json",
"metrics_v10.json",
"keywords.json",
"max.jsonl",
"maxa.json",
"max_dataset.json",
"max_chat_training.jsonl",
"my_knowledge_base.txt",
"my_knowledge_base1.txt",
"100 Moral Stories.txt",
# Optional legacy multimodal checkpoints used by v41 if compatible.
"vision_encoder.pt",
"vision_decoder.pt",
"audio_encoder.pt",
"audio_decoder.pt",
# Useful historical training/config files.
"curriculum.json",
"chat_json2.jsonl",
"chat_jsonl.jsonl",
"chat_jsonl2.jsonl",
"training_data.jsonl",
"image_data.jsonl",
"web_dataset.json",
"snn_name_training_1200.jsonl",
"snn_name_train_1200.jsonl",
"chatdoctor5k.json",
"xlam_function_calling_60k.json",
"prompts.csv",
"prompts.json",
"test.jsonl",
"tqa.json",
"teach1.json",
"data.json",
"data.json.jsonl",
"data.jsonl",
"data1.jsonl",
"data2.json",
"data2.jsonl",
"datah.json",
"datah.jsonl",
"m.json",
"my.json",
"max_dataset.json",
}
# Copy these matching curriculum files too, without bringing across old Python versions.
COPY_PATTERNS = (
"teach_generated_qa*.json",
"teach_curriculum_plan_*.json",
"l[1-6].json",
)
# Optional test / reference files are not needed for runtime, but useful if available.
OPTIONAL_SUPPORT_FILES = {
"check_v41_regressions.py",
"test_lifelong_growth_v41.py",
"SNN_Baby_Brain_41_IMPLEMENTATION_MATRIX.md",
"README_SNN_Baby_Brain_41.md",
"requirements-40-core.txt",
"requirements-40-optional.txt",
}
def choose_paths(args: argparse.Namespace) -> tuple[Path, Path]:
if args.source:
source = Path(args.source).expanduser().resolve()
else:
# If the helper is placed beside 41.py in a folder named "new", use its parent as source.
here = Path(__file__).resolve().parent
if here.name.lower() == "new" and (here / "41.py").exists():
source = here.parent
else:
source = DEFAULT_SOURCE
if args.destination:
destination = Path(args.destination).expanduser().resolve()
else:
here = Path(__file__).resolve().parent
if (here / "41.py").exists():
destination = here
else:
destination = DEFAULT_DESTINATION
return source, destination
def selected_names(source: Path, include_optional_support: bool) -> list[str]:
names = set(COMPANION_MODULES | CONFIG_FILES | CORE_STATE_FILES)
if include_optional_support:
names.update(OPTIONAL_SUPPORT_FILES)
# Add patterns only for existing top-level files in the old folder.
for candidate in source.iterdir():
if candidate.is_file() and any(fnmatch.fnmatch(candidate.name.lower(), p.lower()) for p in COPY_PATTERNS):
names.add(candidate.name)
return sorted(names, key=str.lower)
def main() -> int:
parser = argparse.ArgumentParser(description="Copy old SNN Baby Brain state/data into the folder containing v41.py, without overwriting anything.")
parser.add_argument("--source", help=r"Old files folder (default: D:\ais\my_ai or parent of the folder named new).")
parser.add_argument("--destination", help=r"v41 folder (default: folder containing this script/41.py, or D:\ais\my_ai\new).")
parser.add_argument("--dry-run", action="store_true", help="Show what would be copied without changing any files.")
parser.add_argument("--include-support", action="store_true", help="Also copy the regression tests, README, and requirements files if present.")
args = parser.parse_args()
source, destination = choose_paths(args)
print("SNN Baby Brain v41 file copier")
print(f"Source : {source}")
print(f"Destination : {destination}")
print(f"Mode : {'DRY RUN (no files changed)' if args.dry_run else 'COPY MISSING FILES ONLY'}")
if not source.is_dir():
print(f"ERROR: Old files folder does not exist: {source}", file=sys.stderr)
return 2
if not destination.is_dir():
print(f"ERROR: v41 destination folder does not exist: {destination}", file=sys.stderr)
print("Extract the v41 bundle there first, then run this script from that folder.", file=sys.stderr)
return 2
if not (destination / "41.py").is_file():
print(f"ERROR: {destination / '41.py'} was not found. Refusing to copy into an uncertain folder.", file=sys.stderr)
return 2
if source.resolve() == destination.resolve():
print("ERROR: Source and destination are the same folder; nothing to do.", file=sys.stderr)
return 2
names = selected_names(source, args.include_support)
copied: list[str] = []
skipped_existing: list[str] = []
missing_source: list[str] = []
failed: list[dict[str, str]] = []
for name in names:
src = source / name
dst = destination / name
if not src.is_file():
missing_source.append(name)
continue
if dst.exists():
skipped_existing.append(name)
continue
if args.dry_run:
print(f"[WOULD COPY] {name} ({src.stat().st_size:,} bytes)")
copied.append(name)
continue
try:
shutil.copy2(src, dst)
copied.append(name)
print(f"[COPIED] {name} ({src.stat().st_size:,} bytes)")
except Exception as exc:
failed.append({"file": name, "error": str(exc)})
print(f"[FAILED] {name}: {exc}", file=sys.stderr)
if skipped_existing:
print(f"\nPreserved {len(skipped_existing)} destination file(s) already present (not overwritten).")
if missing_source:
print(f"Source did not contain {len(missing_source)} optional/legacy file(s); skipped them.")
print(f"\nSummary: {'would copy' if args.dry_run else 'copied'}={len(copied)}, already present={len(skipped_existing)}, unavailable in source={len(missing_source)}, failed={len(failed)}")
# Give the user a quick check of critical runtime files after the copy.
print("\nDestination check:")
for name in ("41.py", "dev_workbench.py", "human_workflow.py", "ai_delegation.py", "snn_brain_active.safetensors", "brain_metadata.json", "tokenizer_vocab.json"):
status = "OK" if (destination / name).is_file() else "MISSING"
print(f" [{status}] {name}")
if not args.dry_run:
report = {
"created_at": datetime.now().astimezone().isoformat(timespec="seconds"),
"source": str(source),
"destination": str(destination),
"copied": copied,
"skipped_existing": skipped_existing,
"missing_source": missing_source,
"failed": failed,
}
report_path = destination / "v41_file_copy_report.json"
try:
report_path.write_text(json.dumps(report, indent=2, ensure_ascii=False), encoding="utf-8")
print(f"\nReport saved to: {report_path}")
except Exception as exc:
print(f"WARNING: Could not save copy report: {exc}", file=sys.stderr)
print("\nSafety: no files in the destination were overwritten. Old versioned .py files were not copied.")
return 1 if failed else 0
if __name__ == "__main__":
raise SystemExit(main())
|