blaxel 0.2.31__py3-none-any.whl → 0.2.31rc121__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.
- blaxel/__init__.py +3 -3
- blaxel/core/agents/__init__.py +6 -13
- blaxel/core/authentication/__init__.py +1 -2
- blaxel/core/authentication/devicemode.py +1 -9
- blaxel/core/authentication/oauth.py +6 -13
- blaxel/core/authentication/types.py +0 -1
- blaxel/core/cache/cache.py +3 -10
- blaxel/core/client/api/agents/list_agent_revisions.py +1 -3
- blaxel/core/client/api/compute/delete_sandbox_preview_token.py +2 -6
- blaxel/core/client/api/compute/start_sandbox.py +1 -3
- blaxel/core/client/api/compute/stop_sandbox.py +1 -3
- blaxel/core/client/api/default/list_sandbox_hub_definitions.py +2 -6
- blaxel/core/client/api/functions/list_function_revisions.py +1 -3
- blaxel/core/client/api/images/cleanup_images.py +1 -3
- blaxel/core/client/api/integrations/list_integration_connections.py +2 -6
- blaxel/core/client/api/invitations/list_all_pending_invitations.py +1 -3
- blaxel/core/client/api/jobs/create_job_execution.py +1 -3
- blaxel/core/client/api/jobs/delete_job_execution.py +1 -3
- blaxel/core/client/api/jobs/get_job_execution.py +1 -3
- blaxel/core/client/api/jobs/list_job_executions.py +2 -6
- blaxel/core/client/api/jobs/list_job_revisions.py +1 -3
- blaxel/core/client/api/locations/list_locations.py +1 -3
- blaxel/core/client/api/models/list_model_revisions.py +1 -3
- blaxel/core/client/api/service_accounts/create_workspace_service_account.py +2 -6
- blaxel/core/client/api/service_accounts/delete_workspace_service_account.py +2 -6
- blaxel/core/client/api/service_accounts/get_workspace_service_accounts.py +1 -3
- blaxel/core/client/api/service_accounts/update_workspace_service_account.py +2 -6
- blaxel/core/client/api/volume_templates/list_volume_templates.py +1 -3
- blaxel/core/client/api/workspaces/accept_workspace_invitation.py +2 -6
- blaxel/core/client/api/workspaces/invite_workspace_user.py +2 -6
- blaxel/core/client/api/workspaces/update_workspace_user_role.py +2 -6
- blaxel/core/client/client.py +1 -3
- blaxel/core/client/models/agent.py +4 -11
- blaxel/core/client/models/agent_spec.py +5 -18
- blaxel/core/client/models/billable_time_metric.py +1 -0
- blaxel/core/client/models/configuration.py +1 -0
- blaxel/core/client/models/core_spec.py +3 -10
- blaxel/core/client/models/core_spec_configurations.py +1 -0
- blaxel/core/client/models/create_job_execution_request.py +1 -0
- blaxel/core/client/models/create_job_execution_response.py +1 -0
- blaxel/core/client/models/custom_domain.py +2 -5
- blaxel/core/client/models/custom_domain_metadata.py +1 -0
- blaxel/core/client/models/custom_domain_spec.py +2 -5
- blaxel/core/client/models/delete_volume_template_version_response_200.py +2 -5
- blaxel/core/client/models/entrypoint.py +1 -0
- blaxel/core/client/models/form.py +2 -5
- blaxel/core/client/models/function.py +4 -11
- blaxel/core/client/models/function_spec.py +4 -13
- blaxel/core/client/models/image.py +2 -5
- blaxel/core/client/models/image_spec.py +1 -0
- blaxel/core/client/models/integration.py +3 -10
- blaxel/core/client/models/integration_connection.py +2 -5
- blaxel/core/client/models/integration_connection_spec.py +1 -0
- blaxel/core/client/models/integration_endpoint.py +2 -5
- blaxel/core/client/models/integration_endpoints.py +2 -0
- blaxel/core/client/models/job.py +4 -11
- blaxel/core/client/models/job_execution.py +2 -5
- blaxel/core/client/models/job_execution_spec.py +1 -0
- blaxel/core/client/models/job_execution_task.py +2 -5
- blaxel/core/client/models/job_metrics.py +2 -5
- blaxel/core/client/models/job_spec.py +4 -13
- blaxel/core/client/models/jobs_network_chart.py +1 -0
- blaxel/core/client/models/jobs_success_failed_chart.py +3 -10
- blaxel/core/client/models/latency_metric.py +2 -5
- blaxel/core/client/models/location_response.py +1 -0
- blaxel/core/client/models/mcp_definition.py +2 -5
- blaxel/core/client/models/metadata.py +1 -0
- blaxel/core/client/models/metrics.py +4 -11
- blaxel/core/client/models/model.py +4 -11
- blaxel/core/client/models/model_spec.py +3 -10
- blaxel/core/client/models/pending_invitation_accept.py +2 -5
- blaxel/core/client/models/pending_invitation_render.py +3 -10
- blaxel/core/client/models/policy.py +2 -5
- blaxel/core/client/models/policy_spec.py +4 -11
- blaxel/core/client/models/preview.py +2 -5
- blaxel/core/client/models/preview_spec.py +1 -0
- blaxel/core/client/models/preview_token.py +2 -5
- blaxel/core/client/models/public_ips.py +1 -0
- blaxel/core/client/models/request_duration_over_time_metrics.py +1 -0
- blaxel/core/client/models/request_total_by_origin_metric.py +7 -16
- blaxel/core/client/models/request_total_metric.py +3 -8
- blaxel/core/client/models/resource_metrics.py +17 -58
- blaxel/core/client/models/runtime.py +1 -0
- blaxel/core/client/models/sandbox.py +4 -11
- blaxel/core/client/models/sandbox_definition.py +1 -0
- blaxel/core/client/models/sandbox_lifecycle.py +1 -0
- blaxel/core/client/models/sandbox_spec.py +6 -21
- blaxel/core/client/models/serverless_config.py +1 -0
- blaxel/core/client/models/start_sandbox.py +2 -5
- blaxel/core/client/models/stop_sandbox.py +2 -5
- blaxel/core/client/models/store_agent.py +1 -0
- blaxel/core/client/models/store_configuration.py +1 -0
- blaxel/core/client/models/template.py +1 -0
- blaxel/core/client/models/time_to_first_token_over_time_metrics.py +2 -3
- blaxel/core/client/models/token_rate_metrics.py +1 -0
- blaxel/core/client/models/trigger.py +1 -0
- blaxel/core/client/models/trigger_configuration.py +1 -0
- blaxel/core/client/models/volume.py +4 -11
- blaxel/core/client/models/volume_template.py +2 -5
- blaxel/core/client/models/workspace.py +2 -5
- blaxel/core/client/response_interceptor.py +1 -3
- blaxel/core/common/autoload.py +11 -9
- blaxel/core/common/env.py +8 -10
- blaxel/core/common/settings.py +2 -4
- blaxel/core/common/webhook.py +1 -0
- blaxel/core/jobs/__init__.py +3 -13
- blaxel/core/mcp/client.py +2 -8
- blaxel/core/mcp/server.py +2 -8
- blaxel/core/models/__init__.py +5 -6
- blaxel/core/sandbox/__init__.py +1 -1
- blaxel/core/sandbox/client/api/codegen/get_codegen_reranking_path.py +2 -6
- blaxel/core/sandbox/client/api/fastapply/put_codegen_fastapply_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/delete_filesystem_multipart_upload_id_abort.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/delete_filesystem_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/delete_filesystem_tree_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/get_filesystem_content_search_path.py +1 -3
- blaxel/core/sandbox/client/api/filesystem/get_filesystem_find_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/get_filesystem_search_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/get_watch_filesystem_path.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/post_filesystem_multipart_upload_id_complete.py +2 -6
- blaxel/core/sandbox/client/api/filesystem/put_filesystem_path.py +2 -6
- blaxel/core/sandbox/client/api/process/delete_process_identifier.py +2 -6
- blaxel/core/sandbox/client/api/process/delete_process_identifier_kill.py +2 -6
- blaxel/core/sandbox/client/api/process/get_process.py +1 -3
- blaxel/core/sandbox/client/api/process/get_process_identifier.py +2 -6
- blaxel/core/sandbox/client/api/process/get_process_identifier_logs.py +2 -6
- blaxel/core/sandbox/client/api/process/get_process_identifier_logs_stream.py +2 -6
- blaxel/core/sandbox/client/api/process/post_process.py +2 -6
- blaxel/core/sandbox/client/client.py +1 -3
- blaxel/core/sandbox/client/models/filesystem_multipart_upload_parts.py +1 -3
- blaxel/core/sandbox/default/__init__.py +1 -0
- blaxel/core/sandbox/default/action.py +3 -3
- blaxel/core/sandbox/default/codegen.py +4 -2
- blaxel/core/sandbox/default/filesystem.py +82 -38
- blaxel/core/sandbox/default/interpreter.py +10 -17
- blaxel/core/sandbox/default/preview.py +2 -6
- blaxel/core/sandbox/default/process.py +7 -25
- blaxel/core/sandbox/default/sandbox.py +2 -7
- blaxel/core/sandbox/sync/__init__.py +2 -0
- blaxel/core/sandbox/sync/action.py +3 -2
- blaxel/core/sandbox/sync/codegen.py +5 -1
- blaxel/core/sandbox/sync/filesystem.py +6 -17
- blaxel/core/sandbox/sync/interpreter.py +6 -10
- blaxel/core/sandbox/sync/network.py +2 -0
- blaxel/core/sandbox/sync/preview.py +9 -21
- blaxel/core/sandbox/sync/process.py +8 -32
- blaxel/core/sandbox/sync/sandbox.py +6 -13
- blaxel/core/sandbox/sync/session.py +4 -6
- blaxel/core/sandbox/types.py +1 -2
- blaxel/core/tools/__init__.py +6 -30
- blaxel/core/tools/common.py +1 -1
- blaxel/core/tools/types.py +1 -2
- blaxel/crewai/model.py +5 -20
- blaxel/googleadk/__init__.py +1 -1
- blaxel/googleadk/tools.py +5 -3
- blaxel/langgraph/custom/gemini.py +133 -126
- blaxel/langgraph/model.py +50 -54
- blaxel/langgraph/tools.py +3 -9
- blaxel/llamaindex/custom/cohere.py +16 -25
- blaxel/llamaindex/model.py +57 -44
- blaxel/llamaindex/tools.py +3 -2
- blaxel/pydantic/custom/gemini.py +3 -3
- blaxel/pydantic/tools.py +4 -2
- blaxel/telemetry/exporters.py +3 -10
- blaxel/telemetry/instrumentation/blaxel_langgraph.py +2 -4
- blaxel/telemetry/instrumentation/blaxel_langgraph_gemini.py +5 -22
- blaxel/telemetry/instrumentation/utils.py +3 -3
- blaxel/telemetry/log/log.py +3 -2
- blaxel/telemetry/log/logger.py +15 -21
- blaxel/telemetry/span.py +6 -10
- {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/METADATA +2 -2
- {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/RECORD +174 -174
- {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/WHEEL +0 -0
- {blaxel-0.2.31.dist-info → blaxel-0.2.31rc121.dist-info}/licenses/LICENSE +0 -0
blaxel/telemetry/exporters.py
CHANGED
|
@@ -3,15 +3,11 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import Callable, Dict, Sequence
|
|
4
4
|
|
|
5
5
|
try:
|
|
6
|
-
from opentelemetry.exporter.otlp.proto.http._log_exporter import
|
|
7
|
-
OTLPLogExporter,
|
|
8
|
-
)
|
|
6
|
+
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
|
|
9
7
|
from opentelemetry.exporter.otlp.proto.http.metric_exporter import (
|
|
10
8
|
OTLPMetricExporter,
|
|
11
9
|
)
|
|
12
|
-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import
|
|
13
|
-
OTLPSpanExporter,
|
|
14
|
-
)
|
|
10
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
15
11
|
from opentelemetry.sdk._logs import LogData
|
|
16
12
|
from opentelemetry.sdk.metrics.export import MetricExportResult, MetricsData
|
|
17
13
|
|
|
@@ -37,7 +33,6 @@ class DynamicHeadersSpanExporter(OTLPSpanExporter): # type: ignore[misc]
|
|
|
37
33
|
self._session.headers.update(self._get_headers())
|
|
38
34
|
return super().export(spans)
|
|
39
35
|
|
|
40
|
-
|
|
41
36
|
class DynamicHeadersMetricExporter(OTLPMetricExporter): # type: ignore[misc]
|
|
42
37
|
"""Metric exporter with dynamic headers."""
|
|
43
38
|
|
|
@@ -54,14 +49,12 @@ class DynamicHeadersMetricExporter(OTLPMetricExporter): # type: ignore[misc]
|
|
|
54
49
|
self._session.headers.update(self._get_headers())
|
|
55
50
|
return super().export(metrics_data, timeout_millis, **kwargs)
|
|
56
51
|
|
|
57
|
-
|
|
58
52
|
class DynamicHeadersLogExporter(OTLPLogExporter): # type: ignore[misc]
|
|
59
53
|
"""Log exporter with dynamic headers."""
|
|
60
|
-
|
|
61
54
|
def __init__(self, get_headers: Callable[[], Dict[str, str]]):
|
|
62
55
|
self._get_headers = get_headers
|
|
63
56
|
super().__init__()
|
|
64
57
|
|
|
65
58
|
def export(self, batch: Sequence[LogData]): # type: ignore[reportUnknownReturnType]
|
|
66
59
|
self._session.headers.update(self._get_headers())
|
|
67
|
-
return super().export(batch)
|
|
60
|
+
return super().export(batch)
|
|
@@ -24,15 +24,13 @@ class BlaxelLanggraphInstrumentor(BaseInstrumentor):
|
|
|
24
24
|
|
|
25
25
|
# Restore original methods
|
|
26
26
|
if hasattr(
|
|
27
|
-
blaxel.langgraph.custom.gemini.GeminiRestClient,
|
|
28
|
-
"_blaxel_original_generate_content",
|
|
27
|
+
blaxel.langgraph.custom.gemini.GeminiRestClient, "_blaxel_original_generate_content"
|
|
29
28
|
):
|
|
30
29
|
blaxel.langgraph.custom.gemini.GeminiRestClient.generate_content = (
|
|
31
30
|
blaxel.langgraph.custom.gemini.GeminiRestClient._blaxel_original_generate_content
|
|
32
31
|
)
|
|
33
32
|
delattr(
|
|
34
|
-
blaxel.langgraph.custom.gemini.GeminiRestClient,
|
|
35
|
-
"_blaxel_original_generate_content",
|
|
33
|
+
blaxel.langgraph.custom.gemini.GeminiRestClient, "_blaxel_original_generate_content"
|
|
36
34
|
)
|
|
37
35
|
|
|
38
36
|
if hasattr(
|
|
@@ -7,10 +7,7 @@ from typing import Collection
|
|
|
7
7
|
|
|
8
8
|
from opentelemetry import context as context_api
|
|
9
9
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
10
|
-
from opentelemetry.instrumentation.utils import
|
|
11
|
-
_SUPPRESS_INSTRUMENTATION_KEY,
|
|
12
|
-
unwrap,
|
|
13
|
-
)
|
|
10
|
+
from opentelemetry.instrumentation.utils import _SUPPRESS_INSTRUMENTATION_KEY, unwrap
|
|
14
11
|
from opentelemetry.semconv_ai import (
|
|
15
12
|
SUPPRESS_LANGUAGE_MODEL_INSTRUMENTATION_KEY,
|
|
16
13
|
LLMRequestTypeValues,
|
|
@@ -142,22 +139,12 @@ def _set_input_attributes(span, args, kwargs, llm_model):
|
|
|
142
139
|
_set_span_attribute(span, SpanAttributes.LLM_REQUEST_MODEL, llm_model)
|
|
143
140
|
_set_span_attribute(span, SpanAttributes.LLM_REQUEST_TEMPERATURE, kwargs.get("temperature"))
|
|
144
141
|
_set_span_attribute(
|
|
145
|
-
span,
|
|
146
|
-
SpanAttributes.LLM_REQUEST_MAX_TOKENS,
|
|
147
|
-
kwargs.get("max_output_tokens"),
|
|
142
|
+
span, SpanAttributes.LLM_REQUEST_MAX_TOKENS, kwargs.get("max_output_tokens")
|
|
148
143
|
)
|
|
149
144
|
_set_span_attribute(span, SpanAttributes.LLM_REQUEST_TOP_P, kwargs.get("top_p"))
|
|
150
145
|
_set_span_attribute(span, SpanAttributes.LLM_TOP_K, kwargs.get("top_k"))
|
|
151
|
-
_set_span_attribute(
|
|
152
|
-
|
|
153
|
-
SpanAttributes.LLM_PRESENCE_PENALTY,
|
|
154
|
-
kwargs.get("presence_penalty"),
|
|
155
|
-
)
|
|
156
|
-
_set_span_attribute(
|
|
157
|
-
span,
|
|
158
|
-
SpanAttributes.LLM_FREQUENCY_PENALTY,
|
|
159
|
-
kwargs.get("frequency_penalty"),
|
|
160
|
-
)
|
|
146
|
+
_set_span_attribute(span, SpanAttributes.LLM_PRESENCE_PENALTY, kwargs.get("presence_penalty"))
|
|
147
|
+
_set_span_attribute(span, SpanAttributes.LLM_FREQUENCY_PENALTY, kwargs.get("frequency_penalty"))
|
|
161
148
|
|
|
162
149
|
return
|
|
163
150
|
|
|
@@ -189,11 +176,7 @@ def _set_response_attributes(span, response, llm_model):
|
|
|
189
176
|
_set_span_attribute(span, f"{prefix}.content", item.text)
|
|
190
177
|
_set_span_attribute(span, f"{prefix}.role", "assistant")
|
|
191
178
|
elif isinstance(response.text, str):
|
|
192
|
-
_set_span_attribute(
|
|
193
|
-
span,
|
|
194
|
-
f"{SpanAttributes.LLM_COMPLETIONS}.0.content",
|
|
195
|
-
response.text,
|
|
196
|
-
)
|
|
179
|
+
_set_span_attribute(span, f"{SpanAttributes.LLM_COMPLETIONS}.0.content", response.text)
|
|
197
180
|
_set_span_attribute(span, f"{SpanAttributes.LLM_COMPLETIONS}.0.role", "assistant")
|
|
198
181
|
else:
|
|
199
182
|
if isinstance(response, list):
|
|
@@ -40,7 +40,6 @@ async def start_as_current_span_async(tracer, *args, **kwargs):
|
|
|
40
40
|
with tracer.start_as_current_span(*args, **kwargs) as span:
|
|
41
41
|
yield span
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
class JSONEncoder(json.JSONEncoder):
|
|
45
44
|
def default(self, o):
|
|
46
45
|
if dataclasses.is_dataclass(o):
|
|
@@ -53,8 +52,9 @@ class JSONEncoder(json.JSONEncoder):
|
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
def should_send_prompts():
|
|
56
|
-
return (
|
|
57
|
-
|
|
55
|
+
return (
|
|
56
|
+
os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
|
|
57
|
+
).lower() == "true"
|
|
58
58
|
|
|
59
59
|
@dont_throw
|
|
60
60
|
def process_request(span, args, kwargs):
|
blaxel/telemetry/log/log.py
CHANGED
|
@@ -8,7 +8,6 @@ from opentelemetry.sdk._logs._internal.export import LogExporter
|
|
|
8
8
|
|
|
9
9
|
_logger = logging.getLogger(__name__)
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
class AsyncLogRecordProcessor(LogRecordProcessor):
|
|
13
12
|
"""This is an implementation of LogRecordProcessor which passes
|
|
14
13
|
received logs in the export-friendly LogData representation to the
|
|
@@ -25,7 +24,9 @@ class AsyncLogRecordProcessor(LogRecordProcessor):
|
|
|
25
24
|
def _start_worker(self):
|
|
26
25
|
"""Start the background worker thread."""
|
|
27
26
|
self._worker_thread = threading.Thread(
|
|
28
|
-
target=self._process_logs,
|
|
27
|
+
target=self._process_logs,
|
|
28
|
+
daemon=True,
|
|
29
|
+
name="LogExporterWorker"
|
|
29
30
|
)
|
|
30
31
|
self._worker_thread.start()
|
|
31
32
|
|
blaxel/telemetry/log/logger.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
This module provides a custom colored formatter for logging and an initialization function
|
|
3
3
|
to set up logging configurations for Blaxel applications.
|
|
4
4
|
"""
|
|
5
|
-
|
|
6
5
|
import json
|
|
7
6
|
import logging
|
|
8
7
|
import os
|
|
@@ -14,27 +13,26 @@ class JsonFormatter(logging.Formatter):
|
|
|
14
13
|
"""
|
|
15
14
|
A logger compatible with standard json logging.
|
|
16
15
|
"""
|
|
17
|
-
|
|
18
16
|
def __init__(self):
|
|
19
17
|
super().__init__()
|
|
20
|
-
self.trace_id_name = os.environ.get(
|
|
21
|
-
self.span_id_name = os.environ.get(
|
|
22
|
-
self.labels_name = os.environ.get(
|
|
23
|
-
self.trace_id_prefix = os.environ.get(
|
|
24
|
-
self.span_id_prefix = os.environ.get(
|
|
25
|
-
self.task_index = os.environ.get(
|
|
26
|
-
self.task_prefix = os.environ.get(
|
|
27
|
-
self.execution_key = os.environ.get(
|
|
28
|
-
self.execution_prefix = os.environ.get(
|
|
18
|
+
self.trace_id_name = os.environ.get('BL_LOGGER_TRACE_ID', 'trace_id')
|
|
19
|
+
self.span_id_name = os.environ.get('BL_LOGGER_SPAN_ID', 'span_id')
|
|
20
|
+
self.labels_name = os.environ.get('BL_LOGGER_LABELS', 'labels')
|
|
21
|
+
self.trace_id_prefix = os.environ.get('BL_LOGGER_TRACE_ID_PREFIX', '')
|
|
22
|
+
self.span_id_prefix = os.environ.get('BL_LOGGER_SPAN_ID_PREFIX', '')
|
|
23
|
+
self.task_index = os.environ.get('BL_TASK_KEY', 'TASK_INDEX')
|
|
24
|
+
self.task_prefix = os.environ.get('BL_TASK_PREFIX', '')
|
|
25
|
+
self.execution_key = os.environ.get('BL_EXECUTION_KEY', 'BL_EXECUTION_ID')
|
|
26
|
+
self.execution_prefix = os.environ.get('BL_EXECUTION_PREFIX', '')
|
|
29
27
|
|
|
30
28
|
def format(self, record):
|
|
31
29
|
"""
|
|
32
30
|
Formats the log record by converting it to a JSON object with trace context and environment variables.
|
|
33
31
|
"""
|
|
34
32
|
log_entry = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
self.labels_name: {}
|
|
33
|
+
'message': record.getMessage(),
|
|
34
|
+
'severity': record.levelname,
|
|
35
|
+
self.labels_name: {}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
# Add trace context if available
|
|
@@ -47,14 +45,12 @@ class JsonFormatter(logging.Formatter):
|
|
|
47
45
|
# Add task ID if available
|
|
48
46
|
task_id = os.environ.get(self.task_index)
|
|
49
47
|
if task_id:
|
|
50
|
-
log_entry[self.labels_name][
|
|
48
|
+
log_entry[self.labels_name]['blaxel-task'] = f"{self.task_prefix}{task_id}"
|
|
51
49
|
|
|
52
50
|
# Add execution ID if available
|
|
53
51
|
execution_id = os.environ.get(self.execution_key)
|
|
54
52
|
if execution_id:
|
|
55
|
-
log_entry[self.labels_name][
|
|
56
|
-
f"{self.execution_prefix}{execution_id.split('-')[-1]}"
|
|
57
|
-
)
|
|
53
|
+
log_entry[self.labels_name]['blaxel-execution'] = f"{self.execution_prefix}{execution_id.split('-')[-1]}"
|
|
58
54
|
|
|
59
55
|
return json.dumps(log_entry)
|
|
60
56
|
|
|
@@ -66,7 +62,6 @@ class ColoredFormatter(logging.Formatter):
|
|
|
66
62
|
Attributes:
|
|
67
63
|
COLORS (dict): A mapping of log level names to their corresponding ANSI color codes.
|
|
68
64
|
"""
|
|
69
|
-
|
|
70
65
|
COLORS = {
|
|
71
66
|
"DEBUG": "\033[1;36m", # Cyan
|
|
72
67
|
"INFO": "\033[1;32m", # Green
|
|
@@ -91,7 +86,6 @@ class ColoredFormatter(logging.Formatter):
|
|
|
91
86
|
record.levelname = f"{color}{record.levelname}\033[0m:{tab}"
|
|
92
87
|
return super().format(record)
|
|
93
88
|
|
|
94
|
-
|
|
95
89
|
def init_logger(log_level: str):
|
|
96
90
|
"""
|
|
97
91
|
Initializes the logging configuration for Blaxel.
|
|
@@ -103,7 +97,7 @@ def init_logger(log_level: str):
|
|
|
103
97
|
log_level (str): The logging level to set (e.g., "DEBUG", "INFO").
|
|
104
98
|
"""
|
|
105
99
|
# Disable urllib3 logging
|
|
106
|
-
logging.getLogger(
|
|
100
|
+
logging.getLogger('urllib3').setLevel(logging.CRITICAL)
|
|
107
101
|
logging.getLogger("httpx").setLevel(logging.CRITICAL)
|
|
108
102
|
handler = logging.StreamHandler()
|
|
109
103
|
|
blaxel/telemetry/span.py
CHANGED
|
@@ -12,7 +12,7 @@ from opentelemetry.trace import Span, Tracer
|
|
|
12
12
|
|
|
13
13
|
from blaxel.core import settings
|
|
14
14
|
|
|
15
|
-
T = TypeVar(
|
|
15
|
+
T = TypeVar('T')
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class DefaultAttributesSpanProcessor(SpanProcessor):
|
|
@@ -21,7 +21,7 @@ class DefaultAttributesSpanProcessor(SpanProcessor):
|
|
|
21
21
|
def __init__(self, default_attributes: Dict[str, str]):
|
|
22
22
|
self.default_attributes = default_attributes
|
|
23
23
|
|
|
24
|
-
def on_start(self, span: SdkSpan, parent_context=None) -> None:
|
|
24
|
+
def on_start(self, span: SdkSpan, parent_context = None) -> None:
|
|
25
25
|
"""Add default attributes to the span when it starts."""
|
|
26
26
|
for key, value in self.default_attributes.items():
|
|
27
27
|
span.set_attribute(key, value)
|
|
@@ -52,12 +52,10 @@ class SpanManager:
|
|
|
52
52
|
"blaxel.environment": settings.env,
|
|
53
53
|
"workload.id": settings.name,
|
|
54
54
|
"workload.type": f"{settings.type}s",
|
|
55
|
-
"workspace": settings.workspace
|
|
55
|
+
"workspace": settings.workspace
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
def create_active_span(
|
|
59
|
-
self, name: str, attributes: Dict[str, Any], parent: Span | None = None
|
|
60
|
-
) -> ContextManager[Span]:
|
|
58
|
+
def create_active_span(self, name: str, attributes: Dict[str, Any], parent: Span | None = None) -> ContextManager[Span]:
|
|
61
59
|
"""
|
|
62
60
|
Creates an active span and executes the provided function within its context.
|
|
63
61
|
|
|
@@ -79,9 +77,7 @@ class SpanManager:
|
|
|
79
77
|
context = trace.set_span_in_context(parent)
|
|
80
78
|
return self.tracer.start_as_current_span(name, attributes=attributes, context=context)
|
|
81
79
|
|
|
82
|
-
def create_span(
|
|
83
|
-
self, name: str, attributes: Dict[str, Any], parent: Span | None = None
|
|
84
|
-
) -> Span:
|
|
80
|
+
def create_span(self, name: str, attributes: Dict[str, Any], parent: Span | None = None) -> Span:
|
|
85
81
|
"""
|
|
86
82
|
Creates a new span without making it active.
|
|
87
83
|
|
|
@@ -99,7 +95,7 @@ class SpanManager:
|
|
|
99
95
|
"blaxel.environment": settings.env,
|
|
100
96
|
"workload.id": settings.name,
|
|
101
97
|
"workload.type": f"{settings.type}s",
|
|
102
|
-
"workspace": settings.workspace
|
|
98
|
+
"workspace": settings.workspace
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
context = None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blaxel
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.31rc121
|
|
4
4
|
Summary: Blaxel - AI development platform SDK
|
|
5
5
|
Project-URL: Homepage, https://blaxel.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.blaxel.ai
|
|
@@ -8,7 +8,7 @@ Project-URL: Repository, https://github.com/blaxel-ai/sdk-python
|
|
|
8
8
|
Project-URL: Changelog, https://docs.blaxel.ai/changelog
|
|
9
9
|
Author-email: cploujoux <cploujoux@blaxel.ai>
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Requires-Python:
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
12
|
Requires-Dist: attrs>=21.3.0
|
|
13
13
|
Requires-Dist: httpx>=0.27.0
|
|
14
14
|
Requires-Dist: mcp>=1.9.4
|