A `EvaluationModule` is the base class and common API for metrics, comparisons, and measurements. Args: config_name (`str`): This is used to define a hash specific to a module computation script and prevents the module's data to be overridden when the module load
| 147 | |
| 148 | |
| 149 | class EvaluationModule(EvaluationModuleInfoMixin): |
| 150 | """A `EvaluationModule` is the base class and common API for metrics, comparisons, and measurements. |
| 151 | |
| 152 | Args: |
| 153 | config_name (`str`): |
| 154 | This is used to define a hash specific to a module computation script and prevents the module's data |
| 155 | to be overridden when the module loading script is modified. |
| 156 | keep_in_memory (`bool`): |
| 157 | Keep all predictions and references in memory. Not possible in distributed settings. |
| 158 | cache_dir (`str`): |
| 159 | Path to a directory in which temporary prediction/references data will be stored. |
| 160 | The data directory should be located on a shared file-system in distributed setups. |
| 161 | num_process (`int`): |
| 162 | Specify the total number of nodes in a distributed settings. |
| 163 | This is useful to compute module in distributed setups (in particular non-additive modules like F1). |
| 164 | process_id (`int`): |
| 165 | Specify the id of the current process in a distributed setup (between 0 and num_process-1) |
| 166 | This is useful to compute module in distributed setups (in particular non-additive metrics like F1). |
| 167 | seed (`int`, optional): |
| 168 | If specified, this will temporarily set numpy's random seed when [`~evaluate.EvaluationModule.compute`] is run. |
| 169 | experiment_id (`str`): |
| 170 | A specific experiment id. This is used if several distributed evaluations share the same file system. |
| 171 | This is useful to compute module in distributed setups (in particular non-additive metrics like F1). |
| 172 | hash (`str`): |
| 173 | Used to identify the evaluation module according to the hashed file contents. |
| 174 | max_concurrent_cache_files (`int`): |
| 175 | Max number of concurrent module cache files (default `10000`). |
| 176 | timeout (`Union[int, float]`): |
| 177 | Timeout in second for distributed setting synchronization. |
| 178 | """ |
| 179 | |
| 180 | def __init__( |
| 181 | self, |
| 182 | config_name: Optional[str] = None, |
| 183 | keep_in_memory: bool = False, |
| 184 | cache_dir: Optional[str] = None, |
| 185 | num_process: int = 1, |
| 186 | process_id: int = 0, |
| 187 | seed: Optional[int] = None, |
| 188 | experiment_id: Optional[str] = None, |
| 189 | hash: str = None, |
| 190 | max_concurrent_cache_files: int = 10000, |
| 191 | timeout: Union[int, float] = 100, |
| 192 | **kwargs, |
| 193 | ): |
| 194 | # prepare info |
| 195 | self.config_name = config_name or "default" |
| 196 | info = self._info() |
| 197 | info.module_name = camelcase_to_snakecase(self.__class__.__name__) |
| 198 | info.config_name = self.config_name |
| 199 | info.experiment_id = experiment_id or "default_experiment" |
| 200 | EvaluationModuleInfoMixin.__init__(self, info) # For easy access on low level |
| 201 | |
| 202 | # Safety checks on num_process and process_id |
| 203 | if not isinstance(process_id, int) or process_id < 0: |
| 204 | raise ValueError("'process_id' should be a number greater than 0") |
| 205 | if not isinstance(num_process, int) or num_process <= process_id: |
| 206 | raise ValueError("'num_process' should be a number greater than process_id") |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…