Total Complexity | 10 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | """Basic optimizer.""" |
||
8 | 1 | class Optimizer(object): |
|
9 | """Optimizer is object which optimize process.""" |
||
10 | |||
11 | 1 | def __init__(self, process): |
|
12 | 1 | self.process = process |
|
13 | 1 | self.ordered_stages = nx.topological_sort(self.process) |
|
14 | 1 | self.swarm_size = 40 |
|
15 | |||
16 | 1 | def set_custom_optimizing_order(self, ordered_stages): |
|
17 | """Set custom order.""" |
||
18 | 1 | if set(self.ordered_stages) == set(ordered_stages) and len( |
|
19 | self.ordered_stages) == len(ordered_stages): |
||
20 | 1 | self.ordered_stages = ordered_stages |
|
21 | else: |
||
22 | 1 | raise ValueError("List of stages must contain all stages.") |
|
23 | |||
24 | 1 | def optimize_process(self): |
|
25 | """Optimize process. |
||
26 | Returns: |
||
27 | True if success, False otherwise.""" |
||
28 | 1 | for stage in self.ordered_stages: |
|
29 | 1 | if not self.process.predecessors(stage): |
|
30 | 1 | self.run_pso(stage) |
|
31 | 1 | elif len(self.process.predecessors(stage)) == 1: |
|
32 | 1 | predecessor = self.process.predecessors(stage)[0] |
|
33 | 1 | stage.input_vector = predecessor.get_output_of_stage() |
|
34 | 1 | self.run_pso(stage) |
|
35 | else: |
||
36 | 1 | raise AttributeError('Incorrect process structure.') |
|
37 | |||
38 | 1 | if stage.optimization_status != OptimizationStatus.success: |
|
39 | 1 | return False |
|
40 | 1 | return True |
|
41 | |||
42 | 1 | def run_pso(self, stage): |
|
43 | """Run pso with predefined parameters.""" |
||
44 | pso(stage, swarmsize=self.swarm_size) |
||
45 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.