netunicorn.base.nodes.UncountableNodePool¶
- class UncountableNodePool(node_template, soft_limit=None)[source]¶
Bases:
NodesRepresents a pool of nodes that is not countable (i.e., contains possibly infinite amount of nodes, e.g. cloud provider).In the current implementation cannot have Nodes as elements.- Parameters:
node_template (
List[Node]) – list of nodes that will be used as a template for generating new nodessoft_limit (
Optional[float], default:None)
Attributes
Soft limit for nodes in the pool to prevent infinite loops or excessive node generation.
Methods
Deserializes a JSON representation of the object and returns an instance of the object.
Returns a pool of nodes that match the given filter function.
Class-specific implementation of deserialization from JSON.
Sets a property for all nodes in the pool.
Returns a pool of nodes consisting of the nodes after the first 'count' nodes.
Returns a sequence of nodes consisting of the first count nodes.
- soft_limit[source]¶
Soft limit for nodes in the pool to prevent infinite loops or excessive node generation.
- static dispatch_and_deserialize(data)[source]¶
Deserializes a JSON representation of the object and returns an instance of the object.
- Parameters:
data (
NodesRepresentation) – JSON representation of the object- Returns:
Nodes– instance of the object
- filter(function)[source]¶
Returns a pool of nodes that match the given filter function.
- Parameters:
function (
Callable[[Node],bool]) – filter function returning True if the node should be included in the result- Returns:
UncountableNodePool– pool of nodes
- take(count)[source]¶
Returns a sequence of nodes consisting of the first count nodes.
- Parameters:
count (
int) – number of nodes to take- Returns:
Sequence[Node] – sequence of nodes
- skip(count)[source]¶
Returns a pool of nodes consisting of the nodes after the first ‘count’ nodes.
- Parameters:
count (
int) – number of nodes to skip- Returns:
UncountableNodePool– pool of nodes
- classmethod from_json(data, metadata=None)[source]¶
Class-specific implementation of deserialization from JSON.
- Parameters:
data (
List[Union[NodeRepresentation,NodesRepresentation]]) – JSON representation of the objectmetadata (
Optional[Any], default:None) – optional additional information for the pool instantiation
- Returns:
UncountableNodePool– instance of the object
- set_property(name, value)[source]¶
Sets a property for all nodes in the pool.
- Parameters:
name (
str) – name of the propertyvalue (
Union[str,float,int,Set[str],None]) – property value
- Returns:
UncountableNodePool– self