David 4 gün önce
ebeveyn
işleme
954db9d232

+ 10 - 0
app/__init__.py

@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+# @FileName  :__init__.py.py
+# @Time      :2025/5/20 10:54
+# @Author    :David
+# @Company: shenyang JY
+
+
+if __name__ == "__main__":
+    run_code = 0

+ 18 - 2
app/model/config.py → app/common/config.py

@@ -12,6 +12,8 @@ import os, threading
 import argparse, yaml
 
 
+
+
 class myargparse(argparse.ArgumentParser):
     _save_lock = threading.Lock()
     def __init__(self, description, add_help):
@@ -25,6 +27,14 @@ class myargparse(argparse.ArgumentParser):
             metavar='FILE',
             help='YAML config file specifying default arguments')
         self.add_argument(
+            '-n',
+            '--neu_yaml',
+            default=
+            'neu.yml',
+            type=str,
+            metavar='FILE',
+            help='YAML config file specifying default arguments')
+        self.add_argument(
             '-i',
             '--input_file',
             type=str,
@@ -40,13 +50,19 @@ class myargparse(argparse.ArgumentParser):
     def _parse_args_and_yaml(self):
         base_parser = argparse.ArgumentParser(add_help=False)
         base_parser.add_argument('-c', '--config_yaml', default='config.yml', type=str)
+        base_parser.add_argument('-n', '--neu_yaml', default='neu.yml', type=str)
         given_configs, remaining = base_parser.parse_known_args()
-        current_path = os.path.dirname(__file__)
+        current_path = os.path.dirname(os.path.dirname(__file__))
         if given_configs.config_yaml:
-            config_path = os.path.join(current_path, given_configs.config_yaml)
+            config_path = os.path.join(current_path, 'common', given_configs.config_yaml)
             with open(config_path, 'r', encoding='utf-8') as f:
                 cfg = yaml.safe_load(f)
                 self.set_defaults(**cfg)
+        if given_configs.neu_yaml:
+            config_path = os.path.join(current_path, 'common', given_configs.neu_yaml)
+            with open(config_path, 'r', encoding='utf-8') as f:
+                model_cfg = yaml.safe_load(f)
+                self.set_defaults(**model_cfg)
         # defaults will have been overridden if config file specified.
         # opt = self.parse_args(remaining)
         opt = self.parse_args(remaining)

+ 0 - 0
app/model/config.yml → app/common/config.yml


+ 1 - 1
app/common/data_cleaning.py

@@ -6,7 +6,7 @@
 # company: shenyang JY
 import numpy as np
 import pandas as pd
-from app.common.logs import params, logger
+from app.common.logs import logger
 np.random.seed(42)
 
 def clean_power(power, env, plant_id):

+ 3 - 2
app/common/logs.py

@@ -6,6 +6,7 @@
 # company: shenyang JY
 
 """
+将
 1. 信息流以控制台和文件形式打印
 2. 文件保存以启动日期为文件名
 3. 控制台INFO,文件DEBUG
@@ -15,8 +16,8 @@ from pathlib import Path
 import logging, logging.handlers, time, os, re
 from logging.handlers import BaseRotatingHandler
 current_dir = os.path.dirname(os.path.abspath(__file__))
-with open(os.path.join(current_dir, 'neu.yaml'), 'r', encoding='utf-8') as f:
-    params = yaml.safe_load(f)
+
+
 
 class DailyRotatingFileHandler(BaseRotatingHandler):
     """

+ 0 - 0
app/common/neu.yaml → app/common/neu.yml


+ 4 - 0
app/logs/2025-05-20/south-forecast.2025-05-20.0.log

@@ -38,3 +38,7 @@
  - _tfmw_add_deprecation_warning
 2025-05-20 09:52:46,611 - module_wrapper.py - WARNING - From E:\compete\app\model\losses.py:10: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
  - _tfmw_add_deprecation_warning
+2025-05-20 10:45:07,182 - module_wrapper.py - WARNING - From E:\compete\app\model\losses.py:10: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
+ - _tfmw_add_deprecation_warning
+2025-05-20 10:46:25,449 - module_wrapper.py - WARNING - From E:\compete\app\model\losses.py:10: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
+ - _tfmw_add_deprecation_warning

+ 4 - 6
app/model/main.py

@@ -9,15 +9,13 @@
 模型调参及系统功能配置
 """
 from tqdm import tqdm
-import argparse, yaml
 import pandas as pd
 from pathlib import Path
 from functools import partial
 from concurrent.futures import ProcessPoolExecutor
-from app.common.logs import params, logger
-from app.model.config import myargparse
+from app.common.config import myargparse
 from app.model.resource_manager import ResourceController
-# from app.model.task_worker import station_task
+from app.model.task_worker import station_task
 """"
 调用思路
    xxxx 1. 从入口参数中获取IN OUT文件位置 xxxx
@@ -37,10 +35,10 @@ def main():
     # ---------------------------- 解析参数 ----------------------------
     # 创建解析器对象
     parser = myargparse(description='算法', add_help=False)
-    # 解析参数
+    # 解析参数,将固定参数和任务参数合并
     opt = parser.parse_args_and_yaml()
     config = opt.__dict__
-    # 使用参数
+    # 打印参数
     print(f"文件: {opt.input_file}")
 
     # ---------------------------- 配置计算资源和任务 ----------------------------

+ 0 - 2
app/model/material.py

@@ -8,9 +8,7 @@ import pandas as pd
 from pathlib import Path
 from concurrent.futures import ThreadPoolExecutor
 from functools import partial
-from app.model.config import myargparse
 
-args = myargparse(description="算法批量修模", add_help=False)
 
 class MaterialLoader:
     def __init__(self, base_path, lazy_load=True):

+ 2 - 1
app/model/task_worker.py

@@ -9,11 +9,12 @@ import logging
 import pandas as pd
 from app.model.tf_model_train import ModelTrainer
 from app.model.material import MaterialLoader
-mate = MaterialLoader(base_path='E:/compete/app/model/data/DQYC/qy/62/1002/2025-04-21/IN')
+
 
 def station_task(station_id, config):
     """单个场站训练任务"""
     try:
+        mate = MaterialLoader(base_path=config['input_file'])
         # 动态生成场站数据路径
         input_file = config['data_template'].format(station_id=station_id)
 

+ 0 - 2
app/model/tf_model_train.py

@@ -16,9 +16,7 @@ from typing import Dict, Any
 from app.common.tf_lstm import TSHandler
 from app.common.dbmg import MongoUtils
 from app.common.data_handler import DataHandler, write_number_to_file
-from app.model.config import myargparse
 from app.common.logs import logger
-args = myargparse(description="算法批量修模", add_help=False)
 
 mgUtils = MongoUtils(logger)