blob: 4267fa2455b0b1d57cf4116dd8d906d5e55d8804 (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
|
from __future__ import unicode_literals
from abc import ABCMeta, abstractmethod, abstractproperty
from builtins import object
from future.utils import with_metaclass
class Config(with_metaclass(ABCMeta, object)):
@abstractmethod
def to_dict(self):
pass
@classmethod
def from_dict(cls, obj_dict):
raise NotImplementedError
class ProcessingUnitConfig(with_metaclass(ABCMeta, Config)):
"""Represents the configuration object needed to initialize a
:class:`.ProcessingUnit`"""
@abstractproperty
def unit_name(self):
raise NotImplementedError
def set_unit_name(self, value):
pass
def get_required_resources(self):
return None
class DefaultProcessingUnitConfig(dict, ProcessingUnitConfig):
"""Default config implemented as a simple dict"""
@property
def unit_name(self):
return self["unit_name"]
def set_unit_name(self, value):
self["unit_name"] = value
def to_dict(self):
return self
@classmethod
def from_dict(cls, obj_dict):
return cls(obj_dict)
|