nep框架搭建
This commit is contained in:
0
nep_auto/__init__.py
Normal file
0
nep_auto/__init__.py
Normal file
37
nep_auto/driver.py
Normal file
37
nep_auto/driver.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import yaml
|
||||
import time
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from nep_auto.status_manager import StatusManager
|
||||
|
||||
|
||||
class NEPDriver:
|
||||
def __init__(self):
|
||||
self.logger = logging.getLogger("NEP_Auto")
|
||||
self.root = Path(".")
|
||||
|
||||
# 1. 加载配置
|
||||
self.config_sys = self._load_yaml("config/system.yaml")
|
||||
self.config_param = self._load_yaml("config/param.yaml")
|
||||
self.logger.info(f"项目名称: {self.config_sys.get('project_name')}")
|
||||
|
||||
# 2. 初始化状态管理器
|
||||
self.status = StatusManager(self.root / "workspace")
|
||||
|
||||
def _load_yaml(self, path):
|
||||
if not Path(path).exists():
|
||||
raise FileNotFoundError(f"配置文件缺失: {path}")
|
||||
with open(path, 'r') as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
def run(self):
|
||||
"""主循环"""
|
||||
self.logger.info("✅ 驱动器初始化完成,准备进入主循环...")
|
||||
|
||||
# 获取当前轮次
|
||||
current_iter = self.status.get_current_iter()
|
||||
self.logger.info(f"当前进度: iter_{current_iter:03d}")
|
||||
|
||||
# 暂时只打印一次就退出,用于测试环境
|
||||
self.logger.info("测试阶段:环境检查通过。等待模块代码实现...")
|
||||
# while True: ... (后续我们将在这里实现调度逻辑)
|
||||
0
nep_auto/modules/__init__.py
Normal file
0
nep_auto/modules/__init__.py
Normal file
0
nep_auto/modules/base_module.py
Normal file
0
nep_auto/modules/base_module.py
Normal file
0
nep_auto/modules/m0_preheat.py
Normal file
0
nep_auto/modules/m0_preheat.py
Normal file
0
nep_auto/modules/m1_md.py
Normal file
0
nep_auto/modules/m1_md.py
Normal file
0
nep_auto/modules/m2_select.py
Normal file
0
nep_auto/modules/m2_select.py
Normal file
0
nep_auto/modules/m3_scf.py
Normal file
0
nep_auto/modules/m3_scf.py
Normal file
0
nep_auto/modules/m4_train.py
Normal file
0
nep_auto/modules/m4_train.py
Normal file
0
nep_auto/modules/m5_predict.py
Normal file
0
nep_auto/modules/m5_predict.py
Normal file
27
nep_auto/status_manager.py
Normal file
27
nep_auto/status_manager.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class StatusManager:
|
||||
def __init__(self, workspace_path):
|
||||
self.workspace = Path(workspace_path)
|
||||
self.status_file = self.workspace / "status.json"
|
||||
|
||||
if not self.workspace.exists():
|
||||
self.workspace.mkdir(parents=True)
|
||||
|
||||
# 如果没有状态文件,创建一个初始的
|
||||
if not self.status_file.exists():
|
||||
self._save_status({"current_iter": 1, "stages": {}})
|
||||
|
||||
def _save_status(self, data):
|
||||
with open(self.status_file, 'w') as f:
|
||||
json.dump(data, f, indent=4)
|
||||
|
||||
def get_current_iter(self):
|
||||
if self.status_file.exists():
|
||||
with open(self.status_file, 'r') as f:
|
||||
data = json.load(f)
|
||||
return data.get("current_iter", 1)
|
||||
return 1
|
||||
0
nep_auto/utils/__init__.py
Normal file
0
nep_auto/utils/__init__.py
Normal file
33
nep_auto/utils/logger.py
Normal file
33
nep_auto/utils/logger.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def setup_logger(log_file="logs/runtime.log"):
|
||||
# 确保日志目录存在
|
||||
os.makedirs(os.path.dirname(log_file), exist_ok=True)
|
||||
|
||||
logger = logging.getLogger("NEP_Auto")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
# 避免重复添加 handler
|
||||
if logger.handlers:
|
||||
return logger
|
||||
|
||||
# 格式
|
||||
formatter = logging.Formatter(
|
||||
'[%(asctime)s] [%(levelname)s] %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
)
|
||||
|
||||
# 文件输出
|
||||
fh = logging.FileHandler(log_file, mode='a', encoding='utf-8')
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
|
||||
# 屏幕输出
|
||||
ch = logging.StreamHandler(sys.stdout)
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
return logger
|
||||
0
nep_auto/utils/notifier.py
Normal file
0
nep_auto/utils/notifier.py
Normal file
0
nep_auto/utils/runner.py
Normal file
0
nep_auto/utils/runner.py
Normal file
Reference in New Issue
Block a user