{"record":{"id":"fdab134e7372a677","repo":"huggingface/open-r1","slug":"morphcloud-is-not-available-and-required-for-this-fdab13","errorCode":null,"errorMessage":"MorphCloud is not available and required for this function. Please install MorphCloud with `pip install morphcloud` and add an API key to a `.env` file.","messagePattern":"MorphCloud is not available and required for this function\\. Please install MorphCloud with `pip install morphcloud` and add an API key to a `\\.env` file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/utils/competitive_programming/morph_client.py","lineNumber":729,"sourceCode":"esac\n\"\"\"\n\n\ndef get_morph_client_from_env(session=None) -> MorphCloudExecutionClient:\n    \"\"\"\n    Creates a MorphCloudExecutionClient instance using environment variables.\n\n    Environment variables:\n        MORPH_API_KEY: API key for MorphCloud\n\n    Args:\n        session: Optional aiohttp.ClientSession to use for HTTP requests\n\n    Returns:\n        MorphCloudExecutionClient: A configured MorphCloud execution client\n    \"\"\"\n    if not is_morph_available():\n        raise ImportError(\n            \"MorphCloud is not available and required for this function. Please install MorphCloud with \"\n            \"`pip install morphcloud` and add an API key to a `.env` file.\"\n        )\n\n    load_dotenv()\n    api_key = os.environ.get(\"MORPH_API_KEY\")\n    if not api_key:\n        raise ValueError(\"MORPH_API_KEY environment variable is required\")\n\n    return MorphCloudExecutionClient(api_key=api_key)\n\n\n# noqa: W293\n","sourceCodeStart":711,"sourceCodeEnd":743,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/utils/competitive_programming/morph_client.py#L711-L743","documentation":"get_morph_client_from_env requires the MorphCloud SDK plus a configured API key. is_morph_available() checks importability (and configuration); if it fails, the factory raises ImportError telling the user to install morphcloud and provide an API key via a .env file.","triggerScenarios":"Calling ioi_code_reward (with morph backend) on a machine where the morphcloud package isn't installed or is incompletely configured, so is_morph_available() returns False before the API key is even read.","commonSituations":"Running the reward pipeline in a fresh container/venv without pip install morphcloud; MorphCloud installed but its config/credentials setup not completed so the availability check fails; switching workers without replicating the environment.","solutions":["Install the SDK: pip install morphcloud.","Complete MorphCloud setup (morphcloud auth / config) so is_morph_available() passes.","Add MORPH_API_KEY=... to your .env file in the working directory.","Alternatively use the Piston backend by setting PISTON_ENDPOINTS instead of the Morph backend."],"exampleFix":"// before\npip install vllm  # morphcloud missing\n// after\npip install morphcloud && echo 'MORPH_API_KEY=your-key' >> .env","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec('morphcloud') is None:\n    raise SystemExit('morphcloud not installed: pip install morphcloud')","typeGuard":"def is_morph_ready() -> bool:\n    try:\n        import morphcloud  # noqa: F401\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    client = get_morph_client_from_env()\nexcept ImportError:\n    logger.warning('MorphCloud unavailable; falling back to Piston backend')\n    client = get_piston_client_from_env()","preventionTips":["Pin morphcloud in requirements and install in all environments (CI, workers)","Run a bootstrap check that verifies imports and .env keys at job start","Document the morph backend prerequisites in your runbook"],"tags":["morphcloud","missing-dependency","environment-setup"],"backgroundTag":"missing-dependency","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}