Skip to content

Commit 24dbdef

Browse files
whoseoysterstainless-app[bot]
authored andcommitted
feat: feat: allow publish without ssl verification
1 parent badc2bb commit 24dbdef

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/openlayer/lib/tracing/tracer.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
"""Module with the logic to create and manage traces and steps."""
22

3+
import time
34
import asyncio
4-
import contextvars
55
import inspect
66
import logging
7-
import time
8-
from contextlib import contextmanager
7+
import contextvars
8+
from typing import Any, Dict, List, Tuple, Optional, Awaitable, Generator
99
from functools import wraps
10-
from typing import Any, Awaitable, Dict, Generator, List, Optional, Tuple
10+
from contextlib import contextmanager
1111

12+
from . import enums, steps, traces
13+
from .. import utils
1214
from ..._client import Openlayer
15+
from ..._base_client import DefaultHttpxClient
1316
from ...types.inference_pipelines.data_stream_params import ConfigLlmData
14-
from .. import utils
15-
from . import enums, steps, traces
1617

1718
logger = logging.getLogger(__name__)
1819

19-
_publish = utils.get_env_variable("OPENLAYER_DISABLE_PUBLISH") != "true"
20+
TRUE_LIST = ["true", "on", "1"]
21+
22+
_publish = utils.get_env_variable("OPENLAYER_DISABLE_PUBLISH") not in TRUE_LIST
23+
_verify_ssl = utils.get_env_variable("OPENLAYER_VERIFY_SSL").lower() in TRUE_LIST
2024
_client = None
2125
if _publish:
22-
_client = Openlayer()
26+
if _verify_ssl:
27+
_client = Openlayer()
28+
else:
29+
_client = Openlayer(
30+
http_client=DefaultHttpxClient(
31+
verify=False,
32+
),
33+
)
2334

2435
_current_step = contextvars.ContextVar("current_step")
2536
_current_trace = contextvars.ContextVar("current_trace")
@@ -142,8 +153,8 @@ def trace(
142153
Examples
143154
--------
144155
145-
To trace a function, simply decorate it with the ``@trace()`` decorator. By doing so,
146-
the functions inputs, outputs, and metadata will be automatically logged to your
156+
To trace a function, simply decorate it with the ``@trace()`` decorator. By doing
157+
so, the functions inputs, outputs, and metadata will be automatically logged to your
147158
Openlayer project.
148159
149160
>>> import os
@@ -204,7 +215,8 @@ def wrapper(*func_args, **func_kwargs):
204215
log_context(inputs.get(context_kwarg))
205216
else:
206217
logger.warning(
207-
"Context kwarg `%s` not found in inputs of the current function.",
218+
"Context kwarg `%s` not found in inputs of the "
219+
"current function.",
208220
context_kwarg,
209221
)
210222

@@ -235,8 +247,8 @@ def trace_async(
235247
Examples
236248
--------
237249
238-
To trace a function, simply decorate it with the ``@trace()`` decorator. By doing so,
239-
the functions inputs, outputs, and metadata will be automatically logged to your
250+
To trace a function, simply decorate it with the ``@trace()`` decorator. By doing
251+
so, the functions inputs, outputs, and metadata will be automatically logged to your
240252
Openlayer project.
241253
242254
>>> import os
@@ -297,7 +309,8 @@ async def wrapper(*func_args, **func_kwargs):
297309
log_context(inputs.get(context_kwarg))
298310
else:
299311
logger.warning(
300-
"Context kwarg `%s` not found in inputs of the current function.",
312+
"Context kwarg `%s` not found in inputs of the "
313+
"current function.",
301314
context_kwarg,
302315
)
303316

0 commit comments

Comments
 (0)