-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathcache_population.py
38 lines (28 loc) · 1.09 KB
/
cache_population.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from typing import Any
from ..base_logic_unit import BaseLogicUnit
from ..pipeline_context import PipelineContext
class CachePopulation(BaseLogicUnit):
"""
Cache Population Stage
"""
pass
def execute(self, input: Any, **kwargs) -> Any:
"""
This method will return output according to
Implementation.
:param input: Your input data.
:param kwargs: A dictionary of keyword arguments.
- 'logger' (any): The logger for logging.
- 'config' (Config): Global configurations for the test
- 'context' (any): The execution context.
:return: The result of the execution.
"""
pipeline_context: PipelineContext = kwargs.get("context")
code = input
if pipeline_context.config.enable_cache and pipeline_context.cache:
pipeline_context.cache.set(
pipeline_context.cache.get_cache_key(pipeline_context), code
)
if pipeline_context.config.callback is not None:
pipeline_context.config.callback.on_code(code)
return code