Turi Create
4.0
|
#include <model_server/lib/unity_global.hpp>
Public Member Functions | |
unity_global (toolkit_function_registry *_toolkit_functions, toolkit_class_registry *_classes) | |
std::string | get_version () |
std::shared_ptr< unity_sgraph_base > | load_graph (std::string fname) |
std::vector< std::string > | list_toolkit_classes () |
variant_map_type | load_model (const std::string &url) |
void | save_model (std::shared_ptr< model_base > tkclass, const variant_map_type &sidedata, const std::string &url) |
void | save_model2 (const std::string &model_name, const variant_map_type &sidedata, const std::string &url) |
std::vector< std::string > | list_toolkit_functions () |
std::map< std::string, flexible_type > | describe_toolkit_function (std::string toolkitname) |
std::map< std::string, flexible_type > | describe_toolkit_class (std::string class_name) |
std::shared_ptr< model_base > | create_toolkit_class (std::string class_name) |
toolkit_function_response_type | run_toolkit (std::string toolkit_name, variant_map_type &arguments) |
std::string | get_graph_dag () |
flexible_type | eval_lambda (const std::string &pylambda_string, const flexible_type &arg) |
flexible_type | eval_dict_lambda (const std::string &pylambda_string, const std::vector< std::string > &keys, const std::vector< flexible_type > &args) |
std::vector< flexible_type > | parallel_eval_lambda (const std::string &pylambda_string, const std::vector< flexible_type > &arg) |
std::string | __read__ (const std::string &url) |
void | __write__ (const std::string &url, const std::string &content) |
bool | __mkdir__ (const std::string &url) |
bool | __chmod__ (const std::string &url, short mode) |
size_t | __get_heap_size__ () |
size_t | __get_allocated_size__ () |
void | set_log_level (size_t) |
std::map< std::string, flexible_type > | list_globals (bool runtime_modifiable) |
std::string | set_global (std::string key, flexible_type value) |
std::shared_ptr< unity_sarray_base > | create_sequential_sarray (ssize_t size, ssize_t start, bool reverse) |
std::string | load_toolkit (std::string soname, std::string module_subpath) |
std::vector< std::string > | list_toolkit_functions_in_dynamic_module (std::string soname) |
std::vector< std::string > | list_toolkit_classes_in_dynamic_module (std::string soname) |
std::string | get_current_cache_file_location () |
toolkit_function_registry * | get_toolkit_function_registry () |
toolkit_class_registry * | get_toolkit_class_registry () |
std::string | get_turicreate_object_type (const std::string &url) |
void | model_variant_deep_save (const variant_type &var, oarchive &oarc) |
void | model_variant_deep_load (variant_type &var, iarchive &iarc) |
The turi::unity_global and turi::unity_global_base classes implement a singleton object on the server side which is exposed to the client via the cppipc system. This singleton object provides other miscellaneous uncategorized services (global functions) to the python layer.
Definition at line 24 of file unity_global.hpp.
turi::unity_global::unity_global | ( | toolkit_function_registry * | _toolkit_functions, |
toolkit_class_registry * | _classes | ||
) |
Constructor
reg | Pointer to Toolkit registry. Since Unity Global manaages toolkit execution |
server | Pointer to the comm server object. Toolkit execution status will be emitted there. |
bool turi::unity_global::__chmod__ | ( | const std::string & | url, |
short | mode | ||
) |
Changes permissions of the given url.
size_t turi::unity_global::__get_allocated_size__ | ( | ) |
Returns the amount of memory used inside the heap. May not be available. Returns 0 if unavailable.
size_t turi::unity_global::__get_heap_size__ | ( | ) |
Returns the size of the process heap. May not be available. Returns 0 if unavailable.
bool turi::unity_global::__mkdir__ | ( | const std::string & | url | ) |
Creates a directory that will have the given url.
Throws exception if directory already exists.
std::string turi::unity_global::__read__ | ( | const std::string & | url | ) |
Reads the content of the given url.
Return a string containing the content of the given url.
Throws exception if IO error occurs.
void turi::unity_global::__write__ | ( | const std::string & | url, |
const std::string & | content | ||
) |
Writes the content of to the given url.
Throws exception if IO error occurs.
std::shared_ptr<unity_sarray_base> turi::unity_global::create_sequential_sarray | ( | ssize_t | size, |
ssize_t | start, | ||
bool | reverse | ||
) |
Create a sequentially increasing (or decreasing) SArray.
If 'reverse' is true, counts down instead of up.
std::shared_ptr<model_base> turi::unity_global::create_toolkit_class | ( | std::string | class_name | ) |
Creates a class instance.
std::map<std::string, flexible_type> turi::unity_global::describe_toolkit_class | ( | std::string | class_name | ) |
Returns a dictionary describing the class. It will return a dictionary with 2 fields:
std::map<std::string, flexible_type> turi::unity_global::describe_toolkit_function | ( | std::string | toolkitname | ) |
Returns a dictionary describing the toolkit. It will return a dictionary with 2 fields:
flexible_type turi::unity_global::eval_dict_lambda | ( | const std::string & | pylambda_string, |
const std::vector< std::string > & | keys, | ||
const std::vector< flexible_type > & | args | ||
) |
Evaluate a pickled python lambda with dictionary argument.
flexible_type turi::unity_global::eval_lambda | ( | const std::string & | pylambda_string, |
const flexible_type & | arg | ||
) |
Evaluate a pickled python lambda with the given argument.
std::string turi::unity_global::get_current_cache_file_location | ( | ) |
Retrieve the folder that is currently being used to hold temp files.
This is where all the SFrame files and such are located.
std::string turi::unity_global::get_graph_dag | ( | ) |
Internal utility function. Gets the structure of the lazy evaluation dag for the graph operations.
toolkit_class_registry* turi::unity_global::get_toolkit_class_registry | ( | ) |
Returns a pointer to the toolkit class registry
toolkit_function_registry* turi::unity_global::get_toolkit_function_registry | ( | ) |
Returns a pointer to the toolkit function registry
std::string turi::unity_global::get_turicreate_object_type | ( | const std::string & | url | ) |
Given a url, returns the type of the Turi object, return value could be: model, graph, sframe, sarray
std::string turi::unity_global::get_version | ( | ) |
Get the version string
std::map<std::string, flexible_type> turi::unity_global::list_globals | ( | bool | runtime_modifiable | ) |
Lists all the global configuration values. If runtime_modifiable == true, lists all global values which can be modified at runtime. If runtime == false, lists all global values which can only be modified by environment variables.
std::vector<std::string> turi::unity_global::list_toolkit_classes | ( | ) |
Lists the names of all regsitered classes.
std::vector<std::string> turi::unity_global::list_toolkit_classes_in_dynamic_module | ( | std::string | soname | ) |
Lists all the classes in a toolkit. Raises an exception if the toolkit was not previously loaded by load_toolkit.
std::vector<std::string> turi::unity_global::list_toolkit_functions | ( | ) |
Lists the names of all registered toolkit functions.
std::vector<std::string> turi::unity_global::list_toolkit_functions_in_dynamic_module | ( | std::string | soname | ) |
Lists all the functions in a toolkit. Raises an exception if the toolkit was not previously loaded by load_toolkit.
std::shared_ptr<unity_sgraph_base> turi::unity_global::load_graph | ( | std::string | fname | ) |
Constructs a graph from a binary file on disk, or HDFS
variant_map_type turi::unity_global::load_model | ( | const std::string & | url | ) |
Load toolkit class from file.
Returns variant_map varmap
Archive version 1:
Legacy:
Throws an exception if there is an error reading the url or serializing to a proper toolkit class object.
std::string turi::unity_global::load_toolkit | ( | std::string | soname, |
std::string | module_subpath | ||
) |
Attempts to load a toolkit from a shared library. Returns an empty string on success. An string describing the error on failure.
The so will be loaded with prefix [module_subpath].[filename].[...] For instance: if the so is called "example.so" containing a function square_root.
will load the toolkit function into "example.square_root". (it will also appear in tc.extensions.example.square_root)
will load the toolkit function "pika.example.square_root". (it will also appear in tc.extensions.pika.example.square_root)
module_subpath can also be ".."
In which case it will appear anywhere except in the top level of tc.extensions as tc.extensions.square_root.
void turi::unity_global::model_variant_deep_load | ( | variant_type & | var, |
iarchive & | iarc | ||
) |
A alternate implementation of variant_deep_load which knows how to save models. Models are special because they rely on the unity_global registry. Fully compatible with variant_deep_load otherwise.
void turi::unity_global::model_variant_deep_save | ( | const variant_type & | var, |
oarchive & | oarc | ||
) |
A alternate implementation of var which knows how to save models. Models are special because they rely on the unity_global registry. Fully compatible with variant_deep_save otherwise.
std::vector<flexible_type> turi::unity_global::parallel_eval_lambda | ( | const std::string & | pylambda_string, |
const std::vector< flexible_type > & | arg | ||
) |
Evaluate a pickled python lambda on a list of argument in parallel.
toolkit_function_response_type turi::unity_global::run_toolkit | ( | std::string | toolkit_name, |
variant_map_type & | arguments | ||
) |
Runs a toolkit of the specified name, and with the specified arguments. Returns a toolkit_function_response_type which contains the result of the toolkit execution (success/failure) as well as any additional returned state (graphs/classes/etc). Will throw an exception if the toolkit name was not found.
void turi::unity_global::save_model | ( | std::shared_ptr< model_base > | tkclass, |
const variant_map_type & | sidedata, | ||
const std::string & | url | ||
) |
Save a toolkit class to file.
tkclass | The pointer to the actual toolkit class object. |
sidedata | Any additional side information |
url | The destination url to store the class. |
void turi::unity_global::save_model2 | ( | const std::string & | model_name, |
const variant_map_type & | sidedata, | ||
const std::string & | url | ||
) |
Saves a model using an alternative model saving method where a model class is not available.
model_name | A unique string name of the model |
sidedata | Any additional side information |
url | The destination url to store the class. |
std::string turi::unity_global::set_global | ( | std::string | key, |
flexible_type | value | ||
) |
Sets a modifiable global configuration value. Returns an empty string on success and an error string on failure.
void turi::unity_global::set_log_level | ( | size_t | ) |
Sets the logging level