-
Notifications
You must be signed in to change notification settings - Fork 41
(feat)NeMo-Evaluator Integration #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
e-dobrowolska
wants to merge
2
commits into
OpenHands:main
Choose a base branch
from
e-dobrowolska:nemo-evaluator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,12 @@ | |
| EvalMetadata, | ||
| EvalOutput, | ||
| ) | ||
| from benchmarks.utils.version import SDK_SHORT_SHA | ||
| from benchmarks.utils.llm_config import load_llm_config | ||
| from benchmarks.utils.version import IMAGE_TAG_PREFIX | ||
| from openhands.sdk import LLM, Agent, Conversation, get_logger | ||
| from openhands.sdk.workspace import RemoteWorkspace | ||
| from openhands.tools.preset.default import get_default_tools | ||
| from openhands.workspace import APIRemoteWorkspace, DockerDevWorkspace | ||
| from openhands.workspace import APIRemoteWorkspace, DockerDevWorkspace, DockerWorkspace | ||
|
|
||
|
|
||
| logger = get_logger(__name__) | ||
|
|
@@ -185,28 +186,46 @@ def prepare_workspace( | |
| logger.info(f"Using base docker image: {base_docker_image}") | ||
|
|
||
| if self.metadata.workspace_type == "docker": | ||
| # Build agent-server image from base commit0 image | ||
| workspace = DockerDevWorkspace( | ||
| base_image=base_docker_image, | ||
| working_dir="/workspace", | ||
| target=build_target, | ||
| forward_env=forward_env or [], | ||
| ) | ||
| logger.info( | ||
| f"Building workspace from {base_docker_image}. This may take a while..." | ||
| ) | ||
| # Try to build agent-server image from base commit0 image | ||
| # Fall back to pre-built image if build fails | ||
| try: | ||
| workspace = DockerDevWorkspace( | ||
| base_image=base_docker_image, | ||
| working_dir="/workspace", | ||
| target=build_target, | ||
| forward_env=forward_env or [], | ||
| ) | ||
| logger.info( | ||
| f"Building workspace from {base_docker_image}. This may take a while..." | ||
| ) | ||
| except Exception: | ||
| custom_tag = extract_custom_tag(base_docker_image) | ||
| suffix = f"-{build_target}" if build_target != "binary" else "" | ||
| agent_server_image = ( | ||
| f"{EVAL_AGENT_SERVER_IMAGE}:{IMAGE_TAG_PREFIX}-{custom_tag}{suffix}" | ||
| ) | ||
| if not image_exists(agent_server_image): | ||
| raise RuntimeError( | ||
| f"On-the-fly build failed and pre-built image {agent_server_image} does not exist" | ||
| ) | ||
|
|
||
| workspace = DockerWorkspace( | ||
| server_image=agent_server_image, | ||
| working_dir="/workspace", | ||
| forward_env=forward_env or [], | ||
| ) | ||
| logger.info(f"Using pre-built image {agent_server_image}") | ||
| elif self.metadata.workspace_type == "remote": | ||
| runtime_api_key = os.getenv("RUNTIME_API_KEY") | ||
| if not runtime_api_key: | ||
| raise ValueError( | ||
| "RUNTIME_API_KEY environment variable is not set for remote workspace" | ||
| ) | ||
|
|
||
| sdk_short_sha = os.getenv("SDK_SHORT_SHA", SDK_SHORT_SHA) | ||
| custom_tag = extract_custom_tag(base_docker_image) | ||
| suffix = f"-{build_target}" if build_target != "binary" else "" | ||
| agent_server_image = ( | ||
| f"{EVAL_AGENT_SERVER_IMAGE}:{sdk_short_sha}-{custom_tag}{suffix}" | ||
| f"{EVAL_AGENT_SERVER_IMAGE}:{IMAGE_TAG_PREFIX}-{custom_tag}{suffix}" | ||
| ) | ||
|
|
||
| if not image_exists(agent_server_image): | ||
|
|
@@ -217,7 +236,7 @@ def prepare_workspace( | |
|
|
||
| logger.info( | ||
| f"Using remote workspace with image {agent_server_image} " | ||
| f"(sdk sha: {sdk_short_sha}, resource_factor: {resource_factor})" | ||
| f"(tag prefix: {IMAGE_TAG_PREFIX}, resource_factor: {resource_factor})" | ||
| ) | ||
| startup_timeout = float(os.getenv("REMOTE_RUNTIME_STARTUP_TIMEOUT", "600")) | ||
| workspace = APIRemoteWorkspace( | ||
|
|
@@ -578,7 +597,10 @@ def evaluate_instance( | |
|
|
||
| def main() -> None: | ||
| prompt_dir = (Path(__file__).parent / "prompts").resolve() | ||
| choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")] | ||
| try: | ||
| choices = [str(p.relative_to(Path.cwd())) for p in prompt_dir.glob("*.j2")] | ||
| except ValueError: | ||
| choices = [str(p) for p in prompt_dir.glob("*.j2")] | ||
|
Comment on lines
+600
to
+603
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here about the defensive try/except. |
||
| default_prompt_path = prompt_dir / "default.j2" | ||
| assert default_prompt_path.exists(), ( | ||
| f"Default prompt {default_prompt_path} not found" | ||
|
|
@@ -605,12 +627,7 @@ def main() -> None: | |
| if args.max_attempts < 1: | ||
| raise ValueError(f"max_attempts must be >= 1, got {args.max_attempts}") | ||
|
|
||
| llm_config_path = args.llm_config_path | ||
| if not os.path.isfile(llm_config_path): | ||
| raise ValueError(f"LLM config file {llm_config_path} does not exist") | ||
| with open(llm_config_path, "r") as f: | ||
| llm_config = f.read() | ||
| llm = LLM.model_validate_json(llm_config) | ||
| llm = load_llm_config(args.llm_config_path) | ||
| logger.info("Using LLM config: %s", llm.model_dump_json(indent=2)) | ||
|
|
||
| dataset_description = ( | ||
|
|
@@ -630,6 +647,7 @@ def main() -> None: | |
| dataset=args.dataset, | ||
| dataset_split=args.split, | ||
| max_iterations=args.max_iterations, | ||
| conversation_timeout=args.conversation_timeout, | ||
| eval_output_dir=structured_output_dir, | ||
| details={}, | ||
| prompt_path=args.prompt_path, | ||
|
|
@@ -639,6 +657,7 @@ def main() -> None: | |
| critic=create_critic(args), | ||
| selected_instances_file=args.select, | ||
| max_retries=args.max_retries, | ||
| skip_failed_samples=args.skip_failed_samples, | ||
| workspace_type=args.workspace, | ||
| ) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: do we need this fallback? in which cases would the build fail? Could a retry mechanism not be enough?