GraphLab: Distributed Graph-Parallel API
2.1
|
The GraphLab command line options class helps parse basic command line options for the GraphLab framework as well as user applications. More...
#include <graphlab/options/command_line_options.hpp>
Public Member Functions | |
command_line_options (std::string desc_str, bool suppress_graphlab_options=false) | |
Construct a command options object with basic settings. | |
void | print_description () const |
bool | parse (int argc, const char *const *argv, bool allow_unregistered=false) |
This function should be called AFTER all the options have been seen (including positionals). The parse function reads the standard command line arguments and fills in the attached variables. If there is an error in the syntax or parsing fails the parse routine will print the error and return false. | |
bool | is_set (const std::string &option) |
The is set function is used to test if the user provided the option. The option string should match one of the attached options. | |
std::vector< std::string > | unrecognized () const |
template<typename T > | |
void | attach_option (const std::string &option, T &ret_var, const std::string &description) |
attach a user defined option to the command line options parser. | |
void | add_positional (const std::string &str) |
attach a user defined option to the command line options parser. | |
void | set_ncpus (size_t n) |
Set the number of cpus. | |
size_t | get_ncpus () const |
Get the number of cpus. | |
void | set_scheduler_type (const std::string &stype) |
const std::string & | get_scheduler_type () const |
Get the type of scheduler. | |
const options_map & | get_engine_args () const |
Get the engine arguments. | |
options_map & | get_engine_args () |
Get the engine arguments. | |
const options_map & | get_graph_args () const |
options_map & | get_graph_args () |
const options_map & | get_scheduler_args () const |
options_map & | get_scheduler_args () |
virtual void | print () const |
Public Attributes | |
size_t | ncpus |
The number of cpus. | |
std::string | scheduler_type |
The type of scheduler to use. | |
options_map | engine_args |
additional arguments to the engine | |
options_map | scheduler_args |
additional arguments to the scheduler | |
options_map | graph_args |
Options for the graph. |
The GraphLab command line options class helps parse basic command line options for the GraphLab framework as well as user applications.
Early in the development of GraphLab we realized that a lot of time was spent writing code to parse the many GraphLab options as well as each of the applications options. In many cases we were using the boost::program_options library which while very powerful can also be fairly complicated.
As a consequence, we developed a simple command line options object that parses the standard argv options capturing GraphLab specific options and also processing users options. GraphLab command line tools to enable user applications to benefit from sophisticated and still easy to use command line parsing.
The command_line_options data-structure is built on top of the boost::program_options library. We have tried to retain much of the functionality of the boost::program_options library while hiding some of the less "friendly" template meta-programming "features".
Here is an example of how the library is used:
Definition at line 167 of file command_line_options.hpp.
|
inline |
Construct a command options object with basic settings.
[in] | desc_str | The description of the program that is printed when –help is invoked (in addition to all the options and their descriptions). |
[in] | suppress_graphlab_options | If set to true the standard GraphLab options are not parsed and the help screen. only presents the users options. This is useful in cases where command line options are needed outside of GraphLab binary (e.g., simple utilities). |
Definition at line 194 of file command_line_options.hpp.
void graphlab::command_line_options::add_positional | ( | const std::string & | str | ) |
attach a user defined option to the command line options parser.
The attach option command is used to attach a user defined option to the command line options parser.
option | The name of the command line flag for that option. |
ret_cont | A pointer to an "arbitrary" type which can be any of the basic types (char, int, size_t, float, double, bool, string...) or an std::vector of basic types. It is important that the ret_cont point to a memory block that will exist when parse is invoked. |
default_value | The default value of the parameter if the user does not provide this parameter on the command line. |
description | Used to describe the option when –help is called or when print_description is invoked. This function adds the option as a positional argument. A positional argument does not require –option and instead is read based on its location. Each add_positional call adds to the next position. |
Definition at line 186 of file command_line_options.cpp.
|
inline |
attach a user defined option to the command line options parser.
The attach option command is used to attach a user defined option to the command line options parser.
[in] | option | The name of the command line flag for that option. |
[in,out] | ret_var | A reference to an "arbitrary" type which can be any of the basic types (char, int, size_t, float, double, bool, string...) or an std::vector of basic types. It is important that the ret_cont point to a memory block that will exist when parse is invoked. The default value is read from the ret_cont |
[in] | description | Used to describe the option when –help is called or when print_description is invoked. |
Definition at line 261 of file command_line_options.hpp.
bool graphlab::command_line_options::parse | ( | int | argc, |
const char *const * | argv, | ||
bool | allow_unregistered = false |
||
) |
This function should be called AFTER all the options have been seen (including positionals). The parse function reads the standard command line arguments and fills in the attached variables. If there is an error in the syntax or parsing fails the parse routine will print the error and return false.
If allow_unregistered is set to true, will permit unrecognized options
Definition at line 72 of file command_line_options.cpp.
|
inlinevirtualinherited |
Display the current engine options
Definition at line 151 of file graphlab_options.hpp.
|
inline |
Print the same message that is printed when the –help command line argument is provided.
Definition at line 208 of file command_line_options.hpp.
|
inline |
If allow_unregistered flag is set on parse this will contain the list of unrecognized options
Definition at line 236 of file command_line_options.hpp.