in src/open_r1/utils/code_providers.py [0:0]
def __init__(self, num_parallel: int = 2, morph_router_url: Optional[str] = None):
"""Initialize the Morph provider.
Args:
num_parallel: Number of parallel executions to use
morph_router_url: URL for the MorphCloud router (if using router mode)
"""
if not is_morph_available():
raise ImportError(
"MorphCloud is not available and required for this provider. Please install MorphCloud with "
"`pip install morphcloud` and add an API key to a `.env` file."
)
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
print("Warning: python-dotenv not installed. Environment variables must be set directly.")
self.num_parallel = num_parallel
self.morph_router_url = morph_router_url
if self.morph_router_url is not None:
self.routed_sandbox = RoutedMorphSandbox(router_url=self.morph_router_url)
return
import os
self.api_key = os.getenv("MORPH_API_KEY")
if not self.api_key:
raise ValueError("MorphCloud API key not found. Please set the MORPH_API_KEY environment variable.")
try:
self.client = MorphCloudClient(api_key=self.api_key)
self.Sandbox = Sandbox
except ImportError as e:
raise ImportError(f"Required MorphCloud dependencies not installed: {e}")