fix tests, disable opentel metrics provider

This commit is contained in:
doctorpangloss 2025-07-16 14:21:50 -07:00
parent e67684e669
commit d4d62500ac
3 changed files with 25 additions and 6 deletions

View File

@ -29,13 +29,15 @@ import sys
import warnings
from opentelemetry import trace
from opentelemetry.semconv import attributes
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.aio_pika import AioPikaInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.metrics import set_meter_provider
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExporter
from opentelemetry.semconv.resource import ResourceAttributes as ResAttrs
from .. import options
from ..app import logger
@ -114,8 +116,8 @@ def _fix_pytorch_240():
def _create_tracer():
resource = Resource.create({
ResAttrs.SERVICE_NAME: args.otel_service_name,
ResAttrs.SERVICE_VERSION: args.otel_service_version,
attributes.SERVICE_NAME: args.otel_service_name,
attributes.SERVICE_VERSION: args.otel_service_version,
})
# omit progress spans from aio pika
@ -152,5 +154,11 @@ def _configure_logging():
_configure_logging()
_fix_pytorch_240()
# explicitly disable OpenTelemetry metrics by providing a no-op MeterProvider.
# this prevents the SDK from auto-configuring a default OTLP exporter that
# would try to connect to localhost when no metrics configuration is present.
set_meter_provider(MeterProvider())
tracer = _create_tracer()
__all__ = ["args", "tracer"]

View File

@ -11,14 +11,17 @@ from typing import Tuple, List
import pytest
import requests
os.environ['OTEL_METRICS_EXPORTER'] = 'none'
os.environ["OPENCV_IO_ENABLE_OPENEXR"] = "1"
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
# fixes issues with running the testcontainers rabbitmqcontainer on Windows
os.environ["TC_HOST"] = "localhost"
from comfy.cli_args_types import Configuration
logging.getLogger("pika").setLevel(logging.CRITICAL + 1)
logging.getLogger("aio_pika").setLevel(logging.CRITICAL + 1)
# fixes issues with running the testcontainers rabbitmqcontainer on Windows
os.environ["TC_HOST"] = "localhost"
def run_server(server_arguments: Configuration):
from comfy.cmd.main import main

View File

@ -3,12 +3,19 @@ import torch
from comfy_extras.nodes.nodes_svg import ImageToSVG, SVGToImage
SKIP = False
try:
import skia
except (ImportError, ModuleNotFoundError):
SKIP = True
@pytest.fixture
def sample_image():
return torch.rand((1, 64, 64, 3))
@pytest.mark.skipif(SKIP, reason="skia import error")
def test_image_to_svg(sample_image):
image_to_svg_node = ImageToSVG()
@ -21,6 +28,7 @@ def test_image_to_svg(sample_image):
assert svg_result[0].startswith('<?xml')
@pytest.mark.skipif(SKIP, reason="skia import error")
def test_svg_to_image():
svg_to_image_node = SVGToImage()