-
Notifications
You must be signed in to change notification settings - Fork 2
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
SANDBOX
log level deprecation
#44
Merged
Merged
Conversation
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
craigwalton-dsit
commented
Jan 3, 2025
craigwalton-dsit
force-pushed
the
craig/sandbox-log-level-deprecation
branch
2 times, most recently
from
January 3, 2025 12:19
e2becef
to
32b257d
Compare
Here is the await sandbox().exec(["echo", "Hello, world!"])
await sandbox().read_file("/etc/fake") [
{
"timestamp": "2025-01-03T12:23:33.212484",
"level": "TRACE",
"message": "Subprocess: helm version --short (enter)",
"action": "Subprocess",
"event": "enter",
"trace_id": "H3HUrwrmkRRcdgvC35sacK",
"detail": "helm version --short",
"start_time": 1735907013.2124557,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:33.306512",
"level": "TRACE",
"message": "Subprocess: helm version --short (exit)",
"action": "Subprocess",
"event": "exit",
"trace_id": "H3HUrwrmkRRcdgvC35sacK",
"detail": "helm version --short",
"duration": 0.0940287090052152,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:34.171327",
"level": "TRACE",
"message": "K8s install Helm chart: {\"chart\": \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/resources/helm/agent-env\", \"release\": \"wc3wp4ys\", \"values\": \"None\", \"namespace\": \"agent\", \"task\": \"my_task\"} (enter)",
"action": "K8s install Helm chart",
"event": "enter",
"trace_id": "BLgPH27yW3FHxcHbXvPRt3",
"detail": "{\"chart\": \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/resources/helm/agent-env\", \"release\": \"wc3wp4ys\", \"values\": \"None\", \"namespace\": \"agent\", \"task\": \"my_task\"}",
"start_time": 1735907014.171301,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.330657",
"level": "TRACE",
"message": "K8s install Helm chart: {\"chart\": \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/resources/helm/agent-env\", \"release\": \"wc3wp4ys\", \"values\": \"None\", \"namespace\": \"agent\", \"task\": \"my_task\"} (exit)",
"action": "K8s install Helm chart",
"event": "exit",
"trace_id": "BLgPH27yW3FHxcHbXvPRt3",
"detail": "{\"chart\": \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/resources/helm/agent-env\", \"release\": \"wc3wp4ys\", \"values\": \"None\", \"namespace\": \"agent\", \"task\": \"my_task\"}",
"duration": 5.159330975991907,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.360260",
"level": "TRACE",
"message": "[K8s] Available sandboxes: ['default']"
},
{
"timestamp": "2025-01-03T12:23:39.361150",
"level": "TRACE",
"message": "K8s execute command in Pod: {\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"cmd\": \"['echo', 'Hello, world!']\", \"stdin\": \"None\", \"cwd\": \"None\", \"env\": \"{}\", \"timeout\": \"None\"} (enter)",
"action": "K8s execute command in Pod",
"event": "enter",
"trace_id": "5tAWFGHx2uQZ2ra9Wosr3H",
"detail": "{\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"cmd\": \"['echo', 'Hello, world!']\", \"stdin\": \"None\", \"cwd\": \"None\", \"env\": \"{}\", \"timeout\": \"None\"}",
"start_time": 1735907019.3611326,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.361315",
"level": "TRACE",
"message": "[K8s] Creating PodOpExecutor. {\"max_workers\": \"64\"}"
},
{
"timestamp": "2025-01-03T12:23:39.502075",
"level": "TRACE",
"message": "[K8s] Completed: K8s execute command in Pod. {\"cmd\": \"['echo', 'Hello, world!']\", \"stdin\": \"None\", \"cwd\": \"None\", \"env\": \"{}\", \"timeout\": \"None\", \"result\": \"ExecResult(success=True, returncode=0, stdout='Hello, world!\\\\n', stderr='')\"}"
},
{
"timestamp": "2025-01-03T12:23:39.502209",
"level": "TRACE",
"message": "K8s execute command in Pod: {\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"cmd\": \"['echo', 'Hello, world!']\", \"stdin\": \"None\", \"cwd\": \"None\", \"env\": \"{}\", \"timeout\": \"None\"} (exit)",
"action": "K8s execute command in Pod",
"event": "exit",
"trace_id": "5tAWFGHx2uQZ2ra9Wosr3H",
"detail": "{\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"cmd\": \"['echo', 'Hello, world!']\", \"stdin\": \"None\", \"cwd\": \"None\", \"env\": \"{}\", \"timeout\": \"None\"}",
"duration": 0.1410653100028867,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.502476",
"level": "TRACE",
"message": "K8s read file from Pod: {\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"file\": \"/etc/fake\"} (enter)",
"action": "K8s read file from Pod",
"event": "enter",
"trace_id": "ZqfnRFFmE5DTqpjSWcovVT",
"detail": "{\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"file\": \"/etc/fake\"}",
"start_time": 1735907019.502465,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.648277",
"level": "TRACE",
"message": "K8s read file from Pod: {\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"file\": \"/etc/fake\"} (error)",
"action": "K8s read file from Pod",
"event": "error",
"trace_id": "ZqfnRFFmE5DTqpjSWcovVT",
"detail": "{\"pod\": \"agent-env-wc3wp4ys-default-0\", \"task_name\": \"my_task\", \"file\": \"/etc/fake\"}",
"duration": 0.14460575599514414,
"error": "head: cannot open '/etc/fake' for reading: No such file or directory\n",
"error_type": "FileNotFoundError",
"stacktrace": "Traceback (most recent call last):\n File \"/home/ubuntu/r/inspect_k8s_sandbox/.venv/lib/python3.12/site-packages/inspect_ai/_util/trace.py\", line 55, in trace_action\n yield\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_logger.py\", line 73, in inspect_trace_action\n yield\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_sandbox_environment.py\", line 201, in _log_op\n yield\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_sandbox_environment.py\", line 174, in read_file\n await self._pod.read_file(Path(file), temp_file)\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/pod.py\", line 108, in read_file\n await self._run_async(lambda: reader.read_file(src, dst))\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/pod.py\", line 113, in _run_async\n return await executor.queue_operation(callable)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/executor.py\", line 64, in queue_operation\n return await asyncio.get_event_loop().run_in_executor(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/concurrent/futures/thread.py\", line 58, in run\n result = self.fn(*self.args, **self.kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/pod.py\", line 108, in <lambda>\n await self._run_async(lambda: reader.read_file(src, dst))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/read.py\", line 21, in read_file\n self._handle_stream_output(ws_client, dst)\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/read.py\", line 55, in _handle_stream_output\n raise_for_known_read_write_errors(stderr_str)\n File \"/home/ubuntu/r/inspect_k8s_sandbox/src/k8s_sandbox/_pod/op.py\", line 101, in raise_for_known_read_write_errors\n raise FileNotFoundError(stderr)\nFileNotFoundError: head: cannot open '/etc/fake' for reading: No such file or directory\n\n",
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:39.653624",
"level": "TRACE",
"message": "K8s uninstall Helm chart: {\"release\": \"wc3wp4ys\", \"namespace\": \"agent\"} (enter)",
"action": "K8s uninstall Helm chart",
"event": "enter",
"trace_id": "Vo6mRGSDYPgfMC6jwAA2qw",
"detail": "{\"release\": \"wc3wp4ys\", \"namespace\": \"agent\"}",
"start_time": 1735907019.6536076,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:40.644737",
"level": "TRACE",
"message": "K8s uninstall Helm chart: {\"release\": \"wc3wp4ys\", \"namespace\": \"agent\"} (exit)",
"action": "K8s uninstall Helm chart",
"event": "exit",
"trace_id": "Vo6mRGSDYPgfMC6jwAA2qw",
"detail": "{\"release\": \"wc3wp4ys\", \"namespace\": \"agent\"}",
"duration": 0.9911043200118002,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:40.754066",
"level": "TRACE",
"message": "Log Write: /home/ubuntu/r/inspect_k8s_sandbox/logs/2025-01-03T12-23-33+00-00_my-task_3LRdMRwMXjGhih36PiBAes.eval (enter)",
"action": "Log Write",
"event": "enter",
"trace_id": "7PTNRquWgiy6WGDTkSJvyU",
"detail": "/home/ubuntu/r/inspect_k8s_sandbox/logs/2025-01-03T12-23-33+00-00_my-task_3LRdMRwMXjGhih36PiBAes.eval",
"start_time": 1735907020.7540398,
"pid": 61008
},
{
"timestamp": "2025-01-03T12:23:40.754984",
"level": "TRACE",
"message": "Log Write: /home/ubuntu/r/inspect_k8s_sandbox/logs/2025-01-03T12-23-33+00-00_my-task_3LRdMRwMXjGhih36PiBAes.eval (exit)",
"action": "Log Write",
"event": "exit",
"trace_id": "7PTNRquWgiy6WGDTkSJvyU",
"detail": "/home/ubuntu/r/inspect_k8s_sandbox/logs/2025-01-03T12-23-33+00-00_my-task_3LRdMRwMXjGhih36PiBAes.eval",
"duration": 0.0009293270122725517,
"pid": 61008
}
] |
craigwalton-dsit
commented
Jan 3, 2025
…(`TRACE` level).
…w that SANDBOX log level does not exist).
craigwalton-dsit
force-pushed
the
craig/sandbox-log-level-deprecation
branch
from
January 3, 2025 14:14
32b257d
to
b3a15c9
Compare
jasongwartz-aisi
approved these changes
Jan 3, 2025
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.
Looks good to me, nice improvement! I've left a couple non-blocking comments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
SANDBOX
log level was removed when theTRACE
log level and associated functionality (docs) was added to Inspect (PR).JJ recommended (Slack) using:
trace_action()
for any long running tasks that we'd like the lifecycle logged of (so in our case, Helm install/uninstall and Pod ops likeexec()
)trace_message()
for any other informational logging which used to be atSANDBOX
log level (like listing Pods, or loggingexec()
results)It is great that these logs will be automatically captured. Though there will be some added friction of dumping these logs, filtering them to just K8s-relevant ones (i.e. removing model API calls), then extracting just the relevant
message
to build up an equivalent view of what the oldSANDBOX
log level provided.