MCPcopy Create free account
hub / github.com/InternScience/InternAgent / perform_experiments

Function perform_experiments

internagent/experiments_utils_iflow.py:311–404  ·  view source on GitHub ↗

Perform multi-round experiments using iFlow Code Args: idea: The idea to implement folder_name: The folder to work in proxy_settings: Optional proxy settings for iFlow model: Model name to use (default: iflow-default) gpu_ids: GPU IDs to use (string

(idea, folder_name, proxy_settings=None, model='iflow-default', gpu_ids=None, max_runs=None, log_file=None)

Source from the content-addressed store, hash-verified

309
310# PERFORM EXPERIMENTS with iFlow Code for multiple rounds
311def perform_experiments(idea, folder_name, proxy_settings=None, model='iflow-default', gpu_ids=None, max_runs=None, log_file=None) -> bool:
312 """
313 Perform multi-round experiments using iFlow Code
314
315 Args:
316 idea: The idea to implement
317 folder_name: The folder to work in
318 proxy_settings: Optional proxy settings for iFlow
319 model: Model name to use (default: iflow-default)
320 gpu_ids: GPU IDs to use (string like "0,1" or None for CPU)
321 max_runs: Maximum number of runs (default: uses MAX_RUNS constant)
322 log_file: Optional file object to write logs to
323
324 Returns:
325 True if all experiments completed successfully, False otherwise
326 """
327 def log_message(msg):
328 """Write message to both stdout and log file"""
329 print(msg)
330 sys.stdout.flush()
331 if log_file:
332 try:
333 log_file.write(msg + "\n")
334 log_file.flush()
335 except (ValueError, OSError):
336 pass
337
338 # Use provided max_runs or fall back to default
339 if max_runs is None:
340 max_runs = MAX_RUNS
341
342 timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
343 log_message(f"[{timestamp}] Starting experiments for idea in {folder_name}")
344 if gpu_ids:
345 log_message(f"[{timestamp}] Using GPUs: {gpu_ids}")
346
347 current_iter = 0
348 run = 1
349
350 # Initialize iFlow Code runner
351 iflow_runner = IFlowCodeRunner(proxy_settings, model=model)
352
353 # Extract idea information
354 idea_info = extract_idea_info(idea)
355
356 # Prepare initial prompt
357 next_prompt = CODER_PROMPT_OPENHANDS.format(
358 idea_description=idea_info["description"],
359 code_server_path=folder_name,
360 method=idea_info["method"],
361 max_runs=max_runs,
362 )
363
364 log_message(f"Starting experiments for idea: {idea_info['title']}")
365 log_message(f"Method description: {idea_info['method'][:300]}...")
366
367 while run < max_runs + 1:
368 if current_iter >= MAX_ITERS:

Callers

nothing calls this directly

Calls 6

runMethod · 0.95
IFlowCodeRunnerClass · 0.85
formatMethod · 0.80
log_messageFunction · 0.70
extract_idea_infoFunction · 0.70
run_experimentFunction · 0.70

Tested by

no test coverage detected