Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Improve python logging (#94)
Jakub Novákae587c4b1c34
diff --git a/.changeset/proud-pigs-exercise.md b/.changeset/proud-pigs-exercise.mdnew file mode 100644index 000000000..02b4843d1--- /dev/null+++ b/.changeset/proud-pigs-exercise.md@@ -0,0 +1,5 @@+---+"@e2b/python-sdk": patch+---++Improve loggingdiff --git a/.changeset/sour-ears-laugh.md b/.changeset/sour-ears-laugh.mdnew file mode 100644index 000000000..6decf2d36--- /dev/null+++ b/.changeset/sour-ears-laugh.md@@ -0,0 +1,5 @@+---+"@e2b/python-sdk": patch+---++Add the possibility to timeout callsdiff --git a/package-lock.json b/package-lock.jsonindex d8cbe1064..18a7ca650 100644--- a/package-lock.json+++ b/package-lock.json@@ -10038,7 +10038,7 @@},"packages/js-sdk": {"name": "@e2b/sdk",- "version": "0.2.0",+ "version": "0.2.1","license": "MIT","dependencies": {"cross-fetch": "^3.1.5",@@ -10076,7 +10076,7 @@},"packages/python-sdk": {"name": "@e2b/python-sdk",- "version": "0.2.3"+ "version": "0.2.5"}},"dependencies": {diff --git a/packages/python-sdk/e2b/api/client/api_client.py b/packages/python-sdk/e2b/api/client/api_client.pyindex ad2755a07..119017044 100644--- a/packages/python-sdk/e2b/api/client/api_client.py+++ b/packages/python-sdk/e2b/api/client/api_client.py@@ -14,21 +14,20 @@import atexitimport datetime-from dateutil.parser import parseimport jsonimport mimetypes-from multiprocessing.pool import ThreadPoolimport osimport reimport tempfile-+from multiprocessing.pool import ThreadPoolfrom urllib.parse import quote-from e2b.api.client.configuration import Configuration-from e2b.api.client.api_response import ApiResponseimport e2b.api.client.models+from dateutil.parser import parsefrom e2b.api.client import rest-from e2b.api.client.exceptions import ApiValueError, ApiException+from e2b.api.client.api_response import ApiResponse+from e2b.api.client.configuration import Configuration+from e2b.api.client.exceptions import ApiValueErrorclass ApiClient(object):@@ -225,22 +224,17 @@ class ApiClient(object):url_query = self.parameters_to_url_query(query_params, collection_formats)url += "?" + url_query- try:- # perform request and return response- response_data = await self.request(- method,- url,- query_params=query_params,- headers=header_params,- post_params=post_params,- body=body,- _preload_content=_preload_content,- _request_timeout=_request_timeout,- )- except ApiException as e:- if e.body:- e.body = e.body.decode("utf-8")- raise e+ # perform request and return response+ response_data = await self.request(+ method,+ url,+ query_params=query_params,+ headers=header_params,+ post_params=post_params,+ body=body,+ _preload_content=_preload_content,+ _request_timeout=_request_timeout,+ )self.last_response = response_data@@ -806,7 +800,7 @@ class ApiClient(object):return stringexcept ValueError:raise rest.ApiException(- status=0, reason="Failed to parse `{0}` as date object".format(string)+ status=0, message="Failed to parse `{0}` as date object".format(string))def __deserialize_datetime(self, string):@@ -824,7 +818,7 @@ class ApiClient(object):except ValueError:raise rest.ApiException(status=0,- reason=("Failed to parse `{0}` as datetime object".format(string)),+ message="Failed to parse `{0}` as datetime object".format(string),)def __deserialize_model(self, data, klass):diff --git a/packages/python-sdk/e2b/api/client/docs/DefaultApi.md b/packages/python-sdk/e2b/api/client/docs/DefaultApi.mdindex ae9239ecf..7fa04f227 100644--- a/packages/python-sdk/e2b/api/client/docs/DefaultApi.md+++ b/packages/python-sdk/e2b/api/client/docs/DefaultApi.md@@ -2,26 +2,20 @@All URIs are relative to *https://ondevbook.com*-Method | HTTP request | Description-------------- | ------------- | --------------[**health_get**](DefaultApi.md#health_get) | **GET** /health |-+| Method | HTTP request | Description |+| ------------------------------------------ | --------------- | ----------- |+| [**health_get**](DefaultApi.md#health_get) | **GET** /health |# **health_get**-> health_get()-+> health_get()Health check### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -41,8 +35,8 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling DefaultApi->health_get: %s\n" % e)```-### Parameters+This endpoint does not need any parameter.### Return type@@ -55,14 +49,14 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**200** | Request was successful | - |-**401** | Authentication error | - |-[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+| Status code | Description | Response headers |+| ----------- | ---------------------- | ---------------- |+| **200** | Request was successful | - |+| **401** | Authentication error | - |+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)diff --git a/packages/python-sdk/e2b/api/client/docs/EnvsApi.md b/packages/python-sdk/e2b/api/client/docs/EnvsApi.mdindex 66836e9bf..7c48c600f 100644--- a/packages/python-sdk/e2b/api/client/docs/EnvsApi.md+++ b/packages/python-sdk/e2b/api/client/docs/EnvsApi.md@@ -2,32 +2,26 @@All URIs are relative to *https://ondevbook.com*-Method | HTTP request | Description-------------- | ------------- | --------------[**envs_code_snippet_id_delete**](EnvsApi.md#envs_code_snippet_id_delete) | **DELETE** /envs/{codeSnippetID} |-[**envs_code_snippet_id_patch**](EnvsApi.md#envs_code_snippet_id_patch) | **PATCH** /envs/{codeSnippetID} |-[**envs_code_snippet_id_post**](EnvsApi.md#envs_code_snippet_id_post) | **POST** /envs/{codeSnippetID} |-[**envs_code_snippet_id_state_put**](EnvsApi.md#envs_code_snippet_id_state_put) | **PUT** /envs/{codeSnippetID}/state |-[**envs_code_snippet_id_title_put**](EnvsApi.md#envs_code_snippet_id_title_put) | **PUT** /envs/{codeSnippetID}/title |-[**envs_get**](EnvsApi.md#envs_get) | **GET** /envs |-[**envs_post**](EnvsApi.md#envs_post) | **POST** /envs |-+| Method | HTTP request | Description |+| ------------------------------------------------------------------------------- | ----------------------------------- | ----------- |+| [**envs_code_snippet_id_delete**](EnvsApi.md#envs_code_snippet_id_delete) | **DELETE** /envs/{codeSnippetID} |+| [**envs_code_snippet_id_patch**](EnvsApi.md#envs_code_snippet_id_patch) | **PATCH** /envs/{codeSnippetID} |+| [**envs_code_snippet_id_post**](EnvsApi.md#envs_code_snippet_id_post) | **POST** /envs/{codeSnippetID} |+| [**envs_code_snippet_id_state_put**](EnvsApi.md#envs_code_snippet_id_state_put) | **PUT** /envs/{codeSnippetID}/state |+| [**envs_code_snippet_id_title_put**](EnvsApi.md#envs_code_snippet_id_title_put) | **PUT** /envs/{codeSnippetID}/title |+| [**envs_get**](EnvsApi.md#envs_get) | **GET** /envs |+| [**envs_post**](EnvsApi.md#envs_post) | **POST** /envs |# **envs_code_snippet_id_delete**-> envs_code_snippet_id_delete(api_key, code_snippet_id)-+> envs_code_snippet_id_delete(api_key, code_snippet_id)Delete the code snippet environment### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -40,8 +34,8 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- code_snippet_id = 'code_snippet_id_example' # str |+ api_key = 'api_key_example' # str |+ code_snippet_id = 'code_snippet_id_example' # str |try:await api_instance.envs_code_snippet_id_delete(api_key, code_snippet_id)@@ -49,13 +43,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_code_snippet_id_delete: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **code_snippet_id** | **str**| |+| Name | Type | Description | Notes |+| ------------------- | ------- | ----------- | ----- |+| **api_key** | **str** | |+| **code_snippet_id** | **str** | |### Return type@@ -67,34 +60,30 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Successfully deleted the environment | - |-**400** | Cannot delete the environment | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | ------------------------------------ | ---------------- |+| **204** | Successfully deleted the environment | - |+| **400** | Cannot delete the environment | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_code_snippet_id_patch**-> envs_code_snippet_id_patch(api_key, code_snippet_id)-+> envs_code_snippet_id_patch(api_key, code_snippet_id)Update the environment of the code snippet to match the edit environment### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -107,8 +96,8 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- code_snippet_id = 'code_snippet_id_example' # str |+ api_key = 'api_key_example' # str |+ code_snippet_id = 'code_snippet_id_example' # str |try:await api_instance.envs_code_snippet_id_patch(api_key, code_snippet_id)@@ -116,13 +105,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_code_snippet_id_patch: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **code_snippet_id** | **str**| |+| Name | Type | Description | Notes |+| ------------------- | ------- | ----------- | ----- |+| **api_key** | **str** | |+| **code_snippet_id** | **str** | |### Return type@@ -134,35 +122,30 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Updated the edit environment for code snippet | - |-**400** | Bad request | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | --------------------------------------------- | ---------------- |+| **204** | Updated the edit environment for code snippet | - |+| **400** | Bad request | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_code_snippet_id_post**-> envs_code_snippet_id_post(api_key, code_snippet_id, new_environment)-+> envs_code_snippet_id_post(api_key, code_snippet_id, new_environment)Create a new env for a code snippet### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.new_environment import NewEnvironment-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -175,9 +158,9 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- code_snippet_id = 'code_snippet_id_example' # str |- new_environment = e2b.api.client.NewEnvironment() # NewEnvironment |+ api_key = 'api_key_example' # str |+ code_snippet_id = 'code_snippet_id_example' # str |+ new_environment = e2b.api.client.NewEnvironment() # NewEnvironment |try:await api_instance.envs_code_snippet_id_post(api_key, code_snippet_id, new_environment)@@ -185,14 +168,13 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_code_snippet_id_post: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **code_snippet_id** | **str**| |- **new_environment** | [**NewEnvironment**](NewEnvironment.md)| |+| Name | Type | Description | Notes |+| ------------------- | --------------------------------------- | ----------- | ----- |+| **api_key** | **str** | |+| **code_snippet_id** | **str** | |+| **new_environment** | [**NewEnvironment**](NewEnvironment.md) | |### Return type@@ -204,35 +186,30 @@ No authorization required### HTTP request headers- - **Content-Type**: application/json- - **Accept**: application/json+- **Content-Type**: application/json+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Successfully created an environment | - |-**400** | Bad request | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | ----------------------------------- | ---------------- |+| **204** | Successfully created an environment | - |+| **400** | Bad request | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_code_snippet_id_state_put**-> envs_code_snippet_id_state_put(api_key, code_snippet_id, environment_state_update)-+> envs_code_snippet_id_state_put(api_key, code_snippet_id, environment_state_update)Update the state of the environment### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.environment_state_update import EnvironmentStateUpdate-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -245,9 +222,9 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- code_snippet_id = 'code_snippet_id_example' # str |- environment_state_update = e2b.api.client.EnvironmentStateUpdate() # EnvironmentStateUpdate |+ api_key = 'api_key_example' # str |+ code_snippet_id = 'code_snippet_id_example' # str |+ environment_state_update = e2b.api.client.EnvironmentStateUpdate() # EnvironmentStateUpdate |try:await api_instance.envs_code_snippet_id_state_put(api_key, code_snippet_id, environment_state_update)@@ -255,14 +232,13 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_code_snippet_id_state_put: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **code_snippet_id** | **str**| |- **environment_state_update** | [**EnvironmentStateUpdate**](EnvironmentStateUpdate.md)| |+| Name | Type | Description | Notes |+| ---------------------------- | ------------------------------------------------------- | ----------- | ----- |+| **api_key** | **str** | |+| **code_snippet_id** | **str** | |+| **environment_state_update** | [**EnvironmentStateUpdate**](EnvironmentStateUpdate.md) | |### Return type@@ -274,34 +250,29 @@ No authorization required### HTTP request headers- - **Content-Type**: application/json- - **Accept**: application/json+- **Content-Type**: application/json+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Updated the state of environment | - |-**400** | Bad request | - |-**401** | Authentication error | - |++| Status code | Description | Response headers |+| ----------- | -------------------------------- | ---------------- |+| **204** | Updated the state of environment | - |+| **400** | Bad request | - |+| **401** | Authentication error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_code_snippet_id_title_put**-> envs_code_snippet_id_title_put(api_key, code_snippet_id, environment_title_update)-+> envs_code_snippet_id_title_put(api_key, code_snippet_id, environment_title_update)Update the title of the environment### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.environment_title_update import EnvironmentTitleUpdate-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -314,9 +285,9 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- code_snippet_id = 'code_snippet_id_example' # str |- environment_title_update = e2b.api.client.EnvironmentTitleUpdate() # EnvironmentTitleUpdate |+ api_key = 'api_key_example' # str |+ code_snippet_id = 'code_snippet_id_example' # str |+ environment_title_update = e2b.api.client.EnvironmentTitleUpdate() # EnvironmentTitleUpdate |try:await api_instance.envs_code_snippet_id_title_put(api_key, code_snippet_id, environment_title_update)@@ -324,14 +295,13 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_code_snippet_id_title_put: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **code_snippet_id** | **str**| |- **environment_title_update** | [**EnvironmentTitleUpdate**](EnvironmentTitleUpdate.md)| |+| Name | Type | Description | Notes |+| ---------------------------- | ------------------------------------------------------- | ----------- | ----- |+| **api_key** | **str** | |+| **code_snippet_id** | **str** | |+| **environment_title_update** | [**EnvironmentTitleUpdate**](EnvironmentTitleUpdate.md) | |### Return type@@ -343,33 +313,29 @@ No authorization required### HTTP request headers- - **Content-Type**: application/json- - **Accept**: application/json+- **Content-Type**: application/json+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Updated the title of the code snippet | - |-**400** | Bad request | - |-**401** | Authentication error | - |++| Status code | Description | Response headers |+| ----------- | ------------------------------------- | ---------------- |+| **204** | Updated the title of the code snippet | - |+| **400** | Bad request | - |+| **401** | Authentication error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_get**-> List[EnvsGet200ResponseInner] envs_get(api_key)-+> List[EnvsGet200ResponseInner] envs_get(api_key)List all environments### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.envs_get200_response_inner import EnvsGet200ResponseInner-from e2b.api.client.rest import ApiExceptionfrom pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com@@ -383,7 +349,7 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |+ api_key = 'api_key_example' # str |try:api_response = await api_instance.envs_get(api_key)@@ -393,12 +359,11 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_get: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |+| Name | Type | Description | Notes |+| ----------- | ------- | ----------- | ----- |+| **api_key** | **str** | |### Return type@@ -410,34 +375,29 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**200** | Successfully returned all environments | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | -------------------------------------- | ---------------- |+| **200** | Successfully returned all environments | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **envs_post**-> Environment envs_post(api_key, new_environment)-+> Environment envs_post(api_key, new_environment)Create a new environment### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.environment import Environment-from e2b.api.client.models.new_environment import NewEnvironment-from e2b.api.client.rest import ApiExceptionfrom pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com@@ -451,8 +411,8 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.EnvsApi(api_client)- api_key = 'api_key_example' # str |- new_environment = e2b.api.client.NewEnvironment() # NewEnvironment |+ api_key = 'api_key_example' # str |+ new_environment = e2b.api.client.NewEnvironment() # NewEnvironment |try:api_response = await api_instance.envs_post(api_key, new_environment)@@ -462,13 +422,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling EnvsApi->envs_post: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **new_environment** | [**NewEnvironment**](NewEnvironment.md)| |+| Name | Type | Description | Notes |+| ------------------- | --------------------------------------- | ----------- | ----- |+| **api_key** | **str** | |+| **new_environment** | [**NewEnvironment**](NewEnvironment.md) | |### Return type@@ -480,16 +439,16 @@ No authorization required### HTTP request headers- - **Content-Type**: application/json- - **Accept**: application/json+- **Content-Type**: application/json+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**200** | Successfully created an environment | - |-**400** | Bad request | - |-**401** | Authentication error | - |-**500** | Server error | - |-[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+| Status code | Description | Response headers |+| ----------- | ----------------------------------- | ---------------- |+| **200** | Successfully created an environment | - |+| **400** | Bad request | - |+| **401** | Authentication error | - |+| **500** | Server error | - |+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)diff --git a/packages/python-sdk/e2b/api/client/docs/SessionsApi.md b/packages/python-sdk/e2b/api/client/docs/SessionsApi.mdindex 2554f9859..8278706b2 100644--- a/packages/python-sdk/e2b/api/client/docs/SessionsApi.md+++ b/packages/python-sdk/e2b/api/client/docs/SessionsApi.md@@ -2,29 +2,23 @@All URIs are relative to *https://ondevbook.com*-Method | HTTP request | Description-------------- | ------------- | --------------[**sessions_get**](SessionsApi.md#sessions_get) | **GET** /sessions |-[**sessions_post**](SessionsApi.md#sessions_post) | **POST** /sessions |-[**sessions_session_id_delete**](SessionsApi.md#sessions_session_id_delete) | **DELETE** /sessions/{sessionID} |-[**sessions_session_id_refresh_post**](SessionsApi.md#sessions_session_id_refresh_post) | **POST** /sessions/{sessionID}/refresh |-+| Method | HTTP request | Description |+| --------------------------------------------------------------------------------------- | -------------------------------------- | ----------- |+| [**sessions_get**](SessionsApi.md#sessions_get) | **GET** /sessions |+| [**sessions_post**](SessionsApi.md#sessions_post) | **POST** /sessions |+| [**sessions_session_id_delete**](SessionsApi.md#sessions_session_id_delete) | **DELETE** /sessions/{sessionID} |+| [**sessions_session_id_refresh_post**](SessionsApi.md#sessions_session_id_refresh_post) | **POST** /sessions/{sessionID}/refresh |# **sessions_get**-> List[SessionsGet200ResponseInner] sessions_get(api_key)-+> List[SessionsGet200ResponseInner] sessions_get(api_key)List all sessions### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.sessions_get200_response_inner import SessionsGet200ResponseInner-from e2b.api.client.rest import ApiExceptionfrom pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com@@ -38,7 +32,7 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.SessionsApi(api_client)- api_key = 'api_key_example' # str |+ api_key = 'api_key_example' # str |try:api_response = await api_instance.sessions_get(api_key)@@ -48,12 +42,11 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling SessionsApi->sessions_get: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |+| Name | Type | Description | Notes |+| ----------- | ------- | ----------- | ----- |+| **api_key** | **str** | |### Return type@@ -65,34 +58,29 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**200** | Successfully returned all sessions | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | ---------------------------------- | ---------------- |+| **200** | Successfully returned all sessions | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **sessions_post**-> Session sessions_post(new_session, api_key=api_key)-+> Session sessions_post(new_session, api_key=api_key)Create a session on the server### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.models.new_session import NewSession-from e2b.api.client.models.session import Session-from e2b.api.client.rest import ApiExceptionfrom pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com@@ -106,7 +94,7 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.SessionsApi(api_client)- new_session = e2b.api.client.NewSession() # NewSession |+ new_session = e2b.api.client.NewSession() # NewSession |api_key = 'api_key_example' # str | (optional)try:@@ -117,13 +105,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling SessionsApi->sessions_post: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **new_session** | [**NewSession**](NewSession.md)| |- **api_key** | **str**| | [optional]+| Name | Type | Description | Notes |+| --------------- | ------------------------------- | ----------- | ---------- |+| **new_session** | [**NewSession**](NewSession.md) | |+| **api_key** | **str** | | [optional] |### Return type@@ -135,34 +122,30 @@ No authorization required### HTTP request headers- - **Content-Type**: application/json- - **Accept**: application/json+- **Content-Type**: application/json+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**201** | Successfully created a session | - |-**401** | Authentication error | - |-**400** | Bad request | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | ------------------------------ | ---------------- |+| **201** | Successfully created a session | - |+| **401** | Authentication error | - |+| **400** | Bad request | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **sessions_session_id_delete**-> sessions_session_id_delete(api_key, session_id)-+> sessions_session_id_delete(api_key, session_id)Delete a session on the server### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -175,8 +158,8 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.SessionsApi(api_client)- api_key = 'api_key_example' # str |- session_id = 'session_id_example' # str |+ api_key = 'api_key_example' # str |+ session_id = 'session_id_example' # str |try:await api_instance.sessions_session_id_delete(api_key, session_id)@@ -184,13 +167,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling SessionsApi->sessions_session_id_delete: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **api_key** | **str**| |- **session_id** | **str**| |+| Name | Type | Description | Notes |+| -------------- | ------- | ----------- | ----- |+| **api_key** | **str** | |+| **session_id** | **str** | |### Return type@@ -202,33 +184,29 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Successfully deleted the session | - |-**401** | Authentication error | - |-**500** | Server error | - |++| Status code | Description | Response headers |+| ----------- | -------------------------------- | ---------------- |+| **204** | Successfully deleted the session | - |+| **401** | Authentication error | - |+| **500** | Server error | - |[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)# **sessions_session_id_refresh_post**-> sessions_session_id_refresh_post(session_id, api_key=api_key)-+> sessions_session_id_refresh_post(session_id, api_key=api_key)Refresh the session extending its time to live### Example```python-import time-import osimport e2b.api.client-from e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -241,7 +219,7 @@ configuration = e2b.api.client.Configuration(async with e2b.api.client.ApiClient(configuration) as api_client:# Create an instance of the API classapi_instance = e2b.api.client.SessionsApi(api_client)- session_id = 'session_id_example' # str |+ session_id = 'session_id_example' # str |api_key = 'api_key_example' # str | (optional)try:@@ -250,13 +228,12 @@ async with e2b.api.client.ApiClient(configuration) as api_client:print("Exception when calling SessionsApi->sessions_session_id_refresh_post: %s\n" % e)```-### Parameters-Name | Type | Description | Notes-------------- | ------------- | ------------- | -------------- **session_id** | **str**| |- **api_key** | **str**| | [optional]+| Name | Type | Description | Notes |+| -------------- | ------- | ----------- | ---------- |+| **session_id** | **str** | |+| **api_key** | **str** | | [optional] |### Return type@@ -268,15 +245,15 @@ No authorization required### HTTP request headers- - **Content-Type**: Not defined- - **Accept**: application/json+- **Content-Type**: Not defined+- **Accept**: application/json### HTTP response details-| Status code | Description | Response headers |-|-------------|-------------|------------------|-**204** | Successfully refreshed the session | - |-**401** | Authentication error | - |-**404** | Error refreshing session - session not found | - |-[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)+| Status code | Description | Response headers |+| ----------- | -------------------------------------------- | ---------------- |+| **204** | Successfully refreshed the session | - |+| **401** | Authentication error | - |+| **404** | Error refreshing session - session not found | - |+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)diff --git a/packages/python-sdk/e2b/api/client/exceptions.py b/packages/python-sdk/e2b/api/client/exceptions.pyindex 442c03e60..2bc78f619 100644--- a/packages/python-sdk/e2b/api/client/exceptions.py+++ b/packages/python-sdk/e2b/api/client/exceptions.py@@ -10,6 +10,7 @@Do not edit the class manually."""+import jsonclass OpenApiException(Exception):@@ -99,48 +100,37 @@ class ApiKeyError(OpenApiException, KeyError):class ApiException(OpenApiException):- def __init__(self, status=None, reason=None, http_resp=None):- if http_resp:- self.status = http_resp.status- self.reason = http_resp.reason- self.body = http_resp.data- self.headers = http_resp.getheaders()+ def __init__(self, status, data=None, message=None):+ self.status = status+ if data:+ body = json.loads(data.decode("utf-8"))+ self.message = body.get("message", body.get("error", "Unknown error"))else:- self.status = status- self.reason = reason- self.body = None- self.headers = None+ self.message = messagedef __str__(self):"""Custom error messages for exception"""- error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)- if self.headers:- error_message += "HTTP response headers: {0}\n".format(self.headers)-- if self.body:- error_message += "HTTP response body: {0}\n".format(self.body)-- return error_message+ return "HTTP Status code ({0}) - {1}".format(self.status, self.message)class NotFoundException(ApiException):- def __init__(self, status=None, reason=None, http_resp=None):- super(NotFoundException, self).__init__(status, reason, http_resp)+ def __init__(self, status, data):+ super(NotFoundException, self).__init__(status, data)class UnauthorizedException(ApiException):- def __init__(self, status=None, reason=None, http_resp=None):- super(UnauthorizedException, self).__init__(status, reason, http_resp)+ def __init__(self, status, data):+ super(UnauthorizedException, self).__init__(status, data)class ForbiddenException(ApiException):- def __init__(self, status=None, reason=None, http_resp=None):- super(ForbiddenException, self).__init__(status, reason, http_resp)+ def __init__(self, status, data):+ super(ForbiddenException, self).__init__(status, data)class ServiceException(ApiException):- def __init__(self, status=None, reason=None, http_resp=None):- super(ServiceException, self).__init__(status, reason, http_resp)+ def __init__(self, status, data):+ super(ServiceException, self).__init__(status, data)def render_path(path_to_item):diff --git a/packages/python-sdk/e2b/api/client/rest.py b/packages/python-sdk/e2b/api/client/rest.pyindex de307f19b..0a49d7a24 100644--- a/packages/python-sdk/e2b/api/client/rest.py+++ b/packages/python-sdk/e2b/api/client/rest.py@@ -17,11 +17,17 @@ import jsonimport loggingimport reimport ssl+from urllib.parse import urlencodeimport aiohttp-from urllib.parse import urlencode, quote_plus--from e2b.api.client.exceptions import ApiException, ApiValueError+from e2b.api.client.exceptions import (+ ApiException,+ ApiValueError,+ ForbiddenException,+ NotFoundException,+ ServiceException,+ UnauthorizedException,+)logger = logging.getLogger(__name__)@@ -158,7 +164,7 @@ class RESTClientObject(object):msg = """Cannot prepare a request message for providedarguments. Please check that your arguments matchdeclared content type."""- raise ApiException(status=0, reason=msg)+ raise ApiException(status=0, message=msg)r = await self.pool_manager.request(**args)if _preload_content:@@ -169,7 +175,16 @@ class RESTClientObject(object):logger.debug("response body: %s", r.data)if not 200 <= r.status <= 299:- raise ApiException(http_resp=r)+ if r.status == 401:+ raise UnauthorizedException(status=r.status, data=r.data)+ elif r.status == 403:+ raise ForbiddenException(status=r.status, data=r.data)+ elif r.status == 404:+ raise NotFoundException(status=r.status, data=r.data)+ elif r.status == 500:+ raise ServiceException(status=r.status, data=r.data)+ else:+ raise ApiException(status=r.status, data=r.data)return rdiff --git a/packages/python-sdk/e2b/api/client_README.md b/packages/python-sdk/e2b/api/client_README.mdindex b7cc6bf72..5609f3652 100644--- a/packages/python-sdk/e2b/api/client_README.md+++ b/packages/python-sdk/e2b/api/client_README.md@@ -1,4 +1,5 @@# e2b.api.client+Devbook APIThe `e2b.api.client` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:@@ -17,11 +18,11 @@ This python library package is generated without supporting files like setup.pyTo be able to use it, you will need these dependencies in your own package that uses this library:-* urllib3 >= 1.25.3-* python-dateutil-* aiohttp-* pydantic-* aenum+- urllib3 >= 1.25.3+- python-dateutil+- aiohttp+- pydantic+- aenum## Getting Started@@ -30,10 +31,8 @@ you can run the following:```python-import timeimport e2b.api.clientfrom e2b.api.client.rest import ApiException-from pprint import pprint# Defining the host is optional and defaults to https://ondevbook.com# See configuration.py for a list of all supported configuration parameters.@@ -59,52 +58,46 @@ async with e2b.api.client.ApiClient(configuration) as api_client:All URIs are relative to *https://ondevbook.com*-Class | Method | HTTP request | Description------------- | ------------- | ------------- | --------------*DefaultApi* | [**health_get**](e2b/api/client/docs/DefaultApi.md#health_get) | **GET** /health |-*EnvsApi* | [**envs_code_snippet_id_delete**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_delete) | **DELETE** /envs/{codeSnippetID} |-*EnvsApi* | [**envs_code_snippet_id_patch**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_patch) | **PATCH** /envs/{codeSnippetID} |-*EnvsApi* | [**envs_code_snippet_id_post**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_post) | **POST** /envs/{codeSnippetID} |-*EnvsApi* | [**envs_code_snippet_id_state_put**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_state_put) | **PUT** /envs/{codeSnippetID}/state |-*EnvsApi* | [**envs_code_snippet_id_title_put**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_title_put) | **PUT** /envs/{codeSnippetID}/title |-*EnvsApi* | [**envs_get**](e2b/api/client/docs/EnvsApi.md#envs_get) | **GET** /envs |-*EnvsApi* | [**envs_post**](e2b/api/client/docs/EnvsApi.md#envs_post) | **POST** /envs |-*SessionsApi* | [**sessions_get**](e2b/api/client/docs/SessionsApi.md#sessions_get) | **GET** /sessions |-*SessionsApi* | [**sessions_post**](e2b/api/client/docs/SessionsApi.md#sessions_post) | **POST** /sessions |-*SessionsApi* | [**sessions_session_id_delete**](e2b/api/client/docs/SessionsApi.md#sessions_session_id_delete) | **DELETE** /sessions/{sessionID} |-*SessionsApi* | [**sessions_session_id_refresh_post**](e2b/api/client/docs/SessionsApi.md#sessions_session_id_refresh_post) | **POST** /sessions/{sessionID}/refresh |-+| Class | Method | HTTP request | Description |+| ------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------- | ----------- |+| _DefaultApi_ | [**health_get**](e2b/api/client/docs/DefaultApi.md#health_get) | **GET** /health |+| _EnvsApi_ | [**envs_code_snippet_id_delete**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_delete) | **DELETE** /envs/{codeSnippetID} |+| _EnvsApi_ | [**envs_code_snippet_id_patch**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_patch) | **PATCH** /envs/{codeSnippetID} |+| _EnvsApi_ | [**envs_code_snippet_id_post**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_post) | **POST** /envs/{codeSnippetID} |+| _EnvsApi_ | [**envs_code_snippet_id_state_put**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_state_put) | **PUT** /envs/{codeSnippetID}/state |+| _EnvsApi_ | [**envs_code_snippet_id_title_put**](e2b/api/client/docs/EnvsApi.md#envs_code_snippet_id_title_put) | **PUT** /envs/{codeSnippetID}/title |+| _EnvsApi_ | [**envs_get**](e2b/api/client/docs/EnvsApi.md#envs_get) | **GET** /envs |+| _EnvsApi_ | [**envs_post**](e2b/api/client/docs/EnvsApi.md#envs_post) | **POST** /envs |+| _SessionsApi_ | [**sessions_get**](e2b/api/client/docs/SessionsApi.md#sessions_get) | **GET** /sessions |+| _SessionsApi_ | [**sessions_post**](e2b/api/client/docs/SessionsApi.md#sessions_post) | **POST** /sessions |+| _SessionsApi_ | [**sessions_session_id_delete**](e2b/api/client/docs/SessionsApi.md#sessions_session_id_delete) | **DELETE** /sessions/{sessionID} |+| _SessionsApi_ | [**sessions_session_id_refresh_post**](e2b/api/client/docs/SessionsApi.md#sessions_session_id_refresh_post) | **POST** /sessions/{sessionID}/refresh |## Documentation For Models- - [Environment](e2b/api/client/docs/Environment.md)- - [EnvironmentState](e2b/api/client/docs/EnvironmentState.md)- - [EnvironmentStateUpdate](e2b/api/client/docs/EnvironmentStateUpdate.md)- - [EnvironmentTitleUpdate](e2b/api/client/docs/EnvironmentTitleUpdate.md)- - [EnvsGet200ResponseInner](e2b/api/client/docs/EnvsGet200ResponseInner.md)- - [Error](e2b/api/client/docs/Error.md)- - [NewEnvironment](e2b/api/client/docs/NewEnvironment.md)- - [NewSession](e2b/api/client/docs/NewSession.md)- - [Session](e2b/api/client/docs/Session.md)- - [SessionsGet200ResponseInner](e2b/api/client/docs/SessionsGet200ResponseInner.md)- - [Template](e2b/api/client/docs/Template.md)-+- [Environment](e2b/api/client/docs/Environment.md)+- [EnvironmentState](e2b/api/client/docs/EnvironmentState.md)+- [EnvironmentStateUpdate](e2b/api/client/docs/EnvironmentStateUpdate.md)+- [EnvironmentTitleUpdate](e2b/api/client/docs/EnvironmentTitleUpdate.md)+- [EnvsGet200ResponseInner](e2b/api/client/docs/EnvsGet200ResponseInner.md)+- [Error](e2b/api/client/docs/Error.md)+- [NewEnvironment](e2b/api/client/docs/NewEnvironment.md)+- [NewSession](e2b/api/client/docs/NewSession.md)+- [Session](e2b/api/client/docs/Session.md)+- [SessionsGet200ResponseInner](e2b/api/client/docs/SessionsGet200ResponseInner.md)+- [Template](e2b/api/client/docs/Template.md)<a id="documentation-for-authorization"></a>-## Documentation For Authorization+## Documentation For AuthorizationAuthentication schemes defined for the API:<a id="ApiKeyAuth"></a>+### ApiKeyAuth- **Type**: API key- **API key parameter name**: api_key- **Location**: URL query string-## Author----diff --git a/packages/python-sdk/e2b/session/exception.py b/packages/python-sdk/e2b/session/exception.pyindex d8643702a..fd916f39f 100644--- a/packages/python-sdk/e2b/session/exception.py+++ b/packages/python-sdk/e2b/session/exception.py@@ -20,7 +20,7 @@ class RpcException(SessionException):self.id = id-class MultipleExceptions(Exception):+class MultipleExceptions(SessionException):def __init__(self, message: str, exceptions: List[Exception]):super().__init__(f"Multiple exceptions occurred: {message}")self.exceptions = exceptionsdiff --git a/packages/python-sdk/e2b/session/filesystem.py b/packages/python-sdk/e2b/session/filesystem.pyindex 6bed51b53..d2bcfc94b 100644--- a/packages/python-sdk/e2b/session/filesystem.py+++ b/packages/python-sdk/e2b/session/filesystem.py@@ -1,3 +1,4 @@+import loggingfrom typing import Any, List, Optionalfrom e2b.constants import TIMEOUT@@ -6,6 +7,8 @@ from e2b.session.filesystem_watcher import FilesystemWatcherfrom e2b.session.session_connection import SessionConnectionfrom pydantic import BaseModel+logger = logging.getLogger(__name__)+class FileInfo(BaseModel):"""@@ -60,10 +63,12 @@ class FilesystemManager::param timeout: Timeout for the call:return: Content of a file"""+ logger.debug(f"Reading file {path}")try:result: str = await self._session._call(self._service_name, "read", [path], timeout=timeout)+ logger.debug(f"Read file {path}")return resultexcept RpcException as e:raise FilesystemException(e.message) from e@@ -78,10 +83,12 @@ class FilesystemManager::param content: Content to write:param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time"""+ logger.debug(f"Writing file {path}")try:await self._session._call(self._service_name, "write", [path, content], timeout=timeout)+ logger.debug(f"Wrote file {path}")except RpcException as e:raise FilesystemException(e.message) from e@@ -92,10 +99,12 @@ class FilesystemManager::param path: Path to a file or a directory:param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time"""+ logger.debug(f"Removing file {path}")try:await self._session._call(self._service_name, "remove", [path], timeout=timeout)+ logger.debug(f"Removed file {path}")except RpcException as e:raise FilesystemException(e.message) from e@@ -108,10 +117,12 @@ class FilesystemManager::return: Array of files in a directory"""+ logger.debug(f"Listing files in {path}")try:result: List[Any] = await self._session._call(self._service_name, "list", [path], timeout=timeout)+ logger.debug(f"Listed files in {path}, result: {result}")return [FileInfo(is_dir=file_info["isDir"], name=file_info["name"])for file_info in result@@ -126,10 +137,12 @@ class FilesystemManager::param path: Path to a new directory. For example '/dirA/dirB' when creating 'dirB':param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time"""+ logger.debug(f"Creating directory {path}")try:await self._session._call(self._service_name, "makeDir", [path], timeout=timeout)+ logger.debug(f"Created directory {path}")except RpcException as e:raise FilesystemException(e.message) from e@@ -141,6 +154,7 @@ class FilesystemManager::return: New watcher"""+ logger.debug(f"Watching directory {path}")return FilesystemWatcher(connection=self._session,path=path,diff --git a/packages/python-sdk/e2b/session/filesystem_watcher.py b/packages/python-sdk/e2b/session/filesystem_watcher.pyindex b64b21ee7..ead0f010d 100644--- a/packages/python-sdk/e2b/session/filesystem_watcher.py+++ b/packages/python-sdk/e2b/session/filesystem_watcher.py@@ -1,3 +1,4 @@+import loggingfrom enum import Enumfrom typing import Any, Awaitable, Callable, Optional, Set@@ -6,6 +7,8 @@ from e2b.session.exception import FilesystemException, RpcExceptionfrom e2b.session.session_connection import SessionConnectionfrom pydantic import BaseModel+logger = logging.getLogger(__name__)+class FilesystemOperation(str, Enum):Create = "Create"@@ -55,6 +58,7 @@ class FilesystemWatcher:if self._unsubscribe:return+ logger.debug("Starting filesystem watcher for %s", self.path)try:self._unsubscribe = await self._connection._subscribe(self._service_name,@@ -63,6 +67,7 @@ class FilesystemWatcher:self.path,timeout=timeout,)+ logger.debug("Started filesystem watcher for %s", self.path)except RpcException as e:raise FilesystemException(e.message) from e@@ -70,11 +75,14 @@ class FilesystemWatcher:"""Stops the filesystem watcher."""+ logger.debug("Stopping filesystem watcher for %s", self.path)+self._listeners.clear()if self._unsubscribe:try:await self._unsubscribe()self._unsubscribe = None+ logger.debug("Stopped filesystem watcher for %s", self.path)except RpcException as e:raise FilesystemException(e.message) from e@@ -86,6 +94,8 @@ class FilesystemWatcher::return: Function that removes the listener"""+ logger.debug("Adding filesystem watcher listener for %s", self.path)+self._listeners.add(listener)def delete_listener() -> None:diff --git a/packages/python-sdk/e2b/session/main.py b/packages/python-sdk/e2b/session/main.pyindex 721850012..206fea4ec 100644--- a/packages/python-sdk/e2b/session/main.py+++ b/packages/python-sdk/e2b/session/main.py@@ -85,7 +85,7 @@ class Session(SessionConnection)::param on_scan_ports: A callback to handle opened ports"""- logging.info(f"Session {id if isinstance(id, str) else type(id)}")+ logging.info(f"Creating session {id if isinstance(id, str) else type(id)}")super().__init__(id=id,api_key=api_key,@@ -108,9 +108,11 @@ class Session(SessionConnection)::param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time"""+ logging.info(f"Opening session {self._id}")async with async_timeout(timeout):await super().open()await self._code_snippet._subscribe()+ logging.info(f"Session {self._id} opened")def _close_services(self):self._terminal._close()@@ -154,12 +156,10 @@ class Session(SessionConnection):- `DotNET`:param api_key: The API key to use- :param edit_enabled: Whether the session state will be saved after exit:param on_scan_ports: A callback to handle opened ports:param timeout: Specify the duration, in seconds to give the method to finish its execution before it times out (default is 60 seconds). If set to None, the method will continue to wait until it completes, regardless of time"""- logging.info(f"Session {id if isinstance(id, str) else type(id)}")session = cls(id=id,api_key=api_key,diff --git a/packages/python-sdk/e2b/session/process.py b/packages/python-sdk/e2b/session/process.pyindex 6500549c4..75de77c83 100644--- a/packages/python-sdk/e2b/session/process.py+++ b/packages/python-sdk/e2b/session/process.py@@ -214,7 +214,8 @@ class ProcessManager::return: A process object"""- with async_timeout.timeout(timeout):+ logger.info(f"Starting process (id: {process_id})")+ async with async_timeout.timeout(timeout):if not env_vars:env_vars = {}@@ -236,7 +237,10 @@ class ProcessManager:output._add_stdout(message)if on_stdout:- on_stdout(message)+ try:+ on_stdout(message)+ except TypeError as error:+ logger.exception(f"Error in on_stdout callback: {error}")def handle_stderr(data: Dict[Any, Any]):out = OutStderrResponse(**data)@@ -249,7 +253,10 @@ class ProcessManager:output._add_stderr(message)if on_stderr:- on_stderr(message)+ try:+ on_stderr(message)+ except TypeError as error:+ logger.exception(f"Error in on_stdout callback: {error}")try:unsub_all = await self._session._handle_subscriptions(@@ -280,21 +287,25 @@ class ProcessManager:async def exit_handler():await future_exitlogger.info(- f"Handling process exit {process_id} - {future_exit._future.done()}",+ f"Handling process exit {self._service_name} (id: {process_id})",)if unsub_all:await unsub_all()if on_exit:- on_exit()+ try:+ on_exit()+ except TypeError as error:+ logger.exception(f"Error in on_exit callback: {error}")future_exit_handler_finish(output)exit_task = asyncio.create_task(exit_handler())self._process_cleanup.append(exit_task.cancel)async def trigger_exit():- logger.info("Triggering exit")+ logger.info(f"Exiting the process {self._service_name} (id: {process_id})")future_exit(None)await future_exit_handler_finish+ logger.debug(f"Exited the process (id: {process_id})")try:await self._session._call(@@ -307,6 +318,7 @@ class ProcessManager:rootdir,],)+ logger.info(f"Started process (id: {process_id})")return Process(output=output,session=self._session,diff --git a/packages/python-sdk/e2b/session/session_connection.py b/packages/python-sdk/e2b/session/session_connection.pyindex 3e7475b98..63764a824 100644--- a/packages/python-sdk/e2b/session/session_connection.py+++ b/packages/python-sdk/e2b/session/session_connection.py@@ -24,6 +24,7 @@ from e2b.session.exception import (from e2b.session.session_rpc import Notification, SessionRpcfrom e2b.utils.future import DeferredFuture, run_async_func_in_new_loopfrom e2b.utils.noop import noop+from e2b.utils.str import camel_case_to_snake_casefrom e2b.utils.threads import shutdown_executorfrom pydantic import BaseModel@@ -82,7 +83,7 @@ class SessionConnection:self._process_cleanup: List[Callable[[], Any]] = []self._refreshing_task: Optional[asyncio.Future] = Noneself._subscribers = {}- self._rpc: SessionRpc+ self._rpc: Optional[SessionRpc] = Noneself._finished = DeferredFuture(self._process_cleanup)logger.info(f"Session for code snippet {self._id} initialized")@@ -96,7 +97,7 @@ class SessionConnection::return: Hostname of the session or session's port"""if not self._session:- raise Exception(+ raise SessionException("Session is not running. You have to run `await session.open()` first or create the session with `await Session.create()")@@ -120,12 +121,17 @@ class SessionConnection:Close the session and unsubscribe from all the subscriptions."""if self._is_open:- logger.info(f"Closing session {self._session}")+ logger.info(+ f"Closing session {self._session.code_snippet_id} (id: {self._session.session_id})"+ )self._is_open = Falseif self._rpc:await self._rpc.close()self._close()+ logger.info(+ f"Session {self._session.code_snippet_id} closed (id: {self._session.session_id})"+ )def _close(self):if self._on_close_child:@@ -144,7 +150,7 @@ class SessionConnection:You must call this method before using the session."""if self._is_open or self._session:- raise Exception("Session connect was already called")+ raise SessionException("Session connect was already called")else:self._is_open = True@@ -156,7 +162,9 @@ class SessionConnection:NewSession(codeSnippetID=self._id, editEnabled=False),api_key=self._api_key,)- logger.info(f"Acquired session: {self._session}")+ logger.info(+ f"Session {self._session.code_snippet_id} created (id:{self._session.session_id})"+ )# We could potentially use asyncio.to_thread() but that requires Python 3.9+executor = ThreadPoolExecutor()@@ -176,7 +184,7 @@ class SessionConnection:finally:if self._session:logger.info(- f"Stopped refreshing session {self._session.session_id}"+ f"Stopped refreshing session (id: {self._session.session_id})")else:logger.info(@@ -188,7 +196,7 @@ class SessionConnection:refresh_handler = asyncio.create_task(refresh_cleanup())self._process_cleanup.append(refresh_handler.cancel)except Exception as e:- logger.error(f"Failed to acquire session: {e}")+ logger.error(f"Failed to acquire session")await self.close()raise e@@ -198,7 +206,6 @@ class SessionConnection:session_url = f"{protocol}://{hostname}{WS_ROUTE}"try:- logger.info(f"Connection to session: {self._session}")self._rpc = SessionRpc(url=session_url,on_message=self._handle_notification,@@ -271,7 +278,7 @@ class SessionConnection:sub = self._subscribers[sub_id]await self._call(sub.service, "unsubscribe", [sub.id], timeout=timeout)del self._subscribers[sub_id]- logger.info(f"Unsubscribed from {sub_id}")+ logger.debug(f"Unsubscribed (sub_id: {sub_id})")async def _subscribe(self,@@ -285,14 +292,12 @@ class SessionConnection:service, "subscribe", [method, *params], timeout=timeout)if not isinstance(sub_id, str):- raise Exception(f"Failed to subscribe: ${sub_id}")+ raise Exception(f"Failed to subscribe: {camel_case_to_snake_case(method)}")self._subscribers[sub_id] = Subscription(service=service, id=sub_id, handler=handler)- logger.info(- f"Subscribed to {service}_{method} with params [{', '.join(params)}] and with id {sub_id}"- )+ logger.info(f"Subscribed to {service} {camel_case_to_snake_case(method)}")async def unsub():await self._unsubscribe(sub_id, timeout=timeout)@@ -300,14 +305,16 @@ class SessionConnection:return unsubdef _handle_notification(self, data: Notification):- logger.info(f"Notification {data}")+ logger.debug(f"Notification {data}")for id, sub in self._subscribers.items():if id == data.params["subscription"]:sub.handler(data.params["result"])async def _refresh(self, session_id: str):- logger.info(f"Started refreshing session {session_id}")+ logger.info(+ f"Started refreshing session {self._session.code_snippet_id} (id: {session_id})"+ )current_retry = 0@@ -315,7 +322,7 @@ class SessionConnection:api = client.SessionsApi(api_client)while True:if not self._is_open:- logger.info(+ logger.debug(f"Cannot refresh session - it was closed. {self._session}")return@@ -324,10 +331,9 @@ class SessionConnection:await api.sessions_session_id_refresh_post(session_id,)- logger.info(f"Refreshed session {session_id}")+ logger.debug(f"Refreshed session {session_id}")except ApiException as e:if e.status == 404:- logger.error(f"Session {session_id} not found {e}")raise SessionException(f"Session {session_id} failed because it cannot be found") from ediff --git a/packages/python-sdk/e2b/session/session_rpc.py b/packages/python-sdk/e2b/session/session_rpc.pyindex 32319cb1d..87852ed95 100644--- a/packages/python-sdk/e2b/session/session_rpc.py+++ b/packages/python-sdk/e2b/session/session_rpc.py@@ -34,7 +34,6 @@ Message = Union[Response, Notification]def to_response_or_notification(response: Dict[str, Any]) -> Message:"""Create a Response namedtuple from a dict"""- logger.info(f"Received response: {response}")if "error" in response:return Error(response["error"]["code"],@@ -67,6 +66,7 @@ class SessionRpc(BaseModel):async def process_messages(self):while True:data = await self._queue_out.async_q.get()+ logger.debug(f"WebSocket received message: {data}".strip())await self._receive_message(data)self._queue_out.async_q.task_done()@@ -89,8 +89,10 @@ class SessionRpc(BaseModel):self._process_cleanup.append(websocket_task.cancel)self._process_cleanup.append(lambda: shutdown_executor(executor))self._process_cleanup.append(task.cancel)+ logger.info("WebSocket waiting to start")while not started.is_set():await asyncio.sleep(0)+ logger.info("WebSocket started")async def send_message(self, method: str, params: List[Any]) -> Any:id = next(self._id_generator)@@ -99,22 +101,26 @@ class SessionRpc(BaseModel):try:self._waiting_for_replies[id] = future_reply- logger.info(f"Queueing: {request}")+ logger.debug(f"WebSocket queueing message: {request}")self._queue_in.put(request)- logger.info(f"Waiting for reply: {request}")+ logger.debug(f"WebSocket waiting for reply: {request}")r = await future_replyreturn rexcept Exception as e:- logger.error(f"Error: {request} {e}")+ logger.error(f"WebSocket received error while waiting for: {request} {e}")raise efinally:del self._waiting_for_replies[id]- logger.info(f"Removed waiting handler for {id}")+ logger.debug(f"WebSocket removed waiting handler for {id}")async def _receive_message(self, data: Data):+ logger.debug(f"Processing message: {data}".strip())+message = to_response_or_notification(json.loads(data))- logger.info(f"Current waiting handlers: {self._waiting_for_replies}")+ logger.debug(+ f"Current waiting handlers: {list(self._waiting_for_replies.keys())}"+ )if isinstance(message, Ok):if (message.id in self._waiting_for_repliesdiff --git a/packages/python-sdk/e2b/session/websocket_client.py b/packages/python-sdk/e2b/session/websocket_client.pyindex 23a23cb86..b606d14d4 100644--- a/packages/python-sdk/e2b/session/websocket_client.py+++ b/packages/python-sdk/e2b/session/websocket_client.py@@ -36,33 +36,35 @@ class WebSocket:await self.close()async def _send_message(self):- logger.info("Starting to send messages")+ logger.debug("WebSocket starting to send messages")while True:if self._queue_in.empty():await asyncio.sleep(0)continuemessage = self._queue_in.get()- logger.debug(f"Got message: {message}")+ logger.debug(f"WebSocket message to send: {message}")if self._ws:await self._ws.send(message)+ logger.debug(f"WebSocket message sent: {message}")self._queue_in.task_done()else:- logger.error("No websocket connection")+ logger.error("No WebSocket connection")async def _receive_message(self):try:async for message in self._ws:- logger.debug(f"Received message: {message}")+ logger.debug(f"WebSocket received message: {message}".strip())self._queue_out.put(message)except Exception as e:- logger.error(f"Error: {e}")+ logger.error(f"WebSocket received error while receiving messages: {e}")async def _connect(self):+ logger.debug(f"WebSocket connecting to {self.url}")async for websocket in connect(self.url, max_size=None, max_queue=None):try:self._ws = websocketself.started.set()- logger.info(f"Connected to {self.url}")+ logger.info(f"WebSocket connected to {self.url}")send_task = asyncio.create_task(self._send_message(), name="send_message"@@ -80,7 +82,7 @@ class WebSocket:logger.info("WebSocket stopped")breakexcept ConnectionClosed:- logger.warning("Reconnecting...")+ logger.warning("WebSocket disconnected, it will try to reconnect")continueasync def close(self):diff --git a/packages/python-sdk/e2b/utils/str.py b/packages/python-sdk/e2b/utils/str.pynew file mode 100644index 000000000..6bedcac13--- /dev/null+++ b/packages/python-sdk/e2b/utils/str.py@@ -0,0 +1,5 @@+import re+++def camel_case_to_snake_case(text: str) -> str:+ return re.sub(r"(?<!^)(?=[A-Z])", "_", text).lower()diff --git a/packages/python-sdk/tests/test_timeout.py b/packages/python-sdk/tests/test_timeout.pynew file mode 100644index 000000000..e77e85d94--- /dev/null+++ b/packages/python-sdk/tests/test_timeout.py@@ -0,0 +1,33 @@+import asyncio+from os import getenv++import pytest+from e2b import Session++E2B_API_KEY = getenv("E2B_API_KEY")+++async def test_create_session_timeout():+ with pytest.raises(asyncio.TimeoutError):+ await Session.create("Nodejs", api_key=E2B_API_KEY, timeout=0.1)+++async def test_process_timeout():+ with pytest.raises(asyncio.TimeoutError):+ session = await Session.create("Nodejs", api_key=E2B_API_KEY)+ await session.process.start(+ "sleep 1",+ timeout=0.1,+ )+ await session.close()+++async def test_filesystem_timeout():+ with pytest.raises(asyncio.TimeoutError):+ session = await Session.create("Nodejs", api_key=E2B_API_KEY)+ await session.filesystem.write(+ "test.txt",+ "Hello World",+ timeout=0.1,+ )+ await session.close()