Skip to content
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

feat: Python Verifier implementation #1702

Merged
merged 12 commits into from
Mar 4, 2025
Merged

feat: Python Verifier implementation #1702

merged 12 commits into from
Mar 4, 2025

Conversation

hallerite
Copy link
Collaborator

@hallerite hallerite commented Mar 4, 2025

Description

This PR adds a first implementation of a PythonVerifier that is reusable for anything that is only dependent on Python packages.

This PR also includes a example usage, showing the verifier in action.

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have read the CONTRIBUTION guide (required)
  • I have linked this PR to an issue using the Development section on the right sidebar or by adding Fixes #issue-number in the PR description (required)
  • I have checked if any dependencies need to be added or updated in pyproject.toml and poetry.lock
  • I have updated the tests accordingly (required for a bug fix or a new feature)
  • I have updated the documentation if needed:
  • I have added examples if this is a new feature

@Wendong-Fan Wendong-Fan changed the title feat: a first Verifier implementation feat: Python Verifier implementation Mar 4, 2025
Copy link
Collaborator

@zjrwtx zjrwtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @hallerite , the docstring need to be polished

@hallerite hallerite requested a review from zjrwtx March 4, 2025 17:08
@hallerite
Copy link
Collaborator Author

Should be good now.

Copy link
Member

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hallerite , left some comments, we also need to add test code

Comment on lines 48 to 51
self,
python_version: str = "python3",
timeout: Optional[float] = 30.0,
required_packages: Optional[List[str]] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we let user use interpreters integrated in camel for code execution? https://github.com/camel-ai/camel/tree/master/camel/interpreters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a good feature request for later. As of now, we can just leave it like this so we can accelerate the Loong project.

@hallerite
Copy link
Collaborator Author

Tests added.

Copy link
Collaborator

@HxyScotthuang HxyScotthuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hallerite hallerite requested a review from Wendong-Fan March 4, 2025 19:04
Copy link
Member

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hallerite , added one more commit af71fd4 to fix comment below, feel free to check

Defaults to an empty list.
"""
super().__init__(timeout=timeout)
self.python_version = python_version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used

venv.create(self.venv_path, with_pip=True)
logger.info(f"Virtual environment created at {self.venv_path}")

venv_pip = os.path.join(self.venv_path, "bin", "pip")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path for different system could be different

if process.returncode == 0:
# If ground truth is provided, compare it with the result
if result.ground_truth is not None:
if output_result == str(result.ground_truth).strip():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be problematic if there are whitespace differences or line ending differences

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an area that will have to be improved in general. We will need to use math-verify or extractors for more comprehensive semantic matching.


def __init__(
self,
python_version: str = "python3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is not used

@hallerite
Copy link
Collaborator Author

Thank you @Wendong-Fan

@hallerite hallerite merged commit f47897c into master Mar 4, 2025
6 checks passed
@hallerite hallerite deleted the feat/sympy-env branch March 4, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants