22 #include <graphlab/options/command_line_options.hpp>
23 #include <graphlab/scheduler/scheduler_list.hpp>
29 std::string lexical_cast< std::string>(
const std::vector<int>& vec) {
34 std::string lexical_cast<std::string>(
const std::vector<uint32_t>& vec) {
39 std::string lexical_cast<std::string>(
const std::vector<uint64_t>& vec) {
44 std::string lexical_cast< std::string >(
const std::vector<double>& vec) {
49 std::string lexical_cast< std::string>(
const std::vector<float>& vec) {
54 std::string lexical_cast< std::string>(
const std::vector<std::string>& vec) {
62 static const char* engine_help_string =
63 #include <graphlab/options/engine_help.txt>
66 static const char* graph_help_string =
67 #include <graphlab/options/graph_help.txt>
73 bool allow_unregistered) {
74 namespace boost_po = boost::program_options;
77 std::string engine_opts_string;
79 std::string scheduler_opts_string =
"";
80 std::string graph_opts_string =
"";
82 if(!suppress_graphlab_options) {
86 boost_po::value<size_t>(&(
ncpus))->
88 "Number of cpus to use per machine. Defaults to (#cores - 2)")
90 boost_po::value<std::string>(&(schedulertype))->
91 default_value(schedulertype),
92 (std::string(
"Supported schedulers are: "
94 ". Too see options for each scheduler, run the program with the option"
95 " ---schedhelp=[scheduler_name]").c_str()))
97 boost_po::value<std::string>(&(engine_opts_string))->
98 default_value(engine_opts_string),
99 "string of engine options i.e., \"timeout=100\"")
101 boost_po::value<std::string>(&(graph_opts_string))->
102 default_value(graph_opts_string),
103 "String of graph options i.e., \"ingress=random\"")
105 boost_po::value<std::string>(&(scheduler_opts_string))->
106 default_value(scheduler_opts_string),
107 "String of scheduler options i.e., \"strict=true\"")
109 boost_po::value<std::string>()->implicit_value(
""),
110 "Display help for engine options.")
112 boost_po::value<std::string>()->implicit_value(
""),
113 "Display help for the distributed graph.")
115 boost_po::value<std::string>()->implicit_value(
""),
116 "Display help for schedulers.");
120 std::vector<std::string> arguments;
121 std::copy(argv + 1, argv + argc + !argc,
122 std::inserter(arguments, arguments.end()));
124 boost_po::command_line_parser parser(arguments);
125 parser.options(desc);
126 if (allow_unregistered) parser.allow_unregistered();
127 if (num_positional) parser.positional(pos_opts);
128 boost_po::parsed_options parsed = parser.run();
129 if (allow_unregistered) {
130 unrecognized_options =
131 boost_po::collect_unrecognized(parsed.options,
132 boost_po::include_positional);
134 unrecognized_options.clear();
136 boost_po::store(parsed, vm);
137 boost_po::notify(vm);
138 }
catch( boost_po::error error) {
139 std::cout <<
"Invalid syntax:\n"
140 <<
"\t" << error.what()
141 <<
"\n\n" << std::endl
147 if(vm.count(
"help")) {
151 if (vm.count(
"scheduler_help")) {
152 std::string schedname = vm[
"scheduler_help"].as<std::string>();
153 if (schedname !=
"") {
157 for(
size_t i = 0;i < schednames.size(); ++i) {
163 if (vm.count(
"engine_help")) {
164 std::cout << engine_help_string;
167 if (vm.count(
"graph_help")) {
168 std::cout << graph_help_string;
173 set_scheduler_type(schedulertype);
175 get_scheduler_args().
parse_string(scheduler_opts_string);
183 return vm.count(option);
188 pos_opts.add(str.c_str(), 1);