snowglobe 0.4.9__py3-none-any.whl → 0.4.11__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 +13 -2
- snowglobe/client/src/telemetry.py +31 -17
- snowglobe/client/src/utils.py +12 -3
- {snowglobe-0.4.9.dist-info → snowglobe-0.4.11.dist-info}/METADATA +1 -1
- snowglobe-0.4.11.dist-info/RECORD +16 -0
- snowglobe-0.4.9.dist-info/RECORD +0 -16
- {snowglobe-0.4.9.dist-info → snowglobe-0.4.11.dist-info}/WHEEL +0 -0
- {snowglobe-0.4.9.dist-info → snowglobe-0.4.11.dist-info}/entry_points.txt +0 -0
- {snowglobe-0.4.9.dist-info → snowglobe-0.4.11.dist-info}/licenses/LICENSE +0 -0
- {snowglobe-0.4.9.dist-info → snowglobe-0.4.11.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", "")
|
@@ -193,6 +200,10 @@ async def process_application_heartbeat(app_id):
|
|
193
200
|
connection_test_payload["error"] = f"{str(e)}\n{traceback.format_exc()}"
|
194
201
|
connection_test_payload["app_id"] = app_id
|
195
202
|
connection_test_payload["applicationId"] = app_id
|
203
|
+
LOGGER.error(
|
204
|
+
f"Error processing heartbeat for application {app_id}: {connection_test_payload['error']}"
|
205
|
+
)
|
206
|
+
LOGGER.error(traceback.format_exc())
|
196
207
|
|
197
208
|
connection_test_url = (
|
198
209
|
f"{config.CONTROL_PLANE_URL}/api/successful-code-connection-tests"
|
@@ -8,6 +8,7 @@ from snowglobe.client.src.models import CompletionRequest, RiskEvaluationRequest
|
|
8
8
|
try:
|
9
9
|
import mlflow
|
10
10
|
import mlflow.tracing
|
11
|
+
from databricks.sdk import WorkspaceClient
|
11
12
|
|
12
13
|
mlflow.tracing.enable()
|
13
14
|
except ImportError:
|
@@ -28,11 +29,17 @@ def trace_completion_fn(
|
|
28
29
|
def trace_decorator(completion_fn: Callable):
|
29
30
|
disable_mlflow = os.getenv("SNOWGLOBE_DISABLE_MLFLOW_TRACING") or ""
|
30
31
|
if mlflow and disable_mlflow.lower() != "true":
|
32
|
+
w = WorkspaceClient()
|
33
|
+
current_user = w.current_user.me()
|
34
|
+
|
35
|
+
formatted_sim_name = simulation_name.lower().replace(" ", "_")
|
36
|
+
default_experiment_name = f"/Users/{current_user.user_name}/{formatted_sim_name}"
|
37
|
+
|
31
38
|
mlflow_experiment_name = (
|
32
|
-
os.getenv("MLFLOW_EXPERIMENT_NAME") or
|
39
|
+
os.getenv("MLFLOW_EXPERIMENT_NAME") or default_experiment_name
|
33
40
|
)
|
34
41
|
mlflow.set_experiment(mlflow_experiment_name)
|
35
|
-
|
42
|
+
|
36
43
|
mlflow_active_model_id = os.getenv("MLFLOW_ACTIVE_MODEL_ID")
|
37
44
|
if mlflow_active_model_id:
|
38
45
|
mlflow.set_active_model(model_id=mlflow_active_model_id)
|
@@ -42,9 +49,9 @@ def trace_completion_fn(
|
|
42
49
|
span_attributes = {
|
43
50
|
"snowglobe.version": SNOWGLOBE_VERSION,
|
44
51
|
"type": span_type,
|
45
|
-
"session_id": session_id,
|
46
|
-
"conversation_id": conversation_id,
|
47
|
-
"message_id": message_id,
|
52
|
+
"session_id": str(session_id),
|
53
|
+
"conversation_id": str(conversation_id),
|
54
|
+
"message_id": str(message_id),
|
48
55
|
"simulation_name": simulation_name,
|
49
56
|
"agent_name": agent_name,
|
50
57
|
}
|
@@ -58,11 +65,11 @@ def trace_completion_fn(
|
|
58
65
|
async def completion_fn_wrapper(test_request: CompletionRequest):
|
59
66
|
try:
|
60
67
|
mlflow.update_current_trace(
|
61
|
-
metadata={"mlflow.trace.session": session_id},
|
68
|
+
metadata={"mlflow.trace.session": str(session_id)},
|
62
69
|
tags={
|
63
|
-
"session_id": session_id,
|
64
|
-
"conversation_id": conversation_id,
|
65
|
-
"message_id": message_id,
|
70
|
+
"session_id": str(session_id),
|
71
|
+
"conversation_id": str(conversation_id),
|
72
|
+
"message_id": str(message_id),
|
66
73
|
"simulation_name": simulation_name,
|
67
74
|
"agent_name": agent_name,
|
68
75
|
},
|
@@ -92,8 +99,14 @@ def trace_risk_evaluation_fn(
|
|
92
99
|
def trace_decorator(risk_evaluation_fn: Callable):
|
93
100
|
disable_mlflow = os.getenv("SNOWGLOBE_DISABLE_MLFLOW_TRACING") or ""
|
94
101
|
if mlflow and disable_mlflow.lower() != "true":
|
102
|
+
w = WorkspaceClient()
|
103
|
+
current_user = w.current_user.me()
|
104
|
+
|
105
|
+
formatted_sim_name = simulation_name.lower().replace(" ", "_")
|
106
|
+
default_experiment_name = f"/Users/{current_user.user_name}/{formatted_sim_name}"
|
107
|
+
|
95
108
|
mlflow_experiment_name = (
|
96
|
-
os.getenv("MLFLOW_EXPERIMENT_NAME") or
|
109
|
+
os.getenv("MLFLOW_EXPERIMENT_NAME") or default_experiment_name
|
97
110
|
)
|
98
111
|
mlflow.set_experiment(mlflow_experiment_name)
|
99
112
|
|
@@ -102,12 +115,13 @@ def trace_risk_evaluation_fn(
|
|
102
115
|
mlflow.set_active_model(model_id=mlflow_active_model_id)
|
103
116
|
else:
|
104
117
|
mlflow.set_active_model(name=agent_name)
|
118
|
+
|
105
119
|
span_attributes = {
|
106
120
|
"snowglobe.version": SNOWGLOBE_VERSION,
|
107
121
|
"type": span_type,
|
108
|
-
"session_id": session_id,
|
109
|
-
"conversation_id": conversation_id,
|
110
|
-
"message_id": message_id,
|
122
|
+
"session_id": str(session_id),
|
123
|
+
"conversation_id": str(conversation_id),
|
124
|
+
"message_id": str(message_id),
|
111
125
|
"simulation_name": simulation_name,
|
112
126
|
"agent_name": agent_name,
|
113
127
|
"risk_name": risk_name,
|
@@ -124,11 +138,11 @@ def trace_risk_evaluation_fn(
|
|
124
138
|
):
|
125
139
|
try:
|
126
140
|
mlflow.update_current_trace(
|
127
|
-
metadata={"mlflow.trace.session": session_id},
|
141
|
+
metadata={"mlflow.trace.session": str(session_id)},
|
128
142
|
tags={
|
129
|
-
"session_id": session_id,
|
130
|
-
"conversation_id": conversation_id,
|
131
|
-
"message_id": message_id,
|
143
|
+
"session_id": str(session_id),
|
144
|
+
"conversation_id": str(conversation_id),
|
145
|
+
"message_id": str(message_id),
|
132
146
|
"simulation_name": simulation_name,
|
133
147
|
"agent_name": agent_name,
|
134
148
|
"risk_name": risk_name,
|
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:
|
@@ -0,0 +1,16 @@
|
|
1
|
+
snowglobe/client/__init__.py,sha256=kzp9wPUUYBXqDSKZbfmD4vrAQvrWSW5HOvtpFlEJWfs,353
|
2
|
+
snowglobe/client/src/app.py,sha256=QOqwK4134siIDnrlY2vpRJ6DiwDVKVmrJszzp5z_RE0,43117
|
3
|
+
snowglobe/client/src/cli.py,sha256=I3LVWJmyvUzOQlV0gv_AeMuEazfy8GsYdH6svo7cZOU,28544
|
4
|
+
snowglobe/client/src/cli_utils.py,sha256=6C7J5gow8xveQYF4w6ewtQJKI7VvlLTx7FS_7gl7RwI,17227
|
5
|
+
snowglobe/client/src/config.py,sha256=YRx_AQEZoHaAqk6guTxynIEGV_iJ3wNNGtMmaKsYMbc,10488
|
6
|
+
snowglobe/client/src/models.py,sha256=BX310WrDN9Fd8v68me3XGL_ic1ulvjCrZyIT2ND1eUo,866
|
7
|
+
snowglobe/client/src/project_manager.py,sha256=Ze-qs4dQI2kIV-PmtWZ1b67hMUfsnsMHus90aT8HOow,9970
|
8
|
+
snowglobe/client/src/stats.py,sha256=IdaXroOZBmvLVa_p9pDE6hsxsc7-fBEDnLf8O6Ch0GA,1596
|
9
|
+
snowglobe/client/src/telemetry.py,sha256=CLrnKtCRnq-wGraFHdMcgUqY4-YX1JqxQpnAdWy_wok,5679
|
10
|
+
snowglobe/client/src/utils.py,sha256=F86gku68IyjXzUleZXc9QyzFfWV4PBa9LKukAo9gJl8,4198
|
11
|
+
snowglobe-0.4.11.dist-info/licenses/LICENSE,sha256=S90V6iFU5ZeSg44JQYS1To3pa7ZEobrHc_t483qSKSI,1070
|
12
|
+
snowglobe-0.4.11.dist-info/METADATA,sha256=wExQyglcFQS8zPMvSy81EEin2t7i37XvAb5Ln4XtZIU,5407
|
13
|
+
snowglobe-0.4.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
snowglobe-0.4.11.dist-info/entry_points.txt,sha256=mqx4mTwFPHttjctE2ceYTYWCCIG30Ji2C89aaCYgHcM,71
|
15
|
+
snowglobe-0.4.11.dist-info/top_level.txt,sha256=PoyYihnCBjRyjeIT19yBcE47JTe7i1OwRXvJ4d5EohM,10
|
16
|
+
snowglobe-0.4.11.dist-info/RECORD,,
|
snowglobe-0.4.9.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
snowglobe/client/__init__.py,sha256=kzp9wPUUYBXqDSKZbfmD4vrAQvrWSW5HOvtpFlEJWfs,353
|
2
|
-
snowglobe/client/src/app.py,sha256=CaDtbMn6ZXooQJuaPAHOXs2r9FkFqDxTrgqoW3Rl_2I,42686
|
3
|
-
snowglobe/client/src/cli.py,sha256=I3LVWJmyvUzOQlV0gv_AeMuEazfy8GsYdH6svo7cZOU,28544
|
4
|
-
snowglobe/client/src/cli_utils.py,sha256=6C7J5gow8xveQYF4w6ewtQJKI7VvlLTx7FS_7gl7RwI,17227
|
5
|
-
snowglobe/client/src/config.py,sha256=YRx_AQEZoHaAqk6guTxynIEGV_iJ3wNNGtMmaKsYMbc,10488
|
6
|
-
snowglobe/client/src/models.py,sha256=BX310WrDN9Fd8v68me3XGL_ic1ulvjCrZyIT2ND1eUo,866
|
7
|
-
snowglobe/client/src/project_manager.py,sha256=Ze-qs4dQI2kIV-PmtWZ1b67hMUfsnsMHus90aT8HOow,9970
|
8
|
-
snowglobe/client/src/stats.py,sha256=IdaXroOZBmvLVa_p9pDE6hsxsc7-fBEDnLf8O6Ch0GA,1596
|
9
|
-
snowglobe/client/src/telemetry.py,sha256=N91Q37YfJaUYPa7BUAs_3x4LxjculwlETIKC5k1dbig,5045
|
10
|
-
snowglobe/client/src/utils.py,sha256=hHOht0hc8fv3OuPTz2Tqs639CzSAF34JTZs5ifKV6YI,3708
|
11
|
-
snowglobe-0.4.9.dist-info/licenses/LICENSE,sha256=S90V6iFU5ZeSg44JQYS1To3pa7ZEobrHc_t483qSKSI,1070
|
12
|
-
snowglobe-0.4.9.dist-info/METADATA,sha256=NckGusSPGxCyboKGK79F-PiNaXstK6FOxmM0p0lOB5g,5406
|
13
|
-
snowglobe-0.4.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
-
snowglobe-0.4.9.dist-info/entry_points.txt,sha256=mqx4mTwFPHttjctE2ceYTYWCCIG30Ji2C89aaCYgHcM,71
|
15
|
-
snowglobe-0.4.9.dist-info/top_level.txt,sha256=PoyYihnCBjRyjeIT19yBcE47JTe7i1OwRXvJ4d5EohM,10
|
16
|
-
snowglobe-0.4.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|