Added Comments
This commit is contained in:
parent
5f05bc2460
commit
c77bbb9d2a
@ -4,17 +4,33 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# === CONFIG ===
|
# =========================
|
||||||
OUTPUTS_DIR = "/home/hyrenko/Diploma/outputs" # откуда брать
|
# Config
|
||||||
DEST_DIR = "/home/hyrenko/Diploma/response" # базовая папка назначения
|
# =========================
|
||||||
|
# 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(DEST_DIR, exist_ok=True)
|
||||||
os.makedirs(os.path.join(DEST_DIR, "gemma"), 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, "llama"), exist_ok=True)
|
||||||
os.makedirs(os.path.join(DEST_DIR, "qwen"), 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():
|
def pick_model():
|
||||||
print("\n=== Select model ===")
|
print("\n=== Select model ===")
|
||||||
print("[1] gemma")
|
print("[1] gemma")
|
||||||
@ -31,16 +47,33 @@ def pick_model():
|
|||||||
else:
|
else:
|
||||||
print("Invalid selection, try again.")
|
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/<model_name>/
|
||||||
|
#
|
||||||
|
# Workflow:
|
||||||
|
# 1) Ask user to pick a model name.
|
||||||
|
# 2) Create destination folder DEST_DIR/<model_name>/ if needed.
|
||||||
|
# 3) Scan all subdirectories in OUTPUTS_DIR.
|
||||||
|
# 4) Keep only those whose folder name contains the selected model name.
|
||||||
|
# 5) If <subdir>/responses.json exists, copy it to:
|
||||||
|
# DEST_DIR/<model_name>/<counter>.json
|
||||||
|
# where counter starts from 1 and increments for each copied file.
|
||||||
|
# 6) Print a summary at the end.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
def main():
|
def main():
|
||||||
model_name = pick_model()
|
model_name = pick_model()
|
||||||
print(f"\n[INFO] Selected model: {model_name}")
|
print(f"\n[INFO] Selected model: {model_name}")
|
||||||
|
|
||||||
# Папка назначения — /response/<model_name>/
|
# Destination folder: /response/<model_name>/
|
||||||
dest_path = os.path.join(DEST_DIR, model_name)
|
dest_path = os.path.join(DEST_DIR, model_name)
|
||||||
os.makedirs(dest_path, exist_ok=True)
|
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)
|
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))])
|
if os.path.isdir(os.path.join(OUTPUTS_DIR, d))])
|
||||||
|
|
||||||
@ -48,7 +81,7 @@ def main():
|
|||||||
copied = 0
|
copied = 0
|
||||||
|
|
||||||
for subdir in subdirs:
|
for subdir in subdirs:
|
||||||
# фильтруем только те, где в названии есть имя модели
|
# Filter only subfolders whose name includes the selected model name
|
||||||
if model_name not in subdir:
|
if model_name not in subdir:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -70,5 +103,6 @@ def main():
|
|||||||
if copied == 0:
|
if copied == 0:
|
||||||
print("[WARN] No matching response.json files were found.")
|
print("[WARN] No matching response.json files were found.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user