Turi Create  4.0
turi::lambda::pylambda_function Class Reference

#include <core/system/lambda/pylambda_function.hpp>

Public Member Functions

 pylambda_function (const std::string &lambda_str, bool delete_pickle_files_on_destruction=true)
 

Detailed Description

Represents a python lambda function object which is evaluated in parallel.

Usage

// Constructed from a pickled lambda string.
std::string lambda_string="some pickled str"
pylambda_function f(lambda_string);
// (optional) Set options such as random_seed or skip_undefined.
f.set_skip_undefined(true);
f.set_random_seed(0);
// evaluate on a minibatch of values.
std::vector<flexible_type> out;
f.evaluate({1,2,3}, out);

The pylambda_function can also contain a gl_pickle directory. The gl_pickle must contain one function. The function will then be unpickled from the directory and used.

// Constructed from a pickled lambda string.
std::string gl_pickle_directory = "./pickled_function"
pylambda_function f(gl_pickle_directory);

The evaluation is implemented using pylambda master and workers for parallelism:

  • each call to evaluate() will grab one avaiable worker.
  • if no worker is avaiable, block.
  • when evaluate returns, the corresponding worker is released.

Definition at line 59 of file pylambda_function.hpp.

Constructor & Destructor Documentation

◆ pylambda_function()

turi::lambda::pylambda_function::pylambda_function ( const std::string &  lambda_str,
bool  delete_pickle_files_on_destruction = true 
)

Constructs a lambda function from a either a series of pickled bytes or a gl_pickled directory which contains a function.

Parameters
delete_pickle_files_on_destructionOnly meaningful if lambda_str contains a gl_pickled directory. If true (default), it the directory will be deleted when this pylambda_function instance is destroyed.

The documentation for this class was generated from the following file: