-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
132 additions
and
132 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Binary file added
BIN
+55.6 KB
src/inspect_ai/tool/_tools/_resources/shared_container/inspect_multi_tool-0.1.0.tar.gz
Binary file not shown.
This file contains 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 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,8 @@ | ||
[MASTER] | ||
; R - Refactorings | ||
; C - Convention | ||
; W - Warning | ||
; E - Error | ||
enable=C,R,W,E | ||
disable=R0903,C0114,C0115,C0116,C0301,C0411,C1804,C1805,W0120,W0511,W0718,W1203,E0401,E1101,E0611,E1128 | ||
score=no |
2 changes: 1 addition & 1 deletion
2
src/eric_testing/MANIFEST.in → src/inspect_tool_container/MANIFEST.in
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
include README.md | ||
include LICENSE | ||
recursive-include src/inspect_multi_tool *.py *.svg *.md | ||
recursive-include src/inspect_tool_container *.py *.svg *.md | ||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[cod] | ||
recursive-exclude * *$py.class |
This file contains 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,40 @@ | ||
# Multi-tool Shared Image | ||
|
||
 | ||
|
||
## Stateless / Stateful Design | ||
|
||
Inspect calls into the sandboxed image are done statelessly via `docker exec python multi-tool.py`. | ||
|
||
Some tools can be implemented without the need for any in-process state. For those tools, the tool code will be executed within the `multi-tool.py` process. | ||
|
||
For tools that require the maintenance of state over the lifetime of and sandbox, this image marshals tool calls into a long running process via JSON RPC to an http server process. That server then dispatches tool calls to tool specific `@method` handlers. | ||
|
||
### Stateful Tool Design Pattern | ||
|
||
Each stateful tool should have its own subdirectory that contains the following files: | ||
|
||
- `json_rpc_methods.py` | ||
|
||
This module contains all of the JSON RPC `@method` functions — one for each tool (e.g. the web browser tool is actually a set of distinct tools). It is responsible for unpacking the JSON RPC request and forwarding the call to a transport-agnostic, strongly typed, stateful controller. | ||
|
||
- `tool_types.py` | ||
|
||
This module includes the `pydantic` models representing the types for tool call parameters and results. | ||
|
||
- `controller.py` | ||
|
||
This is transport-agnostic, strongly typed code that manages the tool specific in-process state and performs requested commands. | ||
|
||
## Compatibility | ||
|
||
The Inspect framework will insure that the most recently published image of a particular tag will be downloaded when an eval is executed. This means that, from a cross-version perspective, we only have to worry about old tool code interacting with newer container code. The inverse is not possible. | ||
|
||
Because of this, when publishing new _major version_ images, care must be taken to retain the old version entrypoint called by tools. | ||
|
||
For example, older versions of the `web_browser_tool()` performed `docker exec`'s against `/app/web_browser/web_client.py` and `/app/web_browser/web_client_new_session.py`. A newer version of the image changed the entry point to `/opt/inspect/multi-tool-v1.py`. | ||
|
||
This means that newer versions of the image **must** retain the old entry points in a backwardly compatible way. Typically, the implementation of those old entry points will be updated to adapt and call the new version of the code. | ||
|
||
> [!TIP] | ||
> For this reason, it is a best practice to include a version number in the filename of the `docker exec` entry points. |
File renamed without changes.
This file contains 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 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
File renamed without changes
16 changes: 16 additions & 0 deletions
16
src/inspect_tool_container/src/inspect_tool_container/__init__.py
This file contains 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,16 @@ | ||
""" | ||
Sandbox container tool code for inspect_ai. | ||
Contains tools for web browser, bash, and editor functionality. | ||
""" | ||
|
||
__version__ = "0.1.0" | ||
|
||
from inspect_tool_container._util._constants import SERVER_PORT | ||
from inspect_tool_container._util._load_tools import load_tools | ||
|
||
__all__ = [ | ||
"__version__", | ||
"SERVER_PORT", | ||
"load_tools", | ||
] |
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ing/src/inspect_multi_tool/_cli/server.py → ...src/inspect_tool_container/_cli/server.py
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
8 changes: 5 additions & 3 deletions
8
...process_tools/_editor/json_rpc_methods.py → ...process_tools/_editor/json_rpc_methods.py
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
..._tools/_web_browser/accessibility_tree.py → ..._tools/_web_browser/accessibility_tree.py
This file contains 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
6 changes: 3 additions & 3 deletions
6
...s/_web_browser/accessibility_tree_node.py → ...s/_web_browser/accessibility_tree_node.py
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.