Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
📚 Mintlify Preview Links✨ Added (8 total)📄 Pages (8)
📝 Changed (1 total)⚙️ Other (1)
🤖 Generated automatically when Mintlify deployment succeeds |
🔗 Link Checker ResultsChecked against: https://wb-21fd5541-sandboxes.mintlify.app Summary
Errors per inputErrors in sandboxes.mdx
|
ReviewOverall the docs are well-structured and cover the right topics. The API patterns are mostly accurate against the SDK. Flagging the following issues before merge. Must Fix1. Both show: sandbox.wait_until_complete(timeout=3600.0)
print(f"Exit code: {sandbox.returncode}")
sandbox.wait_until_complete(timeout=3600.0).result()
print(f"Exit code: {sandbox.returncode}")2. Credential propagation claim is inaccurate
This is not true today. W&B credentials authenticate you to the sandbox service (creating/managing sandboxes via ATC), but they are not propagated inside the sandbox container. Code running inside the sandbox has no access to your W&B API key, so Suggested rewrite: "Sandboxes authenticate using your existing W&B credentials. To use W&B or Weave inside a sandbox, pass your API key using the Secrets Manager or environment variables." 3. sandbox.exec(["echo", "Hello, world.", ">", "hello.txt"]).result()When args are passed as a list, sandbox.exec(["sh", "-c", "echo 'Hello, world.' > hello.txt"]).result()Also, 4. LangChain agent tutorial should be replaced LangChain is a direct competitor. We should not be featuring their library in our docs. Beyond the competitive concern, the code has technical issues:
Recommend replacing with a framework-agnostic example, or using Weave. 5. This is the only place in the docs that imports from Should Fix6. Typos
7. Links use 8. Line number references off by 2 "Lines 29-31" should be "Lines 27-29" (the three print statements). "Lines 35-36" should be "Lines 33-34" (read_file and write_bytes). 9. |
|
|
||
| ## Wait for a sandbox to start | ||
|
|
||
| Use `Sandbox.wait()` when you want to confirm that the sandbox starts (sandbox reached RUNNING state) successfully before performing other operations, or when you want to separate startup errors from later command errors. |
There was a problem hiding this comment.
This is a pattern that's generally not that useful.
IIRC Under the hood, we implicitly wait on any call (exec, read, write.... ??).
with Sandbox.run() as sandbox:
sandbox.exec() # waits until sandbox is ready and then calls the exec
| from wandb.sandbox import Sandbox | ||
|
|
||
| with Sandbox.run("sleep", "infinity") as sandbox: | ||
| sandbox.stop().result() |
There was a problem hiding this comment.
Also a pattern that's helpful but generally not that useful.
The python context manager will clean up on exit
with ContextManagerThing as sandbox:
sandbox.do_stuff()
# automatically cleaned up when it hits this line (aka exits the context)
We should highlight this context manager usage since it's more ergonomic than calling stop on sandboxes
| ```python | ||
| from wandb.sandbox import Sandbox | ||
|
|
||
| sandbox = Sandbox.run("python", "train.py") |
There was a problem hiding this comment.
I'd need to double check but this I think is the fire and forget pattern.
They could then get the result by calling sandbox.wait_until_complete().result()
| from wandb.sandbox import Sandbox | ||
|
|
||
| sandbox = Sandbox.run("python", "train.py") | ||
| sandbox.wait_until_complete(timeout=3600.0) |
There was a problem hiding this comment.
result = sandbox.wait_until_complete(timeout=3600.0).result() ?
should probably highlight how to get a result if they want one.
| from wandb.sandbox import Sandbox | ||
|
|
||
| with Sandbox.run() as sandbox: | ||
| result = sandbox.exec(["pip", "install", "torch"], check=True).result() |
There was a problem hiding this comment.
I think we could leave the check=True out of this example for now. the param name is a little confusing about what it does and is perhaps noisy to introduce something like this without explaining it as well.
| print(result.stdout) | ||
| ``` | ||
|
|
||
| The `Sandbox.exec()` method runs a command inside a running sandbox and returns a `Process` object that you can use to wait for completion, read output, and inspect the exit code. |
| @@ -0,0 +1,93 @@ | |||
| --- | |||
| title: File access | |||
There was a problem hiding this comment.
File Operations perhaps makes the most sense.
| sandbox.write_file("hello.txt", text_file.read_bytes()).result() | ||
| ``` | ||
|
|
||
| See the `Sandbox` class reference documentation for a full list of parameters and options for [`Sandbox.write_file()`](https://docs.coreweave.com/products/coreweave-sandbox/client/ref/core/sandbox#write_file). |
There was a problem hiding this comment.
Generally speaking, would be good to link to the class as well. I find myself wanting to click Thing whenever I see it
| ] | ||
|
|
||
| print("Starting sandbox...") | ||
| with Sandbox.run(mounted_files=mounted_files) as sandbox: |
There was a problem hiding this comment.
Oh wow. This is a documentation gap in the CW docs. We'll need to update this. @NavarrePratt FYI
There was a problem hiding this comment.
I deprioritized this because I don't want to push the mounting files thing that hard because it's extremely likely it changes once we get to implementing the CAIOS integration. I'd rather people use read and write file for now. I'm pretty sure this mount file thing is leftover from the swebaas hackathon idea.
| @@ -0,0 +1,179 @@ | |||
| --- | |||
| title: "Tutorial: Invoke an agent in a sandbox" | |||
| description: "Learn how to invoke a LangChain agent within a sandbox environment" | |||
There was a problem hiding this comment.
Should we be cross-selling the WB Agent here instead of Langchain?
|
|
||
| For more in-depth examples, see: | ||
|
|
||
| * [W&B Sandbox tutorial](/sandboxes/invoke_agent_sandbox_tutorial) |
There was a problem hiding this comment.
Should this be cross selling the WB-Agent? Seems weird to provide a tutorial for another company's product.
|
|
||
| The previous code snippet does the following: | ||
|
|
||
| 1. (Lines 6 - 9) Mount files to the sandbox at startup. The `mounted_files` parameter in `Sandbox.run()` allows you to specify a list of files to mount into the sandbox at startup. Each file is represented as a dictionary with two keys: `mount_path`, which specifies the path where the file will be mounted inside the sandbox, and `file_content`, which contains the content of the file as bytes. In this example, you mount `train.py` and `requirements.txt` into the sandbox. |
There was a problem hiding this comment.
I wonder if these are better as inline comments. 🤷
| print(result.stdout) | ||
| ``` | ||
|
|
||
| ## Extract a field from a structured secret |
There was a problem hiding this comment.
I don't think we actually support this with W&B Secrets Manager
| container_image="python:3.13", | ||
| network=NetworkOptions(egress_mode="internet"), | ||
| max_lifetime_seconds=3600, | ||
| environment_variables={"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]}, |
There was a problem hiding this comment.
Let's use a secret here to promote better practices 😅
Description
W&B Sandboxes (Private Preview). Currently documents: