Skip to content

Commit e1a5f33

Browse files
fix: remove trailing whitespace to resolve editorconfig CI failure
- Remove trailing whitespace from common/arg.cpp and test files - Addresses editorconfig checker failure in CI - No functional changes, only formatting fixes Co-Authored-By: Jake Cosme <[email protected]>
1 parent 2e91cef commit e1a5f33

File tree

3 files changed

+67
-67
lines changed

3 files changed

+67
-67
lines changed

common/arg.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void parse_yaml_sampling(const YAML::Node& node, common_params_sampling&
7575
if (node["timing_per_token"]) sampling.timing_per_token = node["timing_per_token"].as<bool>();
7676
if (node["grammar"]) sampling.grammar = node["grammar"].as<std::string>();
7777
if (node["grammar_lazy"]) sampling.grammar_lazy = node["grammar_lazy"].as<bool>();
78-
78+
7979
if (node["dry_sequence_breakers"] && node["dry_sequence_breakers"].IsSequence()) {
8080
sampling.dry_sequence_breakers.clear();
8181
for (const auto& breaker : node["dry_sequence_breakers"]) {
@@ -145,7 +145,7 @@ static void parse_yaml_diffusion(const YAML::Node& node, common_params_diffusion
145145
static bool load_yaml_config(const std::string& config_path, common_params& params) {
146146
try {
147147
YAML::Node config = YAML::LoadFile(config_path);
148-
148+
149149
// Parse main parameters
150150
if (config["n_predict"]) params.n_predict = config["n_predict"].as<int32_t>();
151151
if (config["n_ctx"]) params.n_ctx = config["n_ctx"].as<int32_t>();
@@ -167,7 +167,7 @@ static bool load_yaml_config(const std::string& config_path, common_params& para
167167
if (config["yarn_orig_ctx"]) params.yarn_orig_ctx = config["yarn_orig_ctx"].as<int32_t>();
168168
if (config["n_gpu_layers"]) params.n_gpu_layers = config["n_gpu_layers"].as<int32_t>();
169169
if (config["main_gpu"]) params.main_gpu = config["main_gpu"].as<int32_t>();
170-
170+
171171
// Parse string parameters
172172
if (config["model_alias"]) params.model_alias = config["model_alias"].as<std::string>();
173173
if (config["hf_token"]) params.hf_token = config["hf_token"].as<std::string>();
@@ -180,53 +180,53 @@ static bool load_yaml_config(const std::string& config_path, common_params& para
180180
if (config["lookup_cache_static"]) params.lookup_cache_static = config["lookup_cache_static"].as<std::string>();
181181
if (config["lookup_cache_dynamic"]) params.lookup_cache_dynamic = config["lookup_cache_dynamic"].as<std::string>();
182182
if (config["logits_file"]) params.logits_file = config["logits_file"].as<std::string>();
183-
183+
184184
// Parse boolean parameters
185185
if (config["lora_init_without_apply"]) params.lora_init_without_apply = config["lora_init_without_apply"].as<bool>();
186186
if (config["offline"]) params.offline = config["offline"].as<bool>();
187-
187+
188188
// Parse integer parameters
189189
if (config["verbosity"]) params.verbosity = config["verbosity"].as<int32_t>();
190190
if (config["control_vector_layer_start"]) params.control_vector_layer_start = config["control_vector_layer_start"].as<int32_t>();
191191
if (config["control_vector_layer_end"]) params.control_vector_layer_end = config["control_vector_layer_end"].as<int32_t>();
192192
if (config["ppl_stride"]) params.ppl_stride = config["ppl_stride"].as<int32_t>();
193193
if (config["ppl_output_type"]) params.ppl_output_type = config["ppl_output_type"].as<int32_t>();
194-
194+
195195
// Parse array parameters
196196
if (config["in_files"] && config["in_files"].IsSequence()) {
197197
params.in_files.clear();
198198
for (const auto& file : config["in_files"]) {
199199
params.in_files.push_back(file.as<std::string>());
200200
}
201201
}
202-
202+
203203
if (config["antiprompt"] && config["antiprompt"].IsSequence()) {
204204
params.antiprompt.clear();
205205
for (const auto& prompt : config["antiprompt"]) {
206206
params.antiprompt.push_back(prompt.as<std::string>());
207207
}
208208
}
209-
209+
210210
if (config["sampling"]) {
211211
parse_yaml_sampling(config["sampling"], params.sampling);
212212
}
213-
213+
214214
if (config["model"]) {
215215
parse_yaml_model(config["model"], params.model);
216216
}
217-
217+
218218
if (config["speculative"]) {
219219
parse_yaml_speculative(config["speculative"], params.speculative);
220220
}
221-
221+
222222
if (config["vocoder"]) {
223223
parse_yaml_vocoder(config["vocoder"], params.vocoder);
224224
}
225-
225+
226226
if (config["diffusion"]) {
227227
parse_yaml_diffusion(config["diffusion"], params.diffusion);
228228
}
229-
229+
230230
return true;
231231
} catch (const YAML::Exception& e) {
232232
fprintf(stderr, "YAML parsing error: %s\n", e.what());
@@ -1429,7 +1429,7 @@ bool common_params_parse(int argc, char ** argv, common_params & params, llama_e
14291429
break;
14301430
}
14311431
}
1432-
1432+
14331433
if (!common_params_parse_ex(argc, argv, ctx_arg)) {
14341434
ctx_arg.params = params_org;
14351435
return false;

tests/test-yaml-backward-compat.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct TestCase {
1414

1515
static void test_cli_args_without_yaml() {
1616
std::cout << "Testing CLI arguments without YAML..." << std::endl;
17-
17+
1818
std::vector<TestCase> test_cases = {
1919
{{"test", "-n", "100"}, "Basic n_predict"},
2020
{{"test", "-p", "Hello world"}, "Basic prompt"},
@@ -27,33 +27,33 @@ static void test_cli_args_without_yaml() {
2727
{{"test", "-n", "50", "-p", "Test", "--temp", "0.7"}, "Multiple arguments"},
2828
{{"test", "--help"}, "Help flag (should exit)"},
2929
};
30-
30+
3131
for (const auto& test_case : test_cases) {
3232
if (test_case.description == "Help flag (should exit)") {
3333
continue;
3434
}
35-
35+
3636
std::cout << " Testing: " << test_case.description << std::endl;
37-
37+
3838
common_params params;
3939
std::vector<char*> argv;
4040
for (const auto& arg : test_case.args) {
4141
argv.push_back(const_cast<char*>(arg.c_str()));
4242
}
43-
43+
4444
bool result = common_params_parse(argv.size(), argv.data(), params, LLAMA_EXAMPLE_COMMON);
45-
45+
4646
if (!result && test_case.description != "Help flag (should exit)") {
4747
std::cout << " Warning: " << test_case.description << " failed to parse" << std::endl;
4848
}
4949
}
50-
50+
5151
std::cout << "CLI arguments without YAML test completed!" << std::endl;
5252
}
5353

5454
static void test_equivalent_yaml_and_cli() {
5555
std::cout << "Testing equivalent YAML and CLI produce same results..." << std::endl;
56-
56+
5757
std::ofstream yaml_file("equivalent_test.yaml");
5858
yaml_file << R"(
5959
n_predict: 100
@@ -68,16 +68,16 @@ prompt: "Test prompt"
6868
penalty_repeat: 1.1
6969
)";
7070
yaml_file.close();
71-
71+
7272
common_params yaml_params;
7373
const char* yaml_argv[] = {"test", "--config", "equivalent_test.yaml"};
7474
bool yaml_result = common_params_parse(3, const_cast<char**>(yaml_argv), yaml_params, LLAMA_EXAMPLE_COMMON);
75-
75+
7676
common_params cli_params;
7777
const char* cli_argv[] = {
78-
"test",
78+
"test",
7979
"-n", "100",
80-
"--ctx-size", "2048",
80+
"--ctx-size", "2048",
8181
"-b", "512",
8282
"-p", "Test prompt",
8383
"-s", "42",
@@ -87,12 +87,12 @@ prompt: "Test prompt"
8787
"--repeat-penalty", "1.1"
8888
};
8989
bool cli_result = common_params_parse(17, const_cast<char**>(cli_argv), cli_params, LLAMA_EXAMPLE_COMMON);
90-
90+
9191
assert(yaml_result == true);
9292
assert(cli_result == true);
9393
(void)yaml_result; // Suppress unused variable warning
9494
(void)cli_result; // Suppress unused variable warning
95-
95+
9696
assert(yaml_params.n_predict == cli_params.n_predict);
9797
assert(yaml_params.n_ctx == cli_params.n_ctx);
9898
assert(yaml_params.n_batch == cli_params.n_batch);
@@ -102,20 +102,20 @@ prompt: "Test prompt"
102102
assert(yaml_params.sampling.top_k == cli_params.sampling.top_k);
103103
assert(yaml_params.sampling.top_p == cli_params.sampling.top_p);
104104
assert(yaml_params.sampling.penalty_repeat == cli_params.sampling.penalty_repeat);
105-
105+
106106
std::filesystem::remove("equivalent_test.yaml");
107107
std::cout << "Equivalent YAML and CLI test passed!" << std::endl;
108108
}
109109

110110
static void test_all_major_cli_options() {
111111
std::cout << "Testing all major CLI options still work..." << std::endl;
112-
112+
113113
struct CliTest {
114114
std::vector<std::string> args;
115115
std::string param_name;
116116
bool should_succeed;
117117
};
118-
118+
119119
std::vector<CliTest> cli_tests = {
120120
{{"test", "-m", "model.gguf"}, "model path", true},
121121
{{"test", "-n", "200"}, "n_predict", true},
@@ -133,35 +133,35 @@ static void test_all_major_cli_options() {
133133
{{"test", "--color"}, "color output", true},
134134
{{"test", "--verbose"}, "verbose mode", true},
135135
};
136-
136+
137137
for (const auto& test : cli_tests) {
138138
std::cout << " Testing: " << test.param_name << std::endl;
139-
139+
140140
common_params params;
141141
std::vector<char*> argv;
142142
for (const auto& arg : test.args) {
143143
argv.push_back(const_cast<char*>(arg.c_str()));
144144
}
145-
145+
146146
bool result = common_params_parse(argv.size(), argv.data(), params, LLAMA_EXAMPLE_COMMON);
147-
147+
148148
if (result != test.should_succeed) {
149-
std::cout << " Unexpected result for " << test.param_name
149+
std::cout << " Unexpected result for " << test.param_name
150150
<< ": expected " << test.should_succeed << ", got " << result << std::endl;
151151
}
152152
}
153-
153+
154154
std::cout << "Major CLI options test completed!" << std::endl;
155155
}
156156

157157
int main() {
158158
std::cout << "Running backward compatibility tests..." << std::endl;
159-
159+
160160
try {
161161
test_cli_args_without_yaml();
162162
test_equivalent_yaml_and_cli();
163163
test_all_major_cli_options();
164-
164+
165165
std::cout << "All backward compatibility tests completed!" << std::endl;
166166
return 0;
167167
} catch (const std::exception& e) {

0 commit comments

Comments
 (0)