{{ message }}
Repository navigation
Fix issues found by Sourcery review - #399
Open
im47cn-bot wants to merge 1 commit into
Open
im47cn-bot wants to merge 1 commit into
im47cn-bot wants to merge 1 commit into
Conversation
Apply Sourcery fixes across finetune, finetune_csv, model and webui: - Auto-fixed: merge-duplicate-blocks, simplify-if, swap-if-expression, use-named-expression, any() over not-all(), etc. - Manual low-code-quality refactors (behavior-preserving): train_model/train_tokenizer split into epoch/validate/summary helpers; kronos.py predict_batch split; webui app.py create_prediction_chart and predict split - tests: MSE sampling loop extracted to _compute_mse_values; 3 data-guard conditionals kept intentionally Verification: py_compile all files, sourcery review zero issues except 3 kept guards, pytest 4 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

修复摘要
Sourcery 扫描发现的问题已全部修复(54 issues:44 自动 + 10 手工)。
自动修复(merge-duplicate-blocks / simplify-if / swap-if-expression / use-named-expression 等)
finetune/qlib_test.py、finetune_csv/config_loader.py、finetune_csv/train_sequential.py、model/__init__.py、model/module.py、webui/run.py等 11 文件model/kronos.py:sample_from_logits嵌套 if 合并、ran = trange if verbose else range、any(col not in ...)替代not all(col in ...)手工重构(rule: low-code-quality,全部行为等价)
finetune/train_predictor.pytrain_model拆为_train_one_epoch/_validate/_log_epoch_summaryfinetune/train_tokenizer.pytrain_model拆为_train_one_epoch/_accumulate_gradients/_validate/_log_epoch_summaryfinetune_csv/finetune_base_model.pytrain_model拆为 6 个 helper(_prepare_epoch/_train_one_epoch/_validate_model/_reduce_epoch_metrics/_log_epoch_summary/_save_best_if_improved)finetune_csv/finetune_tokenizer.pytrain_tokenizer拆为 5 个 helper(梯度累积提取_accumulate_gradients)model/kronos.pypredict_batch拆为_prepare_batch_series/_build_batch_pred_dfswebui/app.pycreate_prediction_chart与predict拆为 13 个 helper测试规则处理
tests/test_kronos_regression.py: MSE 采样循环提取为模块级_compute_mse_values(消除 no-loop-in-tests)no-conditionals-in-tests:均为数据前提守卫(数据不足时raise ValueError而非静默失败),属合法测试前提检查,非断言条件验证
python3 -m py_compile全部 23 个跟踪文件通过sourcery review仅剩上述 3 处有意保留的守卫pytest tests/4 个回归测试全部通过