snowglobe 0.4.10__tar.gz → 0.4.12__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.
Files changed (26) hide show
  1. {snowglobe-0.4.10/src/snowglobe.egg-info → snowglobe-0.4.12}/PKG-INFO +1 -1
  2. {snowglobe-0.4.10 → snowglobe-0.4.12}/pyproject.toml +1 -1
  3. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/app.py +28 -5
  4. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/cli.py +5 -1
  5. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/utils.py +12 -3
  6. {snowglobe-0.4.10 → snowglobe-0.4.12/src/snowglobe.egg-info}/PKG-INFO +1 -1
  7. {snowglobe-0.4.10 → snowglobe-0.4.12}/LICENSE +0 -0
  8. {snowglobe-0.4.10 → snowglobe-0.4.12}/README.md +0 -0
  9. {snowglobe-0.4.10 → snowglobe-0.4.12}/setup.cfg +0 -0
  10. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/__init__.py +0 -0
  11. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/cli_utils.py +0 -0
  12. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/config.py +0 -0
  13. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/models.py +0 -0
  14. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/project_manager.py +0 -0
  15. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/stats.py +0 -0
  16. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe/client/src/telemetry.py +0 -0
  17. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe.egg-info/SOURCES.txt +0 -0
  18. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe.egg-info/dependency_links.txt +0 -0
  19. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe.egg-info/entry_points.txt +0 -0
  20. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe.egg-info/requires.txt +0 -0
  21. {snowglobe-0.4.10 → snowglobe-0.4.12}/src/snowglobe.egg-info/top_level.txt +0 -0
  22. {snowglobe-0.4.10 → snowglobe-0.4.12}/tests/test_app.py +0 -0
  23. {snowglobe-0.4.10 → snowglobe-0.4.12}/tests/test_cli.py +0 -0
  24. {snowglobe-0.4.10 → snowglobe-0.4.12}/tests/test_config.py +0 -0
  25. {snowglobe-0.4.10 → snowglobe-0.4.12}/tests/test_heartbeat.py +0 -0
  26. {snowglobe-0.4.10 → snowglobe-0.4.12}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowglobe
3
- Version: 0.4.10
3
+ Version: 0.4.12
4
4
  Summary: client server for usage with snowglobe experiments
5
5
  Author-email: Guardrails AI <contact@guardrailsai.com>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "snowglobe"
3
- version = "0.4.10"
3
+ version = "0.4.12"
4
4
  authors = [
5
5
  {name = "Guardrails AI", email = "contact@guardrailsai.com"}
6
6
  ]
@@ -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(messages=[{"role": "user", "content": prompt}])
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
- response = await completion_fn(completion_request)
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
- risk_evaluation = await risks[risk_name](risk_evaluation_request)
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
- completionOutput = await completion_fn(completion_request)
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
@@ -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
- response = asyncio.run(process_scenario(completion_request))
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
@@ -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?&evaluated=false"
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
- experiments_response = await client.get(
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowglobe
3
- Version: 0.4.10
3
+ Version: 0.4.12
4
4
  Summary: client server for usage with snowglobe experiments
5
5
  Author-email: Guardrails AI <contact@guardrailsai.com>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes