# Buggy code
def get(self, name):
    """List of predictors colums"""
    try:
        model = g.mindsdb_native.get_model_data(name)
    except Exception:
        abort(404, "Invalid predictor name")

    columns = []
    for array, is_target_array in [
        (model["data_analysis"]["target_columns_metadata"], True),
        (model["data_analysis"]["input_columns_metadata"], False),
    ]:
        for col_data in array:
            column = {
                "name": col_data["column_name"],
                "data_type": col_data["data_type"].lower(),
                "is_target_column": is_target_array,
            }
            if column["data_type"] == "categorical":
                column["distribution"] = col_data["data_distribution"][
                    "data_histogram"
                ]["x"]
            columns.append(column)

    return columns, 200


# Traceback (AttributeError)
2020-06-25 14:30:32,318 - INFO - Starting MindsDB Mysql proxy server on tcp://127.0.0.1:47335
2020-06-25 14:30:32,334 - INFO - Waiting for incoming connections...
127.0.0.1 - - [25/Jun/2020 14:31:14] "GET /util/ping HTTP/1.1" 200 -
Exception on /datasources/ [GET]
Traceback (most recent call last):
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask_restx/api.py", line 375, in wrapper
resp = resource(*args, **kwargs)
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask_restx/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/flask_restx/marshalling.py", line 248, in wrapper
resp = f(*args, **kwargs)
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/mindsdb/api/http/namespaces/datasource.py", line 40, in get
return g.default_store.get_datasources()
File "/home/zoran/MyProjects/mindsdb-examples/new/lib/python3.7/site-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: '_AppCtxGlobals' object has no attribute 'default_store'
127.0.0.1 - - [25/Jun/2020 14:31:18] "GET /datasources/ HTTP/1.1" 500 -
Exception on /datasources/ [GET]

# Fixed code
def get(self, name):
    """List of predictors colums"""
    try:
        model = ca.mindsdb_native.get_model_data(name)
    except Exception:
        abort(404, "Invalid predictor name")

    columns = []
    for array, is_target_array in [
        (model["data_analysis"]["target_columns_metadata"], True),
        (model["data_analysis"]["input_columns_metadata"], False),
    ]:
        for col_data in array:
            column = {
                "name": col_data["column_name"],
                "data_type": col_data["data_type"].lower(),
                "is_target_column": is_target_array,
            }
            if column["data_type"] == "categorical":
                column["distribution"] = col_data["data_distribution"][
                    "data_histogram"
                ]["x"]
            columns.append(column)

    return columns, 200