-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Automatically serialize test dependencies #5
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
Conversation
Mesa DescriptionThis PR introduces a fundamental change in how test functions are executed in the container. Instead of recompiling the test function's source code inside the container, we now use This new approach automatically handles module-level dependencies like imports, constants, and helper functions, making it much easier to write tests that run in a container. Key Changes:
Description generated by Mesa. Update settings |
Add cloudpickle as a dependency for serializing test functions to containers instead of rpyc teleport. This enables closure and lambda support. - Add cloudpickle>=3.1.1 to pyproject.toml dependencies - Install cloudpickle in container alongside rpyc and pytest - Add run_pickled() helper that serializes a callable with cloudpickle, sends it to the container via rpyc, and executes it remotely - Update version mismatch error message to reference pickle compatibility
6030f79 to
6f7cb94
Compare
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.
Performed full review of 9b8303a...203e039
Analysis
-
Critical centralization risk: All execution paths now funnel through
_container.run_pickled, creating a single point of failure where any import errors or serialization issues would block all consumers. -
Dependency vulnerability: The system now relies heavily on cloudpickle for serialization, introducing a new external dependency that must be properly bootstrapped in containers.
-
Code organization concern: Helper routines for function rewriting (
_make_picklable,_force_by_value) are embedded in_containerrather than in a dedicated utility module, potentially mixing responsibilities. -
Implementation stability risk: The marker/decorator wrappers now act as thin delegators to shared implementation in
_container, meaning their correctness depends on import-time availability of these shared components.
Tip
Help
Slash Commands:
/review- Request a full code review/review latest- Review only changes since the last review/describe- Generate PR description. This will update the PR body or issue comment depending on your configuration/help- Get help with Mesa commands and configuration options
6 files reviewed | 3 comments | Edit Agent Settings • Read Docs
| clone = types.FunctionType( | ||
| func.__code__, | ||
| clean_globals, | ||
| func.__name__, |
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.
Callable is now imported only under TYPE_CHECKING, but this module doesn’t use from __future__ import annotations. The annotations in _make_picklable, _force_by_value, and run_pickled are therefore evaluated at import time, and Callable is undefined. Importing pytest_in_docker._container will immediately raise NameError: name 'Callable' is not defined, so none of the container helpers can be used. Please import Callable unconditionally (or enable postponed evaluation of annotations) before referencing it in runtime annotations.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: mesa-dot-dev/pytest-in-docker#5
File: pytest_in_docker/_container.py#L235
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
`Callable` is now imported only under `TYPE_CHECKING`, but this module doesn’t use `from __future__ import annotations`. The annotations in `_make_picklable`, `_force_by_value`, and `run_pickled` are therefore evaluated at import time, and `Callable` is undefined. Importing `pytest_in_docker._container` will immediately raise `NameError: name 'Callable' is not defined`, so none of the container helpers can be used. Please import `Callable` unconditionally (or enable postponed evaluation of annotations) before referencing it in runtime annotations.
| import textwrap | ||
| from collections.abc import Callable | ||
| from typing import Any, ParamSpec, TypeVar, overload | ||
| from typing import TYPE_CHECKING, ParamSpec, TypeVar, overload |
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.
Callable was moved under TYPE_CHECKING, but this module doesn’t postpone annotation evaluation. The overloads and decorator signature (Callable[[Callable[P, T]], Callable[P, T]], etc.) are executed when the module imports, so Callable is missing at runtime and the import raises NameError. That prevents users from importing pytest_in_docker.in_container entirely. Please keep Callable as a real import (or add from __future__ import annotations) so the annotations can resolve.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: mesa-dot-dev/pytest-in-docker#5
File: pytest_in_docker/_decorator.py#L3
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
`Callable` was moved under `TYPE_CHECKING`, but this module doesn’t postpone annotation evaluation. The overloads and decorator signature (`Callable[[Callable[P, T]], Callable[P, T]]`, etc.) are executed when the module imports, so `Callable` is missing at runtime and the import raises `NameError`. That prevents users from importing `pytest_in_docker.in_container` entirely. Please keep `Callable` as a real import (or add `from __future__ import annotations`) so the annotations can resolve.
|
|
||
| ```python | ||
| from pytest_in_docker import in_container | ||
| import subprocess |
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 sample now uses the marker form (@pytest.mark.in_container) but the snippet no longer imports pytest, so copying it verbatim raises NameError. Either add import pytest to this block or revert the example back to the decorator version to keep it self‑contained.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: mesa-dot-dev/pytest-in-docker#5
File: README.md#L65
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
This sample now uses the marker form (`@pytest.mark.in_container`) but the snippet no longer imports `pytest`, so copying it verbatim raises `NameError`. Either add `import pytest` to this block or revert the example back to the decorator version to keep it self‑contained.
No description provided.