e2b-code-interpreter 0.0.9a0__tar.gz → 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: e2b-code-interpreter
3
- Version: 0.0.9a0
3
+ Version: 0.0.10
4
4
  Summary: E2B Code Interpreter - Stateful code execution
5
5
  Home-page: https://e2b.dev/
6
6
  License: Apache-2.0
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Dist: e2b (>=0.17.1)
18
- Requires-Dist: pydantic (>1,<3)
18
+ Requires-Dist: pydantic
19
19
  Requires-Dist: websocket-client (>=1.7.0,<2.0.0)
20
20
  Project-URL: Bug Tracker, https://github.com/e2b-dev/code-interpreter/issues
21
21
  Project-URL: Repository, https://github.com/e2b-dev/e2b-code-interpreter/tree/python
@@ -23,7 +23,7 @@ class CodeInterpreter(Sandbox):
23
23
  E2B code interpreter sandbox extension.
24
24
  """
25
25
 
26
- template = "code-interpreter-multikernel"
26
+ template = "code-interpreter-stateful"
27
27
 
28
28
  def __init__(
29
29
  self,
@@ -161,7 +161,11 @@ class JupyterKernelWebSocket:
161
161
 
162
162
  :param data: The message data
163
163
  """
164
- parent_msg_ig = data["parent_header"]["msg_id"]
164
+ parent_msg_ig = data["parent_header"].get("msg_id", None)
165
+ if parent_msg_ig is None:
166
+ logger.warning("Parent message ID not found. %s", data)
167
+ return
168
+
165
169
  logger.debug(f"Received message {data['msg_type']} for {parent_msg_ig}")
166
170
 
167
171
  cell = self._cells.get(parent_msg_ig)
@@ -1,6 +1,6 @@
1
1
  import copy
2
2
  from typing import List, Optional, Iterable, Dict
3
- from pydantic import BaseModel, field_serializer
3
+ from pydantic import BaseModel
4
4
 
5
5
 
6
6
  class Error(BaseModel):
@@ -211,6 +211,19 @@ class Logs(BaseModel):
211
211
  "List of strings printed to stderr by prints, subprocesses, etc."
212
212
 
213
213
 
214
+ def serialize_results(results: List[Result]) -> List[Dict[str, str]]:
215
+ """
216
+ Serializes the results to JSON.
217
+ This method is used by the Pydantic JSON encoder.
218
+ """
219
+ serialized = []
220
+ for result in results:
221
+ serialized_dict = {key: result[key] for key in result.formats()}
222
+ serialized_dict["text"] = result.text
223
+ serialized.append(serialized_dict)
224
+ return serialized
225
+
226
+
214
227
  class Execution(BaseModel):
215
228
  """
216
229
  Represents the result of a cell execution.
@@ -218,6 +231,9 @@ class Execution(BaseModel):
218
231
 
219
232
  class Config:
220
233
  arbitrary_types_allowed = True
234
+ json_encoders = {
235
+ List[Result]: serialize_results,
236
+ }
221
237
 
222
238
  results: List[Result] = []
223
239
  "List of the result of the cell (interactively interpreted last line), display calls (e.g. matplotlib plots)."
@@ -245,19 +261,6 @@ class Execution(BaseModel):
245
261
  """
246
262
  return self.model_dump_json(exclude_none=True)
247
263
 
248
- @field_serializer("results", when_used="json")
249
- def serialize_results(results: List[Result]) -> List[Dict[str, str]]:
250
- """
251
- Serializes the results to JSON.
252
- This method is used by the Pydantic JSON encoder.
253
- """
254
- serialized = []
255
- for result in results:
256
- serialized_dict = {key: result[key] for key in result.formats()}
257
- serialized_dict["text"] = result.text
258
- serialized.append(serialized_dict)
259
- return serialized
260
-
261
264
 
262
265
  class KernelException(Exception):
263
266
  """
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "e2b-code-interpreter"
3
- version = "0.0.9a0"
3
+ version = "0.0.10"
4
4
  description = "E2B Code Interpreter - Stateful code execution"
5
5
  authors = ["e2b <hello@e2b.dev>"]
6
6
  license = "Apache-2.0"
@@ -12,7 +12,7 @@ packages = [{ include = "e2b_code_interpreter" }]
12
12
  [tool.poetry.dependencies]
13
13
  python = "^3.8"
14
14
 
15
- pydantic = ">1, <3"
15
+ pydantic = "*"
16
16
  websocket-client = "^1.7.0"
17
17
  e2b = ">=0.17.1"
18
18