LoginJoin GenScrap

#sandbox

Tags liés

2 scraps publics avec le tag #sandbox

Daytona Sandbox:開発環境の新たな可能性
manual

# Daytona Sandbox:開発環境の新たな可能性 ## Daytona Sandboxとは Daytona Sandboxは、開発者がクラウド上で瞬時に開発環境を構築・共有できる革新的なプラットフォームです。従来のローカル開発環境の制約を取り払い、どこからでもアクセス可能な統一された開発体験を提供します。 ## 主な特徴 ### 1. 瞬時の環境構築 Gitリポジトリから数秒で完全な開発環境を立ち上げることができます。依存関係の解決やツールのセットアップは自動化されており、「動かない」というストレスから解放されます。 ### 2. チーム間での共有 作成した環境をURLで簡単に共有できるため、コードレビューやペアプログラミング、トラブルシューティングが格段に効率化されます。 ### 3. 一貫性の保証 開発者全員が同じ環境で作業するため、「私の環境では動く」問題が根本的に解決されます。 ## 開発ワークフローへの影響 Daytona Sandboxは特に以下のシーンで威力を発揮します: - **新しいプロジェクトの立ち上げ**:環境構築の時間を大幅短縮 - **オンボーディング**:新メンバーが即座に開発に参加可能 - **リモート開発**:デバイスに依存しない開発体験 ## まとめ Daytona Sandboxは開発環境の民主化を推し進める重要なツールです。クラウドネイティブな開発体験により、私たちはコードを書くことに集中し、環境の問題に悩まされることなく、より創造的な開発活動に時間を投資できるようになります。 現代の開発チームにとって、Daytona Sandboxのような標準化されたクラウド開発環境は、もはや選択肢ではなく必需品と言えるでしょう。

02/09/2025Voir
E2B example in Python
chatgpt

step-by-step E2B example in Python that shows stateful execution, installing packages, uploading a file, and doing a quick SQLite query—all inside a sandbox. --- ## 0) Install & set your key ```bash pip install e2b-code-interpreter python-dotenv export E2B_API_KEY="e2b_***" ``` E2B’s Python package is `e2b-code-interpreter`, and the SDK reads your `E2B_API_KEY` from env. ([PyPI][1]) --- ## 1) Minimal stateful sandbox script ```python # e2b_step_by_step.py import os from e2b_code_interpreter import Sandbox def main(): # Spins up an isolated VM ("sandbox"); auto-shuts down when the block exits with Sandbox() as sbx: # --- A) Stateful Python: variables persist across calls --- sbx.run_code("x = 41") out = sbx.run_code("x += 1; x") # reuses x print("x =", out.text) # -> 42 # --- B) Shell: install a package inside the sandbox --- sbx.commands.run("pip install --quiet pandas") # ok to pip-install at runtime # --- C) Upload a CSV into the sandbox filesystem --- csv = "name,age\nTaro,30\nHanako,28\n" sbx.files.write("/home/user/people.csv", csv) # --- D) Analyze the CSV in Python (pandas) --- out = sbx.run_code(r''' import pandas as pd df = pd.read_csv("/home/user/people.csv") df["age"].mean() ''') print("mean age:", out.text) # --- E) Quick SQLite session (persists objects across cells) --- sbx.run_code(r''' import sqlite3 conn = sqlite3.connect("/home/user/demo.db") cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS t(a INT)") cur.executemany("INSERT INTO t(a) VALUES (?)", [(1,), (2,), (3,)]) conn.commit() ''') out = sbx.run_code(r''' cur.execute("SELECT sum(a) FROM t") cur.fetchone()[0] ''') print("sum =", out.text) # --- F) Peek at files (via Python, no shell needed) --- out = sbx.run_code('import os; print(os.listdir("/home/user"))') print("files in /home/user:\n", "".join(out.logs.stdout)) if __name__ == "__main__": main() ``` **Why this works / what to know** * `Sandbox()` starts an isolated cloud VM where you can **run code repeatedly and reuse variables** (`run_code` shares state across calls). The returned `Execution` has `.text` (last expression) and `.logs.stdout` for prints. ([e2b.dev][2]) * You can **run shell commands** like `pip install …` via `sandbox.commands.run(...)`. ([Hugging Face][3]) * You can **upload files** into the sandbox with `sandbox.files.write(path, data)` (string/bytes/IO). ([e2b.dev][4]) * By default, a sandbox has a short idle timeout (\~5 minutes) unless you keep using it. ([e2b.dev][5]) --- ## 2) (Optional) Pause & resume the same sandbox later If you want the *exact* process memory and filesystem to persist (even running kernels), E2B has **persistence** (public beta): ```python from e2b_code_interpreter import Sandbox sbx = Sandbox() # create sbx.beta_pause() # save full state (ID: sbx.sandbox_id) same = Sandbox.connect(sbx.sandbox_id) # resume later and continue ``` This preserves files **and memory** (variables, processes) between sessions. ([e2b.dev][6]) --- ## 3) Useful docs you’ll likely reference * **Quickstart** (API key, first sandbox). ([e2b.dev][7]) * **Python SDK: `Sandbox.run_code`** (stateful cells; result fields). ([e2b.dev][2]) * **Filesystem read/write** (Python `files.write`, `files.read`, etc.). ([e2b.dev][4]) * **Install custom packages / runtime installs** (`pip install` in sandbox). ([e2b.dev][8]) * **Commands API (shell in sandbox)**. ([e2b.dev][9]) * **Cookbook examples** (more end-to-end Python demos). ([GitHub][10]) If you want, I can tailor this to your exact use case (e.g., connecting to Postgres/MySQL from inside the sandbox, or wiring this into your LLM/tool-calling flow). [1]: https://pypi.org/project/e2b-code-interpreter/?utm_source=chatgpt.com "e2b-code-interpreter" [2]: https://e2b.dev/docs/sdk-reference/code-interpreter-python-sdk/v1.2.1/sandbox "E2B - Code Interpreting for AI apps" [3]: https://huggingface.co/docs/smolagents/en/tutorials/secure_code_execution?utm_source=chatgpt.com "Secure code execution" [4]: https://e2b.dev/docs/sdk-reference/python-sdk/v1.5.2/sandbox_sync?utm_source=chatgpt.com "E2B - Code Interpreting for AI apps" [5]: https://e2b.dev/docs/quickstart "E2B - Code Interpreting for AI apps" [6]: https://e2b.dev/docs/sandbox/persistence "E2B - Code Interpreting for AI apps" [7]: https://e2b.dev/docs/quickstart?utm_source=chatgpt.com "Running your first Sandbox" [8]: https://e2b.dev/docs/quickstart/install-custom-packages?utm_source=chatgpt.com "Install custom packages" [9]: https://e2b.dev/docs/commands?utm_source=chatgpt.com "Running commands in sandbox" [10]: https://github.com/e2b-dev/e2b-cookbook?utm_source=chatgpt.com "e2b-dev/e2b-cookbook: Examples of using E2B"

30/08/2025Voir

Envie de créer votre propre contenu tagué ?

Commencer