syft.ast.attribute¶
This module contains Attribute, an interface of a generic node in the AST.
Classes
|
Attribute is the interface of a generic node in the AST that covers basic functionality. |
- class syft.ast.attribute.Attribute(client, path_and_name=None, object_ref=None, return_type_name=None, parent=None)[source]¶
Bases:
object
Attribute is the interface of a generic node in the AST that covers basic functionality.
- __init__(client, path_and_name=None, object_ref=None, return_type_name=None, parent=None)[source]¶
Base constructor for all AST nodes.
- Parameters
client – The client for which all computation is being executed.
path_and_name – The path for the current node, e.g. syft.lib.python.List.
object_ref – The actual python object for which the computation is being made.
return_type_name – The given action’s return type name, with its full path, in string format.
parent – The parent node in the AST.
- property classes¶
Extract all classes from the current node attributes.
- Returns
The list of classes in the current AST node attributes.
- property properties¶
Extract all properties from the current node attributes.
- Returns
The list of properties in the current AST node attributes.
- query(path, obj_type=None)[source]¶
The query method is a tree traversal function based on the path to retrieve the node.
It has a similar functionality to __call__, main difference being that query retrieves node without performing execution on node.
- Parameters
path – The node path in AST to be queried, e.g. syft.lib.python.List or [“syft”, “lib”, “python”, “List”].
obj_type – The type of the object that we want to call, whose path is resolved from the lookup_cache.
- Returns
The attribute in the AST at the given initial path.
- property name¶
Retrieve the name of the current AST node from its path_and_name.
- Returns
The name of the current attribute.
- add_path(path, index, return_type_name=None, framework_reference=None, is_static=False)[source]¶
The add_path method adds new nodes in AST based on type of current node and type of object to be added.
- Parameters
path – The node path added in AST, e.g. syft.lib.python.List or [“syft”, “lib”, “python”, “List].
index – The associated position in the path for the current node.
framework_reference – The Python framework in which we can resolve same path to obtain Python object.
return_type_name – The return type name of the given action as a string with its full path.
is_static – If the queried object is static, it has to be found on AST itself, not on an existing pointer.