| 31 | }; |
| 32 | |
| 33 | int set_key(int argc, const char* argv[]) { |
| 34 | TCommonMetaInfoParams params; |
| 35 | TString key; |
| 36 | TString value; |
| 37 | TString outputModelPath; |
| 38 | EModelType outputModelFormat = EModelType::CatboostBinary; |
| 39 | auto parser = NLastGetopt::TOpts(); |
| 40 | parser.AddHelpOption(); |
| 41 | params.BindParser(parser); |
| 42 | parser.AddLongOption("key", "key name") |
| 43 | .RequiredArgument("NAME") |
| 44 | .StoreResult(&key); |
| 45 | parser.AddLongOption("value", "value") |
| 46 | .RequiredArgument("VALUE") |
| 47 | .StoreResult(&value); |
| 48 | parser.AddLongOption('o', "output-model-path") |
| 49 | .OptionalArgument("PATH") |
| 50 | .Handler1T<TString>([&outputModelPath, &outputModelFormat](const TString& path) { |
| 51 | outputModelPath = path; |
| 52 | outputModelFormat = NCatboostOptions::DefineModelFormat(path); |
| 53 | }); |
| 54 | parser.AddLongOption("output-model-format") |
| 55 | .OptionalArgument("output model format") |
| 56 | .Handler1T<TString>([&outputModelFormat](const TString& format) { |
| 57 | outputModelFormat = FromString<EModelType>(format); |
| 58 | }); |
| 59 | parser.SetFreeArgsMax(0); |
| 60 | NLastGetopt::TOptsParseResult parserResult{&parser, argc, argv}; |
| 61 | params.LoadModel(); |
| 62 | params.Model.ModelInfo[key] = value; |
| 63 | if (outputModelPath.empty()) { |
| 64 | CB_ENSURE(params.ModelPath.size() == 1, "Metadata manipulation requires exactly one model"); |
| 65 | NCB::ExportModel(params.Model, params.ModelPath[0], outputModelFormat); |
| 66 | } else { |
| 67 | NCB::ExportModel(params.Model, outputModelPath, outputModelFormat); |
| 68 | } |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | int get_keys(int argc, const char* argv[]) { |
| 73 | TCommonMetaInfoParams params; |
nothing calls this directly
no test coverage detected