FREVA-CLINT / freva

The Free Evaluation System Framework (FreVa)
Other
10 stars 3 forks source link

overriding the configuration incompatible with batchmode=True #192

Open eelucio opened 3 months ago

eelucio commented 3 months ago

If I do

import freva
freva.config("/patht/to/freva-instance.conf")

freva.run_plugin(**kwards, batchmode=True)

I get:

[18:57:55] ERROR    freva - ERROR - batchmode and overriding the config is not implemented - decrease  utils.py:101
                    log level via `freva.logger.setLevel` for more information    

However if I do:

import os
os.environ["EVALUATION_SYSTEM_CONFIG_FILE"] = FREVA_INSTANCES["xces"]["EVALUATION_SYSTEM_CONFIG_FILE"]
os.environ["EVALUATION_SYSTEM_CONFIG_DIR"] = FREVA_INSTANCES["xces"]["EVALUATION_SYSTEM_CONFIG_DIR"]
import freva

freva.run_plugin(**kwards, batchmode=True)

then it works fine.

This is related to:

        if batchmode:
            if freva.config.db_reloaded[0]:
                raise ValueError(
                    "batchmode and overriding the config is not implemented"
                )

that for what I understand is set as True here?:

    def __init__(self, config_file: Union[str, Path]) -> None:
        self._config_file = Path(config_file).expanduser().absolute()
        os.environ["EVALUATION_SYSTEM_CONFIG_FILE"] = str(self._config_file)
        cfg.reloadConfiguration(self._config_file)
        pm.reload_plugins()
        try:
            if django_settings.DATABASES:
                self.db_reloaded[0] = True
        except (ImproperlyConfigured, AttributeError):
            pass

I unfortunatelly do not know how to solve this issue