p-doom/crowd-code-dataset-0.2 huggingface dataset:
[content] tab-model-eval/src/evaluation/sglang_eval.py (python)
class LocalLogger:
    """A simple local logger that saves metrics to JSON files for later sync to wandb."""
    
    def __init__(self, log_dir: str, run_id: str, run_name: str, project: str, config: dict = None, tags: list = None):
        self.log_dir = os.path.join(log_dir, run_id)
        os.makedirs(self.log_dir, exist_ok=True)
        self.run_id = run_id
        self.run_name = run_name
        self.project = project
        self.config = config or {}
        self.tags = tags or []
        self.metrics_file = os.path.join(self.log_dir, "metrics.jsonl")
        
        # Save run metadata
        metadata_file = os.path.join(self.log_dir, "metadata.json")
        with open(metadata_file, "w") as f:
            json.dump({
                "run_id": run_id,
                "run_name": run_name,
                "project": project,
                "config": config,
                "tags": tags,
                "created_at": time.strftime("%Y-%m-%dT%H:%M:%S")
            }, f, indent=2)
        
        print(f"LocalLogger initialized. Logs will be saved to: {self.log_dir}")
    
    def log(self, metrics: dict):
        """Append metrics to the JSONL file."""
        metrics_with_timestamp = {
            "timestamp": time.strftime("%Y-%m-%dT%H:%M:%S"),
            **metrics
        }
        with open(self.metrics_file, "a") as f:
            f.write(json.dumps(metrics_with_timestamp) + "
")
        print(f"Logged metrics to {self.metrics_file}: eval_step={metrics.get('eval_step', 'N/A')}")
    
    def finish(self):
        """Called when logging is complete."""
        print(f"LocalLogger finished. All logs saved to: {self.log_dir}")
[content] tab-model-eval/src/evaluation/sglang_eval.py (python)
    # Initialize logger (local or wandb)
    logger = None
    if args.use_local_logger:
        # Use local logger for offline mode
        run_id = args.wandb_id or args.wandb_name
        logger = LocalLogger(
            log_dir=args.local_log_dir,
            run_id=run_id,
            run_name=args.wandb_name,
            project=args.wandb_project,
            config=metadata,
            tags=args.wandb_tags,
        )
    else:
        # Use wandb for online mode
        wandb_init_kwargs = {
            "project": args.wandb_project,
            "name": args.wandb_name,
            "tags": args.wandb_tags,
            "group": "debug",
            "config": metadata,
        }

        if args.wandb_id:
            # For offline mode: ensure we always write to the same run directory
            # by setting WANDB_DIR to a consistent location based on run ID
            wandb_dir = os.path.join(args.wandb_log_dir or os.getcwd(), "eval_logs", args.wandb_id)
            os.makedirs(wandb_dir, exist_ok=True)
            os.environ["WANDB_DIR"] = wandb_dir
            os.environ["WANDB_RESUME"] = "allow"
            
            wandb_init_kwargs.update(
                {
                    "id": args.wandb_id,
                    "resume": "allow",
                    "dir": wandb_dir,
                }
            )
        wandb.init(**wandb_init_kwargs)
[content] tab-model-eval/src/evaluation/sglang_eval.py (python)
    # Prepare metrics to log
    metrics_to_log = {
        f"eval_step": args.eval_step,
        f"{args.wandb_eval_type}/total_test_cases": len(test_cases),
        f"{args.wandb_eval_type}/num_samples_per_task": loaded_data["config_generations"][
            "num_samples"
        ],
        f"{args.wandb_eval_type}/total_judge_avg_at_n": total_judge_avg_at_n,
        f"{args.wandb_eval_type}/total_judge_pass_at_n": total_judge_pass_at_n,
        f"{args.wandb_eval_type}/total_exact_match_avg_at_n": total_exact_match_avg_at_n,
        f"{args.wandb_eval_type}/total_exact_match_pass_at_n": total_exact_match_pass_at_n,
    }
    
    # Log metrics using appropriate logger
    if args.use_local_logger:
        logger.log(metrics_to_log)
    else:
        wandb.log(metrics_to_log)
[content] tab-model-eval/src/evaluation/sglang_eval.py (python)
    
    # Finish logging
    if args.use_local_logger:
        logger.finish()
    else:
        wandb.finish()


# ----------------------------
# Server launch + waiting
# ----------------------------
async
[content] tab-model-eval/src/evaluation/sglang_eval.py (python)
    
    # Finish logging
    if args.use_local_logger:
        logger.finish()
    else:
        wandb.finish()


# ----------------------------
# Server launch + waiting
# ----------------------------
async def wait_for_server(base_url: str, timeout: float = 600.0) -> None:
[tab] /fast/project/HFMI_SynergyUnit/tab_model/data/qwen/miles_hf_part_jsonl_4k_tokens/metadata.json (json)
{
  "config": {
    "coalesce_radius": 5,
    "csv_root": "/fast/project/HFMI_SynergyUnit/tab_model/data/hf_part_csv/",
    "max_tokens_per_conversation": 8192,
    "max_tokens_per_message": 2048,
    "min_conversation_messages": 5,
    "output_dir": "/fast/project/HFMI_SynergyUnit/tab_model/data/qwen/miles_hf_part_jsonl_4k_tokens/",
    "tokenizer": "Qwen/Qwen3-8B",
    "val_ratio": 0.1,
    "viewport_radius": 10
  },
  "counts": {
    "total_conversations": 4446,
    "total_sessions": 349,
    "train_conversations": 4043,
    "val_conversations": 403
  },
  "files": {
    "train_path": "/fast/project/HFMI_SynergyUnit/tab_model/data/qwen/miles_hf_part_jsonl_4k_tokens/training.jsonl",
    "val_path": "/fast/project/HFMI_SynergyUnit/tab_model/data/qwen/miles_hf_part_jsonl_4k_tokens/validation.jsonl"
  },
  "stats": {
    "avg_messages_per_conversation": 29.13697705802969,
    "avg_tokens_per_conversation": 7527.038461538462,
    "total_messages": 129543,
    "total_tokens": 33465213
  }
}