Repository navigation
feat: Improve inference CLI and update tests #166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8163f0e
Expose runtime seams for deterministic tests
MartinekV c443b1f
Fix forked run environment restoration
MartinekV 474ec0c
Replace the legacy tests with pytest suites
MartinekV 454f12c
Add scripted end-to-end workflow tests
MartinekV 6c0f9b5
Separate test execution from the agent run CLI
MartinekV a4f0f84
Support custom inference artifact directories
MartinekV ea987c4
Document the project testing standard
MartinekV 99a77b1
Merge branch 'main' into test_standards
MartinekV 8ef7675
Propagate proxy vars into test docker images
MartinekV db24ea2
Move mini train size constants
MartinekV 21e0a39
Improve inference arg parsing of artifacts dir
MartinekV b963b89
Update save config fn name
MartinekV d9277e7
Adjust create_model docstring
MartinekV 05e0353
Forward proxy vars to test containers
MartinekV 1bf91a1
Add no proxy env var passing across docker containers
MartinekV bcdd0aa
Fix proxy env passing to test containers
MartinekV 1e89ec7
Update pip package replacement test
MartinekV a493d6b
Preserve same-named but logically distinct-from-pip conda packages in…
MartinekV be17649
Correctly remove pip-replaced conda packages from env export
MartinekV f09c9d0
Update gitignore
MartinekV 1bab623
Fix pip re-installation test
MartinekV 3d3e674
Defer a failing env recreation test
MartinekV 88cc3df
Fix import line duplication
andrea-gariboldi 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
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
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 |
|---|---|---|
|
|
@@ -20,3 +20,4 @@ dependencies: | |
| - uv==0.9.26 | ||
| - openai==2.16.0 | ||
| - anthropic==0.79.0 | ||
| - pytest==9.1.1 | ||
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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import os | ||
| from pathlib import Path | ||
| import subprocess | ||
| import sys | ||
| from uuid import uuid4 | ||
|
|
||
| from agentomics.cli.docker_utils import ( | ||
| build_development_image, | ||
| run_python_in_docker, | ||
| validate_docker_gpu_access, | ||
| resolve_proxy_env_vars, | ||
| ) | ||
|
|
||
|
|
||
| def main(argv: list[str] | None = None) -> int: | ||
| parser = argparse.ArgumentParser( | ||
| description="Run unit/integration tests in Docker, then end-to-end tests on the host.", | ||
| allow_abbrev=False, | ||
| ) | ||
| parser.add_argument("--image", help="Reuse an already-built Docker image") | ||
| parser.add_argument("--cpu-only", action="store_true", help="Disable GPU access and GPU tests") | ||
| arguments = parser.parse_args(argv) | ||
|
|
||
| image = arguments.image or build_development_image() | ||
| result = subprocess.run( | ||
| ["docker", "image", "inspect", image], capture_output=True, text=True | ||
| ) | ||
| if result.returncode: | ||
| raise RuntimeError(f"Docker image {image!r} is unavailable: {result.stderr.strip()}") | ||
| if not arguments.cpu_only: | ||
| validate_docker_gpu_access(image) | ||
|
|
||
| container_name = f"agentomics-tests-{uuid4().hex}" | ||
| docker_arguments = ["--name", container_name, "--pull", "never"] | ||
|
Contributor
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. Among the arguments for the created containers, we should pass also the proxy env variables (if set).
Collaborator
Author
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. Implemented |
||
| for name, value in resolve_proxy_env_vars().items(): | ||
| docker_arguments.extend(["-e", f"{name}={value}"]) | ||
| if arguments.cpu_only: | ||
| docker_arguments.extend(["-e", "CUDA_VISIBLE_DEVICES="]) | ||
| try: | ||
| container_exit = run_python_in_docker( | ||
| image=image, | ||
| cpu_only=arguments.cpu_only, | ||
| mounts=[], | ||
| python_arguments=["-m", "pytest", "tests/unit", "tests/integration"], | ||
| docker_arguments=docker_arguments, | ||
| check=False, | ||
| ) | ||
| finally: | ||
| # --rm does not cover interruption of the Docker client. | ||
| subprocess.run( | ||
| ["docker", "rm", "--force", container_name], | ||
| stdout=subprocess.DEVNULL, | ||
| stderr=subprocess.DEVNULL, | ||
| ) | ||
|
|
||
| host_exit = subprocess.run( | ||
| [sys.executable, "-m", "pytest", "tests/end_to_end"], | ||
| cwd=Path(__file__).resolve().parents[1], | ||
| env=os.environ | { | ||
| "AGENTOMICS_TEST_IMAGE": image, | ||
| "AGENTOMICS_TEST_CPU_ONLY": "1" if arguments.cpu_only else "0", | ||
| }, | ||
| ).returncode | ||
| return int(bool(container_exit or host_exit)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
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.
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.
The development image-build path needs the proxy support from PR #164. Could we incorporate that change once merged? In here build_development_image() is called, so no separate build-proxy implementation should be needed here.
Uh oh!
There was an error while loading. Please reload this page.
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.
This is automatically solved by merging with main that includes PR 164 since the proxy env variables are automatically fetched from the .env file
(will rebase)