snowglobe 0.4.10__py3-none-any.whl → 0.4.12__py3-none-any.whl
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.
- snowglobe/client/src/app.py +28 -5
- snowglobe/client/src/cli.py +5 -1
- snowglobe/client/src/utils.py +12 -3
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/METADATA +1 -1
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/RECORD +9 -9
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/WHEEL +0 -0
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/entry_points.txt +0 -0
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/licenses/LICENSE +0 -0
- {snowglobe-0.4.10.dist-info → snowglobe-0.4.12.dist-info}/top_level.txt +0 -0
snowglobe/client/src/app.py
CHANGED
@@ -26,7 +26,7 @@ from snowglobe.client.src.telemetry import trace_completion_fn, trace_risk_evalu
|
|
26
26
|
|
27
27
|
from .cli_utils import info, shutdown_manager
|
28
28
|
from .config import config, get_api_key_or_raise
|
29
|
-
from .models import CompletionFunctionOutputs, CompletionRequest, RiskEvaluationRequest
|
29
|
+
from .models import CompletionFunctionOutputs, CompletionRequest, RiskEvaluationRequest, SnowglobeData, SnowglobeMessage
|
30
30
|
from .stats import initialize_stats, track_batch_completion
|
31
31
|
from .utils import fetch_experiments, fetch_messages
|
32
32
|
|
@@ -129,7 +129,14 @@ async def process_application_heartbeat(app_id):
|
|
129
129
|
}
|
130
130
|
try:
|
131
131
|
prompt = "Hello from Snowglobe!"
|
132
|
-
test_request = CompletionRequest(
|
132
|
+
test_request = CompletionRequest(
|
133
|
+
messages=[SnowglobeMessage(
|
134
|
+
role="user",
|
135
|
+
content=prompt,
|
136
|
+
snowglobe_data=SnowglobeData(
|
137
|
+
conversation_id="test", test_id="test"
|
138
|
+
),
|
139
|
+
)])
|
133
140
|
heartbeat_id = uuid.uuid4().hex
|
134
141
|
agent = apps.get(app_id, {})
|
135
142
|
agent_name = agent.get("name", "")
|
@@ -150,7 +157,11 @@ async def process_application_heartbeat(app_id):
|
|
150
157
|
)
|
151
158
|
async def run_completion_fn(completion_request: CompletionRequest):
|
152
159
|
if asyncio.iscoroutinefunction(completion_fn):
|
153
|
-
|
160
|
+
try:
|
161
|
+
asyncio.get_running_loop()
|
162
|
+
response = await completion_fn(completion_request)
|
163
|
+
except RuntimeError:
|
164
|
+
response = asyncio.run(completion_fn(completion_request))
|
154
165
|
else:
|
155
166
|
response = completion_fn(completion_request)
|
156
167
|
return response
|
@@ -193,6 +204,10 @@ async def process_application_heartbeat(app_id):
|
|
193
204
|
connection_test_payload["error"] = f"{str(e)}\n{traceback.format_exc()}"
|
194
205
|
connection_test_payload["app_id"] = app_id
|
195
206
|
connection_test_payload["applicationId"] = app_id
|
207
|
+
LOGGER.error(
|
208
|
+
f"Error processing heartbeat for application {app_id}: {connection_test_payload['error']}"
|
209
|
+
)
|
210
|
+
LOGGER.error(traceback.format_exc())
|
196
211
|
|
197
212
|
connection_test_url = (
|
198
213
|
f"{config.CONTROL_PLANE_URL}/api/successful-code-connection-tests"
|
@@ -239,7 +254,11 @@ async def process_risk_evaluation(test, risk_name, simulation_name, agent_name):
|
|
239
254
|
)
|
240
255
|
async def run_risk_evaluation_fn(risk_evaluation_request: RiskEvaluationRequest):
|
241
256
|
if asyncio.iscoroutinefunction(risks[risk_name]):
|
242
|
-
|
257
|
+
try:
|
258
|
+
asyncio.get_running_loop()
|
259
|
+
risk_evaluation = await risks[risk_name](risk_evaluation_request)
|
260
|
+
except RuntimeError:
|
261
|
+
risk_evaluation = asyncio.run(risks[risk_name](risk_evaluation_request))
|
243
262
|
else:
|
244
263
|
risk_evaluation = risks[risk_name](risk_evaluation_request)
|
245
264
|
return risk_evaluation
|
@@ -301,7 +320,11 @@ async def process_test(test, completion_fn, app_id, simulation_name):
|
|
301
320
|
)
|
302
321
|
async def run_completion_fn(completion_request: CompletionRequest):
|
303
322
|
if asyncio.iscoroutinefunction(completion_fn):
|
304
|
-
|
323
|
+
try:
|
324
|
+
asyncio.get_running_loop()
|
325
|
+
completionOutput = await completion_fn(completion_request)
|
326
|
+
except RuntimeError:
|
327
|
+
completionOutput = asyncio.run(completion_fn(completion_request))
|
305
328
|
else:
|
306
329
|
completionOutput = completion_fn(completion_request)
|
307
330
|
return completionOutput
|
snowglobe/client/src/cli.py
CHANGED
@@ -401,7 +401,11 @@ def test_agent_wrapper(filename: str, app_id: str, app_name: str) -> Tuple[bool,
|
|
401
401
|
)
|
402
402
|
async def run_process_scenario(completion_request: CompletionRequest):
|
403
403
|
if asyncio.iscoroutinefunction(process_scenario):
|
404
|
-
|
404
|
+
try:
|
405
|
+
asyncio.get_running_loop()
|
406
|
+
response = await process_scenario(completion_request)
|
407
|
+
except RuntimeError:
|
408
|
+
response = asyncio.run(process_scenario(completion_request))
|
405
409
|
else:
|
406
410
|
response = process_scenario(completion_request)
|
407
411
|
return response
|
snowglobe/client/src/utils.py
CHANGED
@@ -16,13 +16,22 @@ async def fetch_experiments(app_id: str = None) -> list[dict]:
|
|
16
16
|
list[dict]: A list of experiments.
|
17
17
|
"""
|
18
18
|
async with httpx.AsyncClient() as client:
|
19
|
-
experiments_url = f"{config.CONTROL_PLANE_URL}/api/experiments
|
19
|
+
experiments_url = f"{config.CONTROL_PLANE_URL}/api/experiments?evaluated=false"
|
20
|
+
|
20
21
|
if app_id:
|
21
22
|
experiments_url += f"&appId={config.APPLICATION_ID}"
|
22
|
-
|
23
|
+
try:
|
24
|
+
# get elapsed time for this request
|
25
|
+
import time
|
26
|
+
start_time = time.monotonic()
|
27
|
+
experiments_response = await client.get(
|
23
28
|
experiments_url,
|
24
29
|
headers={"x-api-key": get_api_key_or_raise()},
|
25
|
-
|
30
|
+
timeout=60.0, # Set timeout to 60 seconds
|
31
|
+
)
|
32
|
+
except httpx.ConnectTimeout:
|
33
|
+
elapsed_time = time.monotonic() - start_time
|
34
|
+
raise Exception(f"Warning: Connection timed out while fetching experiments. Elapsed time: {elapsed_time:.2f} seconds. Polling will continue. If this persists please contact Snowglobe support.")
|
26
35
|
|
27
36
|
if not experiments_response.status_code == 200:
|
28
37
|
try:
|
@@ -1,16 +1,16 @@
|
|
1
1
|
snowglobe/client/__init__.py,sha256=kzp9wPUUYBXqDSKZbfmD4vrAQvrWSW5HOvtpFlEJWfs,353
|
2
|
-
snowglobe/client/src/app.py,sha256=
|
3
|
-
snowglobe/client/src/cli.py,sha256=
|
2
|
+
snowglobe/client/src/app.py,sha256=LR_ctj2QMkgaZjognm0xYjl-Xekj9jEnrPSc0XfnSOA,43670
|
3
|
+
snowglobe/client/src/cli.py,sha256=SKOhPvJhRphSwFvF8OsZ6l_QEaqpzlo83oT3GwgXtzc,28727
|
4
4
|
snowglobe/client/src/cli_utils.py,sha256=6C7J5gow8xveQYF4w6ewtQJKI7VvlLTx7FS_7gl7RwI,17227
|
5
5
|
snowglobe/client/src/config.py,sha256=YRx_AQEZoHaAqk6guTxynIEGV_iJ3wNNGtMmaKsYMbc,10488
|
6
6
|
snowglobe/client/src/models.py,sha256=BX310WrDN9Fd8v68me3XGL_ic1ulvjCrZyIT2ND1eUo,866
|
7
7
|
snowglobe/client/src/project_manager.py,sha256=Ze-qs4dQI2kIV-PmtWZ1b67hMUfsnsMHus90aT8HOow,9970
|
8
8
|
snowglobe/client/src/stats.py,sha256=IdaXroOZBmvLVa_p9pDE6hsxsc7-fBEDnLf8O6Ch0GA,1596
|
9
9
|
snowglobe/client/src/telemetry.py,sha256=CLrnKtCRnq-wGraFHdMcgUqY4-YX1JqxQpnAdWy_wok,5679
|
10
|
-
snowglobe/client/src/utils.py,sha256=
|
11
|
-
snowglobe-0.4.
|
12
|
-
snowglobe-0.4.
|
13
|
-
snowglobe-0.4.
|
14
|
-
snowglobe-0.4.
|
15
|
-
snowglobe-0.4.
|
16
|
-
snowglobe-0.4.
|
10
|
+
snowglobe/client/src/utils.py,sha256=F86gku68IyjXzUleZXc9QyzFfWV4PBa9LKukAo9gJl8,4198
|
11
|
+
snowglobe-0.4.12.dist-info/licenses/LICENSE,sha256=S90V6iFU5ZeSg44JQYS1To3pa7ZEobrHc_t483qSKSI,1070
|
12
|
+
snowglobe-0.4.12.dist-info/METADATA,sha256=wrg-xcWGzAZEkWm82469y0stXMdLDs-sxYuynhWC0do,5407
|
13
|
+
snowglobe-0.4.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
snowglobe-0.4.12.dist-info/entry_points.txt,sha256=mqx4mTwFPHttjctE2ceYTYWCCIG30Ji2C89aaCYgHcM,71
|
15
|
+
snowglobe-0.4.12.dist-info/top_level.txt,sha256=PoyYihnCBjRyjeIT19yBcE47JTe7i1OwRXvJ4d5EohM,10
|
16
|
+
snowglobe-0.4.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|