-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlogic.py
More file actions
37 lines (26 loc) · 922 Bytes
/
logic.py
File metadata and controls
37 lines (26 loc) · 922 Bytes
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
from recombee_api_client.inputs.input import Input
from recombee_api_client.utils.serialize_to_json import serialize_to_json
from typing import Union, List
from datetime import datetime
import uuid
DEFAULT = uuid.uuid4()
class Logic(Input):
"""
Initializes Logic input
Optional parameters:
:param name: Name of the logic that should be used
:param settings: Parameters passed to the logic
"""
def __init__(self, name: str = DEFAULT, settings: dict = DEFAULT):
self.name = name
self.settings = settings
def to_dict(self) -> dict:
"""
Serializes the input into a dict for sending to the Recombee API.
"""
res = dict()
if self.name is not DEFAULT:
res["name"] = serialize_to_json(self.name)
if self.settings is not DEFAULT:
res["settings"] = serialize_to_json(self.settings)
return res