runcloud-sdk 0.7.1__tar.gz → 0.7.3__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.4
2
2
  Name: runcloud-sdk
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Python SDK for run.cloud, including sandbox-provider compatibility adapters
5
5
  Author: Newly
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "runcloud-sdk"
3
- version = "0.7.1"
3
+ version = "0.7.3"
4
4
  description = "Python SDK for run.cloud, including sandbox-provider compatibility adapters"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -15,6 +15,7 @@ from typing import Any, Callable, Optional, Union
15
15
 
16
16
  Transport = Callable[[str, str, Any], Any]
17
17
  DEFAULT_API_URL = "https://api.run.cloud"
18
+ USER_AGENT = "runcloud-python/0.7.3"
18
19
 
19
20
 
20
21
  class RunCloudError(Exception):
@@ -131,6 +132,7 @@ class Client:
131
132
  headers={
132
133
  "Authorization": "Bearer " + self.api_key,
133
134
  "Content-Type": "application/json",
135
+ "User-Agent": USER_AGENT,
134
136
  },
135
137
  )
136
138
  try:
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import io
5
6
  from typing import Optional
6
7
 
7
8
  from runcloud.client import (
@@ -54,12 +55,8 @@ class Process:
54
55
  return self.returncode
55
56
 
56
57
 
57
- class _Reader:
58
- def __init__(self, value: str):
59
- self._value = value
60
-
61
- def read(self):
62
- return self._value
58
+ class _Reader(io.StringIO):
59
+ pass
63
60
 
64
61
 
65
62
  class App:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runcloud-sdk
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Python SDK for run.cloud, including sandbox-provider compatibility adapters
5
5
  Author: Newly
6
6
  License-Expression: Apache-2.0
@@ -34,6 +34,17 @@ class Recorder:
34
34
  return SANDBOX
35
35
 
36
36
 
37
+ class Response:
38
+ def __enter__(self):
39
+ return self
40
+
41
+ def __exit__(self, *_):
42
+ return None
43
+
44
+ def read(self):
45
+ return b"{}"
46
+
47
+
37
48
  class SDKTests(unittest.TestCase):
38
49
  def setUp(self):
39
50
  self.recorder = Recorder()
@@ -61,7 +72,12 @@ class SDKTests(unittest.TestCase):
61
72
 
62
73
  def test_compatibility_adapters_share_the_public_client(self):
63
74
  app = modal.App.lookup("compat", client=self.client)
64
- self.assertEqual(modal.Sandbox.create(app=app).exec("echo ok").wait(), 0)
75
+ modal_sandbox = modal.Sandbox.create(app=app)
76
+ read_process = modal_sandbox.exec("echo ok")
77
+ self.assertEqual(read_process.stdout.read(), "ok\n")
78
+ self.assertEqual(read_process.wait(), 0)
79
+ iter_process = modal_sandbox.exec("echo ok")
80
+ self.assertEqual(list(iter_process.stdout), ["ok\n"])
65
81
  self.assertEqual(
66
82
  E2BSandbox.create(client=self.client).commands.run("echo ok").exit_code, 0
67
83
  )
@@ -80,6 +96,16 @@ class SDKTests(unittest.TestCase):
80
96
  with self.assertRaises(UnsupportedCompatibilityFeatureError):
81
97
  modal.Image.debian_slim().pip_install("requests")
82
98
 
99
+ def test_requests_identify_the_python_sdk(self):
100
+ with patch(
101
+ "runcloud.client.urllib.request.urlopen",
102
+ return_value=Response(),
103
+ ) as urlopen:
104
+ Client(api_key="rc_live_test").request("GET", "/run-cloud/account")
105
+
106
+ request = urlopen.call_args.args[0]
107
+ self.assertEqual(request.get_header("User-agent"), "runcloud-python/0.7.3")
108
+
83
109
 
84
110
  class CredentialTests(unittest.TestCase):
85
111
  def setUp(self):
File without changes
File without changes
File without changes