diff --git a/program/copymaster.py b/program/copymaster.py index 2e8a328..8294633 100644 --- a/program/copymaster.py +++ b/program/copymaster.py @@ -4,17 +4,33 @@ import os import shutil -# === CONFIG === -OUTPUTS_DIR = "/home/hyrenko/Diploma/outputs" # откуда брать -DEST_DIR = "/home/hyrenko/Diploma/response" # базовая папка назначения +# ========================= +# Config +# ========================= +# Source directory containing run subfolders +OUTPUTS_DIR = "/home/hyrenko/Diploma/outputs" +# Destination base directory where JSON files will be copied +DEST_DIR = "/home/hyrenko/Diploma/response" -# создаём папки, если их нет +# Ensure destination folders exist os.makedirs(DEST_DIR, exist_ok=True) os.makedirs(os.path.join(DEST_DIR, "gemma"), exist_ok=True) os.makedirs(os.path.join(DEST_DIR, "llama"), exist_ok=True) os.makedirs(os.path.join(DEST_DIR, "qwen"), exist_ok=True) -# === PICK MODEL INTERACTIVELY === + +# ----------------------------------------------------------------------------- +# pick_model() +# Purpose: +# Interactive menu to choose which model's outputs should be collected. +# +# Behavior: +# - Prompts user to select one of: gemma / llama / qwen +# - Keeps asking until a valid selection is entered +# +# Returns: +# A lowercase model name string: "gemma", "llama", or "qwen" +# ----------------------------------------------------------------------------- def pick_model(): print("\n=== Select model ===") print("[1] gemma") @@ -31,16 +47,33 @@ def pick_model(): else: print("Invalid selection, try again.") -# === MAIN === + +# ----------------------------------------------------------------------------- +# main() +# Purpose: +# Copies 'responses.json' files from model-specific run folders inside OUTPUTS_DIR +# into a dedicated destination folder: +# DEST_DIR// +# +# Workflow: +# 1) Ask user to pick a model name. +# 2) Create destination folder DEST_DIR// if needed. +# 3) Scan all subdirectories in OUTPUTS_DIR. +# 4) Keep only those whose folder name contains the selected model name. +# 5) If /responses.json exists, copy it to: +# DEST_DIR//.json +# where counter starts from 1 and increments for each copied file. +# 6) Print a summary at the end. +# ----------------------------------------------------------------------------- def main(): model_name = pick_model() print(f"\n[INFO] Selected model: {model_name}") - # Папка назначения — /response// + # Destination folder: /response// dest_path = os.path.join(DEST_DIR, model_name) os.makedirs(dest_path, exist_ok=True) - # Сканируем все подпапки в outputs + # Collect all subdirectories inside OUTPUTS_DIR subdirs = sorted([os.path.join(OUTPUTS_DIR, d) for d in os.listdir(OUTPUTS_DIR) if os.path.isdir(os.path.join(OUTPUTS_DIR, d))]) @@ -48,7 +81,7 @@ def main(): copied = 0 for subdir in subdirs: - # фильтруем только те, где в названии есть имя модели + # Filter only subfolders whose name includes the selected model name if model_name not in subdir: continue @@ -70,5 +103,6 @@ def main(): if copied == 0: print("[WARN] No matching response.json files were found.") + if __name__ == "__main__": main()