Skip to content

feat: Improve inference CLI and update tests - #166

Merged
andrea-gariboldi merged 23 commits into
mainfrom
test_standards
Sep 28, 2026
Merged

andrea-gariboldi merged 23 commits into
mainfrom
test_standards

Conversation

@MartinekV

Copy link
Copy Markdown
Collaborator

This PR

  • adds CLI inference support for using any model artifacts (e.g. from a retrained model)
  • fixes forking bugs
    • now it uses the actual forked run config, not the original run's
    • environment recreation bug that potentially prevented forked runs from installing new packages
  • update codebase to expose better testing interfaces
  • establishes testing standards
  • revamp existing tests to meet those standards (added, removeed, and updated the whole test suite)
  • dientangle the test runner from agentomics-run
  • introduce end-to-end tests

I wasnt able to run GPU tests, so please run them on a GPU machine during the review

@andrea-gariboldi
andrea-gariboldi self-requested a review September 9, 2026 09:39
f"must be symbolic links, not copies. Up to first 10: {names}"
)

CLASSIFICATION_MINI_TRAIN_SAMPLES_PER_CLASS = 100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would keep these two class constants (lines 86 and 87) above the definition of the validate_generated_split method (like we had before this change)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implemented

Comment thread src/agentomics/runtime/setup_fork.py Outdated
agent_id=target_agent_id,
workspace_dir=str(target_workspace_dir),
)
save_config(target_config)

@andrea-gariboldi andrea-gariboldi Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this save necessary? The config file would be saved regardless at the beginning of the (forked) run, in initialize_run (line 84 of run_agent.py). Could we leave target_config in memory for environment restoration and let initialization persist the final config?

Unrelated to your changes: I would rename the save_config method to something that communicates about saving to file (e.g. write_config_file, or save_config_to_file)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Config is loaded from the filesystem through the run - we need to update it with the new agent id, otherwise it will still have the old runs agent id. Currently this doesnt have any bugs linked to it afaik, but there could be a time where that discrepancy introduces a new bug.
Renaming was implemented.

@andrea-gariboldi andrea-gariboldi self-assigned this Sep 10, 2026
return None

def create_model(self, model_name: str, config: Config) -> OpenAIModel:
def create_model(self, model_name: str, config: Config) -> Model:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As providers can now return a generic Model type, should this method return a generic Model and not a OpenAIModel (line 109)? As well the docstring now is mentioning OpenAI sdk friendly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The Model is an abstract class. We should keep the default OpenAI model return here since its the most widely compatible one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense. I was trying to point out the inconsistency between code and docstring, your change in the dostring is satisfactory from my end

Comment thread test/test_environment_recreation.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we retain the environment-export regression scenarios covering Conda overwriting pip packages, differing Conda/pip package names, and base-environment package leakage? These tests existed because those interactions are difficult to predict. The replacement mixed-environment test doesn’t cover all of them. Rewriting them through the production export/recreation interfaces makes sense, but I’d preserve the scenarios.
In particular I am referring to:
test_graphviz_pip_conda_name_mismatch_survives_recreation,
test_graphviz_conda_only_survives_recreation,
test_pip_before_conda_order_survives_recreation,
test_export_captures_actual_version_after_conda_overwrites_pip,
test_export_excludes_phantom_packages_from_base_env

Let me know what you think.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implemented these and added some reasonable parametrizable tests that could be easily expanded in the future if we find failing cases.
Skipped test_export_excludes_phantom_packages_from_base_env since i dont think it covers a realistic regression.

Comment thread src/agentomics/cli/inference.py Outdated
default=Path(Config.BEST_ITERATION_SNAPSHOT_DIRNAME),
help="Iteration directory relative to --agent-dir",
)
parser.add_argument(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we put --all-iterations and --artifacts-dir in a parser.add_mutually_exclusive_group()? This would reject the combination during
parsing with a standard CLI error.

If you are applying this change, the test test_inference_requires_one_iteration_when_artifacts_are_supplied in tests/unit/test_inference_cli.py would need to expect SystemExit with code 2 during parsing instead of ValueError during execution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implemented

Comment thread scripts/run_tests.py
validate_docker_gpu_access(image)

container_name = f"agentomics-tests-{uuid4().hex}"
docker_arguments = ["--name", container_name, "--pull", "never"]

@andrea-gariboldi andrea-gariboldi Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implemented

environment = {
key: value for key, value in os.environ.items()
if key in {
"PATH", "DOCKER_HOST", "DOCKER_CONTEXT", "DOCKER_CONFIG",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In here the proxy vars should be forwarded as end-to-end workflows recreate conda environments which require network access.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implemented

Comment thread scripts/run_tests.py
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()

Copy link
Copy Markdown
Contributor

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.

@MartinekV MartinekV Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

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)

@andrea-gariboldi andrea-gariboldi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good job on this. I left some minor comments.
I can confirm I run the tests on a machine with GPU, and the tests are passing.

@andrea-gariboldi

Copy link
Copy Markdown
Contributor

Small additional note: I was able to run the tests on our server after patching mysefl the proxy env vars forwarding.

@andrea-gariboldi andrea-gariboldi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comments from round 1 have been addressed. I added a very small cleanup of an import.

@andrea-gariboldi
andrea-gariboldi merged commit dc353bb into main Sep 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants