AttributeError: 'function' object has no attribute 'info'

Solved!
super_bulldog
Level 2
AttributeError: 'function' object has no attribute 'info'

Hi Dataiku community, 

I encountered the AttributeError as shown in the title when I ran a Python recipe that was created from a notebook. The notebook runs correctly (without any error), but when it is converted into a Python recipe. The AttributeError was thrown immediately after the recipe finished executing the last line of the code right before the recipe output block. 

The AttributeError was from the python-exec-wrapper.py file and I could not access its content to debug the error. 

The Traceback is shown below.

Traceback (most recent call last):
File "/data/dataiku/data_dir/jobs/MLOPS/Build_from_recipe_from_notebook_1_create_input_dataset_2024-03-23T13-49-56.329/recipe_from_notebook_4_build_model_NP/python-recipe/pyoutSlgc2L5Bc1ba/python-exec-wrapper.py", line 266, in <module>
logging.info("Check if spark is available")
AttributeError: 'function' object has no attribute 'info'. 

Please advise! 

Thanks!


Operating system used: Windows 10 64-bit

0 Kudos
1 Solution
ZachM
Dataiker

Hi @super_bulldog,

Based on the stack trace, it looks like you have a function called "logging" in your recipe, which is conflicting with the "logging" module.

For example, I was able to reproduce the error with the following recipe:

import dataiku
import pandas as pd

# This function is causing the error
def logging():
    pass

df = pd.DataFrame(
    [{"str": "foo", "int": 1}, {"str": "bar", "int": 2}]
)

dataset = dataiku.Dataset("MY_DATASET")
dataset.write_with_schema(df)

 

You can avoid the issue by renaming the function.

View solution in original post

2 Replies
ZachM
Dataiker

Hi @super_bulldog,

Based on the stack trace, it looks like you have a function called "logging" in your recipe, which is conflicting with the "logging" module.

For example, I was able to reproduce the error with the following recipe:

import dataiku
import pandas as pd

# This function is causing the error
def logging():
    pass

df = pd.DataFrame(
    [{"str": "foo", "int": 1}, {"str": "bar", "int": 2}]
)

dataset = dataiku.Dataset("MY_DATASET")
dataset.write_with_schema(df)

 

You can avoid the issue by renaming the function.

super_bulldog
Level 2
Author

Hi @ZachM ,

Thank you for your quick response and accurate resolution! It pinpointed the root cause and it worked after I renamed my function.

Sorry for my carelessness! 

Cheers!