Skip to content

Cannot load pickle file when parameters are passed through Provide #420

@Balthus1989

Description

@Balthus1989

Hello,
I have a class that is in charge to load some pickle files for a "machine learning" purpose.

Specifically, I call my class, called Regressor, in this way, through the usage of a .ini file reporting all the desired settings:

from dependency_injector import containers, providers
from dependency_injector.wiring import inject, Provide
from src.service.costestimator.configuration.configuration import Container

class Regressor():
    def __init__(self,
                 regressors_list = Provide[Container.config.regressors_scalers.regressors_list.as_(str)],
                 regressors_path = Provide[Container.config.regressors_scalers.regressors_path.as_(str)],
                 scalers_path = Provide[Container.config.regressors_scalers.scalers_path.as_(str)],
                 file_type_regressors = Provide[Container.config.regressors_scalers.file_type_regressors.as_(str)],
                 file_type_scalers = Provide[Container.config.regressors_scalers.file_type_scalers.as_(str)]):

When it comes to the "core" part of the code, it fails to load the pickle file:

    def load_model(self):
        if self.regressors_out is None:
            resulting_reg = {}
            resulting_scal = {}
            
            for regressor in self.regressors_list:
                with open(self.regressors_path.joinpath(self.regressors_path, f'{regressor}.{self.file_type_regressors}'), 'rb') as reg:
                    resulting_reg[regressor] = pickle.load(reg)

The error I get is the following:
ImportError: cannot import name '_ccallback_c' from 'scipy._lib'

The funny part is that: if I instantiate my Regressor class using the "Factory approach", it perfectly works.

Any idea? Thank you in advance for any response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions