opencensus-python icon indicating copy to clipboard operation
opencensus-python copied to clipboard

Opencensus not working with MLFlow

Open NastasiaSaby opened this issue 4 years ago • 7 comments

Describe your environment.

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

Steps to reproduce.


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

What is the expected behavior? MLFlow should be imported.

What is the actual behavior? It's impossible to import mlflow. Its runs forever.

NastasiaSaby avatar Apr 21 '21 12:04 NastasiaSaby

What is the error message you are getting? How do you know mlflow is not getting imported?

lzchen avatar Apr 21 '21 14:04 lzchen

The scripts never ends. I have no error message.

NastasiaSaby avatar Apr 21 '21 14:04 NastasiaSaby

@NastasiaSaby If you remove either logger.addHandler or import mlflow, the script works?

lzchen avatar Apr 21 '21 15:04 lzchen

@Izchen Thank you for your answers. Yes, it works if I remove either logger.addHandler or import mlflow.

NastasiaSaby avatar Apr 21 '21 15:04 NastasiaSaby

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

NastasiaSaby avatar Apr 22 '21 07:04 NastasiaSaby

@NastasiaSaby You have two import lines now?

lzchen avatar Apr 22 '21 15:04 lzchen

Yes. In reality, the two import lines in my project are in two different files. But you can reproduce the problem by putting all in the same file. @Izchen

NastasiaSaby avatar Apr 23 '21 06:04 NastasiaSaby