syft.lib.misc package

syft.lib.misc.solve_ast_type_functions(path, lib_ast)[source]
syft.lib.misc.get_allowed_functions(lib_ast, union_types)[source]

This function generates a set of functions that can go into a union type. A function has to meet the following requirements to be present on a union type:

1. If it’s present on all Class attributes associated with the union types on the ast, add it. 2. If it’s not present on all Class attributes associated with the union types, check if they exist on the original type functions list. If they do exist, drop it, if not, add it.

Parameters
  • lib_ast (Globals) – the AST on which we want to generate the union pointer.

  • union_types (List[str]) – the qualnames of the types on which we want a union.

Returns

The keys of the dict are function names (str) and the values are Bool (if they are allowed or not).

Return type

allowed_functions (dict)

syft.lib.misc.create_union_ast(lib_ast, client=None)[source]

Submodules

syft.lib.misc.union module

class syft.lib.misc.union.IndexableTrait[source]

Bases: type

IndexableTrait is used as a metaclass for our UnionGenerator to be able to set __getitem__ on the class to enable the UnionGenerator[…] syntax.

class syft.lib.misc.union.UnionGenerator(name, bases, dct)[source]

Bases: type

UnionGenerator is a metaclass used to generate on the spot union types from their qualnames.

Eg. UnionGenerator[“syft.lib.python.Int”, “syft.lib.python.Float”] will generate in the current module the FloatIntUnion type that will have no functions added to the type itself until the AST is finished to be generated. If new types of unions have to be generated afterwards: 1. you might be using the ast in a wrong way. 2. if you know what you are doing, you have to regenerate the ast.

SUFFIX_UNION = 'Union'
static from_qualnames(union_types)[source]
class syft.lib.misc.union.BoolFloatIntUnion

Bases: object

class syft.lib.misc.union.BoolFloatIntmaxUnion

Bases: object

class syft.lib.misc.union.BoolFloatIntmedianUnion

Bases: object

class syft.lib.misc.union.BoolFloatIntminUnion

Bases: object

class syft.lib.misc.union.FloatIntStringTensorParameterUnion

Bases: object

class syft.lib.misc.union.IntListUnion

Bases: object

class syft.lib.misc.union.IntSizeUnion

Bases: object

class syft.lib.misc.union.Int_SyNoneUnion

Bases: object