BUG: dataiku.get_custom_variables() returns Python string instead of dict at lower levels

Options
info-rchitect
info-rchitect Registered Posts: 169 ✭✭✭✭✭✭

Hi,

I tried `get_custom_variables` function and found it does not return the proper Python classes at the lower levels of the `dict`.

REPRODUCE:

Create 'bug' variable:

{"bug": {"dict1": {"a": 1,"b": 2}}}import dataikuimport pandas as pd, numpy as npfrom dataiku import pandasutils as pduproject_handle = dataiku.api_client().get_project(dataiku.default_project_key())vars = project_handle.get_variables()['standard']# This does not return JSON objects after the top-level dictcustom_vars = dataiku.get_custom_variables()print(f"should be a dict, type actually is {type(custom_vars['bug'])}")print(f"should be a dict, and is a {type(vars['bug'])}")exit()


Here is the log output that shows `get_custom_variables` returns a str instead of a dict:


[08:50:29] [INFO] [dku.utils]  - should be a dict, type actually is <class 'str'>[08:50:29] [INFO] [dku.utils]  - should be a dict, and is a <class 'dict'>  

Operating system used: Windows 10

Tagged:

Best Answer

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
    Answer ✓
    Options

    Hi,

    As you have proved, the method 'get_custom_variables' will by default return the variable values as strings in the returned dictionary.

    If you want the values to be typed, call the function with the following argument:

    custom_vars = dataiku.get_custom_variables(typed=True)

    Capture.png

Answers

Setup Info
    Tags
      Help me…