Search code examples
azuremlflowopencensus

Is there a workaround to make opencensus work with MLFlow?


I'm not able to import mlflow after having launched a log with opencensus Azure. The MLFlow import runs forever.

My environment is the following:

  • Python 3.7
  • opencensus-ext-azure 1.0.7
  • opencensus-ext-logging 0.1.0
  • mlflow 1.15.0

Here is the code to repoduce the bug:

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-key>'))
logger.warning('Hello, World!')

import mlflow

Solution

  • I found a workaround, not the cleanest one though.

    I import mlflow at the beginning even if it's not useful this way:

    import mlflow
    import logging
    
    from opencensus.ext.azure.log_exporter import AzureLogHandler
    
    logger = logging.getLogger(__name__)
    logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-key>'))
    logger.warning('Hello, World!')
    
    import mlflow