syft package

Welcome to the syft package! This package is the primary package for PySyft. This package has two kinds of attributes: submodules and convenience functions. Submodules are configured in the standard way, but the convenience functions exist to allow for a convenient import syft as sy to then expose the most-used functionalities directly on syft. Note that this way of importing PySyft is the strict convention in this codebase. (Do no simply call import syft and then directly use syft.<method>.)

The syft module is split into two distinct groups of functionality which we casually refer to as syft “core” and syft “python”. “core” functionality is functionality which is designed to be universal across all Syft languages (javascript, kotlin, swift, etc.). Syft “python” includes all functionality which by its very nature cannot be truly polyglot. Syft “core” functionality includes the following modules:

  • syft.core.node - APIs for interacting with remote machines you do not directly

control. * syft.core.old_message - APIs for serializing messages sent between Client and Node classes. * syft.core.pointer - Client side API for referring to objects on a Node * syft.core.store - Server side API for referring to object storage on a node (things pointers point to)

Syft “python” functionality includes the following modules:

  • syft.ast - code generates external library common syntax tree using a whitelist of methods
  • syft.typecheck - automatically checks and enforces Python type hints and the exclusive

use of kwargs. * syft.lib - uses the ast library to dynamically create remote execution APIs for supported Python libs.

IMPORTANT: syft.core should be very careful when importing functionality from outside of syft core!!! Since we plan to drop syft core down to a language (such as C++ or Rust) this can create future complications with lower level languages calling higher level ones.

To begin your education in Syft, continue to the syft.core.node.vm.vm module…

syft.LONG_TYPECHECK_STACK_TRACES(setting=None)[source]

Subpackages

Submodules

syft.util module

syft.util.get_subclasses(obj_type: type) → List[type][source]

Recusively generate the list of all classes within the sub-tree of an object

As a paradigm in Syft, we often allow for something to be known about by another part of the codebase merely because it has subclassed a particular object. While this can be a big “magicish” it also can simplify future extensions and reduce the likelihood of small mistakes (if done right).

This is a utility function which allows us to look for sub-classes and the sub-classes of those sub-classes etc. returning a full list of descendants of a class in the inheritance hierarchy.

Parameters:obj_type – the type we want to look for sub-classes of
Returns:the list of subclasses of obj_type:
Return type:List[type]
syft.util.index_modules(a_dict: object, keys: List[str]) → object[source]

Recursively find a syft module from its path

This is the recursive inner function of index_syft_by_module_name. See that method for a full description.

Parameters:
  • a_dict (object) – a module we’re traversing
  • keys (List[str]) – the list of string attributes we’re using to traverse the module
Returns:

a reference to the final object

Return type:

object

syft.util.index_syft_by_module_name(fully_qualified_name: str) → object[source]

Look up a Syft class/module/function from full path and name

Sometimes we want to use the fully qualified name (such as one generated from the ‘get_fully_qualified_name’ method below) to fetch an actual reference. This is most commonly used in deserialization so that we can have generic protobuf objects which just have a string representation of the specific object it is meant to deserialize to.

Parameters:fully_qualified_name (str) – the name of a module, class, or function
Returns:a reference to the actual object at that string path
Return type:object
syft.util.get_fully_qualified_name(obj: object) → str[source]

Return the full path and name of a class

Sometimes we want to return the entire path and name encoded using periods. For example syft.core.common.message.SyftMessage is the current fully qualified path and name for the SyftMessage object.

Parameters:obj (object) – the object we we want to get the name of
Returns:the full path and name of the object
Return type:str
syft.util.aggressive_set_attr(obj: object, name: str, attr: object) → None[source]

Different objects prefer different types of monkeypatching - try them all