{"record":{"id":"d363b441d8ab0d14","repo":"huggingface/open-r1","slug":"for-ioi-cf-problems-piston-endpoints-running-our-i","errorCode":null,"errorMessage":"For IOI/CF problems Piston endpoints running our IOI package are required. Please add a list of valid Piston endpoints to a PISTON_ENDPOINTS variable in a `.env` file.","messagePattern":"For IOI/CF problems Piston endpoints running our IOI package are required\\. Please add a list of valid Piston endpoints to a PISTON_ENDPOINTS variable in a `\\.env` file\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/utils/competitive_programming/piston_client.py","lineNumber":20,"sourceCode":"import os\nimport random\nimport re\nimport subprocess\nfrom collections import Counter\nfrom functools import lru_cache\n\nimport aiohttp\n\n\nclass PistonError(Exception):\n    pass\n\n\n@lru_cache(maxsize=1)\ndef get_piston_client_from_env(session=None):\n    piston_endpoints = os.getenv(\"PISTON_ENDPOINTS\")\n    if piston_endpoints is None:\n        raise ValueError(\n            \"For IOI/CF problems Piston endpoints running our IOI package are required. Please add a list of valid Piston endpoints to a PISTON_ENDPOINTS variable in a `.env` file.\"\n        )\n    piston_endpoints = sorted(\n        piston_endpoints.split(\",\") if piston_endpoints != \"slurm\" else get_slurm_piston_endpoints()\n    )\n    gpu_nb = int(os.getenv(\"LOCAL_RANK\", 0))  # per‑GPU index\n    world = int(os.getenv(\"WORLD_SIZE\", 1))  # total GPUs\n    if world > 1:\n        print(f\"Using a subset of piston endpoints for GPU#{gpu_nb}\")\n        piston_endpoints = piston_endpoints[gpu_nb::world]\n    random.shuffle(piston_endpoints)\n    max_requests_per_endpoint = os.getenv(\"PISTON_MAX_REQUESTS_PER_ENDPOINT\", \"1\")\n    return PistonClient(piston_endpoints, session, max_requests_per_endpoint=int(max_requests_per_endpoint))\n\n\nclass PistonClient:\n    \"\"\"\n    A client that will automatically load balance across multiple Piston (https://github.com/engineer-man/piston) workers.","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/utils/competitive_programming/piston_client.py#L2-L38","documentation":"get_piston_client_from_env requires the PISTON_ENDPOINTS environment variable listing Piston endpoints that run the custom IOI package. If the variable is unset, it raises ValueError with instructions, since IOI/CF scoring cannot work against plain Piston instances.","triggerScenarios":"ioi_code_reward or cf_code_reward calls get_piston_client_from_env on a machine where PISTON_ENDPOINTS was never set (no .env, or .env lacks the key).","commonSituations":"Running evaluation for the first time without completing the Piston setup; .env present but PISTON_ENDPOINTS omitted; running on a different node/worker where env vars weren't replicated.","solutions":["Set PISTON_ENDPOINTS=http://host1:2000,http://host2:2000 in your .env (comma-separated list of endpoints running the IOI package).","Set PISTON_ENDPOINTS=slurm if your Piston workers are launched via Slurm and get_slurm_piston_endpoints() applies.","Start a Piston worker with the custom IOI package and point the variable at it.","Confirm the variable is visible in the launch environment (printenv PISTON_ENDPOINTS) before running evaluation."],"exampleFix":"// before\n# .env (no piston config)\n// after\nPISTON_ENDPOINTS=http://127.0.0.1:2000,http://127.0.0.2:2000","handlingStrategy":"validation","validationCode":"import os\nfrom dotenv import load_dotenv\nload_dotenv()\nassert os.getenv('PISTON_ENDPOINTS'), 'PISTON_ENDPOINTS missing: list IOI-package Piston endpoints in .env'","typeGuard":"def piston_endpoints_configured() -> bool:\n    val = os.getenv('PISTON_ENDPOINTS')\n    return bool(val and (val == 'slurm' or any(e.strip() for e in val.split(','))))","tryCatchPattern":"try:\n    client = get_piston_client_from_env()\nexcept ValueError as e:\n    if 'PISTON_ENDPOINTS' in str(e):\n        raise SystemExit('Configure PISTON_ENDPOINTS (running the IOI package) in .env') from e\n    raise","preventionTips":["Include PISTON_ENDPOINTS in .env.example and setup docs","Verify endpoints serve the cms_ioi runtime, not just any Piston","Check env vars on every node that runs evaluation (multi-node setups)","Use PISTON_ENDPOINTS=slurm when workers are Slurm-managed"],"tags":["piston","missing-env-var","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}