修正引用路径;恢复project_info.py到service目录,新增config/project_info.yml配置文件

This commit is contained in:
2026-01-21 17:41:52 +08:00
parent 6c0f7d821c
commit 5986a20cc3
25 changed files with 50 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
import os import os
from tjnetwork import * from app.services.tjnetwork import *
from app.native.api.project import copy_project from app.native.api.project import copy_project
from run_simulation import run_simulation_ex, from_clock_to_seconds_2 from run_simulation import run_simulation_ex, from_clock_to_seconds_2
from math import sqrt, pi from math import sqrt, pi
@@ -18,7 +18,7 @@ import geopandas as gpd
from sqlalchemy import create_engine from sqlalchemy import create_engine
import ast import ast
import sensitivity import sensitivity
import configs.project_info as project_info import app.services.project_info as project_info
import app.algorithms.api_ex.kmeans_sensor import app.algorithms.api_ex.kmeans_sensor
import app.algorithms.api_ex.Fdataclean import app.algorithms.api_ex.Fdataclean
import app.algorithms.api_ex.Pdataclean import app.algorithms.api_ex.Pdataclean

View File

@@ -11,7 +11,7 @@ from sklearn.cluster import KMeans
from wntr.epanet.toolkit import EpanetException from wntr.epanet.toolkit import EpanetException
from numpy.linalg import slogdet from numpy.linalg import slogdet
import random import random
from tjnetwork import * from app.services.tjnetwork import *
from matplotlib.lines import Line2D from matplotlib.lines import Line2D
from sklearn.cluster import SpectralClustering from sklearn.cluster import SpectralClustering
import libpysal as ps import libpysal as ps

View File

@@ -11,7 +11,7 @@ from sklearn.cluster import KMeans
from wntr.epanet.toolkit import EpanetException from wntr.epanet.toolkit import EpanetException
from numpy.linalg import slogdet from numpy.linalg import slogdet
import random import random
from tjnetwork import * from app.services.tjnetwork import *
import project_info import project_info
# 2025/03/12 # 2025/03/12

View File

@@ -18,7 +18,7 @@ import get_data
import psycopg import psycopg
import time import time
import app.services.simulation as simulation import app.services.simulation as simulation
from tjnetwork import * from app.services.tjnetwork import *
import schedule import schedule
import threading import threading
import app.services.globals as globals import app.services.globals as globals
@@ -27,7 +27,7 @@ import pandas as pd
import openpyxl import openpyxl
import pytz import pytz
import app.infra.db.influxdb.info as influxdb_info import app.infra.db.influxdb.info as influxdb_info
import configs.project_info as project_info import app.services.project_info as project_info
import app.services.time_api as time_api import app.services.time_api as time_api
from app.native.api.postgresql_info import get_pgconn_string from app.native.api.postgresql_info import get_pgconn_string

View File

@@ -47,7 +47,7 @@ import py_linq
import app.services.time_api as time_api import app.services.time_api as time_api
import app.services.simulation as simulation import app.services.simulation as simulation
import app.services.globals as globals import app.services.globals as globals
import configs.project_info as project_info import app.services.project_info as project_info
from app.infra.db.timescaledb.database import db as tsdb from app.infra.db.timescaledb.database import db as tsdb
from app.infra.db.postgresql.database import db as pgdb from app.infra.db.postgresql.database import db as pgdb
from app.algorithms.online_Analysis import * from app.algorithms.online_Analysis import *

View File

@@ -0,0 +1,22 @@
import os
import yaml
# 获取当前项目根目录的路径
_current_file = os.path.abspath(__file__)
project_root = os.path.dirname(os.path.dirname(os.path.dirname(_current_file)))
# 尝试读取 .yml 或 .yaml 文件
config_file = os.path.join(project_root, "configs", "project_info.yml")
if not os.path.exists(config_file):
config_file = os.path.join(project_root, "configs", "project_info.yaml")
if not os.path.exists(config_file):
raise FileNotFoundError(f"未找到项目配置文件 (project_info.yaml 或 .yml): {os.path.dirname(config_file)}")
with open(config_file, 'r', encoding='utf-8') as f:
_config = yaml.safe_load(f)
if not _config or 'name' not in _config:
raise KeyError(f"项目配置文件中缺少 'name' 配置: {config_file}")
name = _config['name']

View File

@@ -1,5 +1,5 @@
import numpy as np import numpy as np
from tjnetwork import * from app.services.tjnetwork import *
from app.native.api.s36_wda_cal import * from app.native.api.s36_wda_cal import *
# from get_real_status import * # from get_real_status import *
@@ -19,10 +19,10 @@ import psycopg
import logging import logging
import app.services.globals as globals import app.services.globals as globals
import uuid import uuid
import configs.project_info as project_info import app.services.project_info as project_info
from app.native.api.postgresql_info import get_pgconn_string from app.native.api.postgresql_info import get_pgconn_string
from timescaledb.internal_queries import InternalQueries as TimescaleInternalQueries from app.infra.db.timescaledb.internal_queries import InternalQueries as TimescaleInternalQueries
from timescaledb.internal_queries import InternalStorage as TimescaleInternalStorage from app.infra.db.timescaledb.internal_queries import InternalStorage as TimescaleInternalStorage
logging.basicConfig( logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"

View File

@@ -1 +0,0 @@
name='szh'

1
configs/project_info.yml Normal file
View File

@@ -0,0 +1 @@
name: szh

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
if __name__ == '__main__': if __name__ == '__main__':
clean_project() clean_project()

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
argc = len(sys.argv) argc = len(sys.argv)

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
read_inp("beibeizone","beibeizone.inp") read_inp("beibeizone","beibeizone.inp")
#open_project('beibeizone') #open_project('beibeizone')
#generate_service_area("beibeizone",0.00001) #generate_service_area("beibeizone",0.00001)

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
p = 'dev' p = 'dev'

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
from get_realValue import * from get_realValue import *
from get_hist_data import * from get_hist_data import *
import datetime import datetime

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
from get_realValue import * from get_realValue import *
def get_current_total_Q(): def get_current_total_Q():
ids=['3489'] ids=['3489']

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
open_project('szh') open_project('szh')

View File

@@ -1,5 +1,5 @@
import sys import sys
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
if len(sys.argv) != 2: if len(sys.argv) != 2:

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
def main(): def main():
for p in list_project(): for p in list_project():

View File

@@ -1,4 +1,4 @@
from tjnetwork import * from app.services.tjnetwork import *
from get_current_status import * from get_current_status import *
def run_simulation(cur_datetime:str=None)->str: def run_simulation(cur_datetime:str=None)->str:

View File

@@ -1,5 +1,5 @@
import numpy as np import numpy as np
from tjnetwork import * from app.services.tjnetwork import *
from api.s36_wda_cal import * from api.s36_wda_cal import *
# from get_real_status import * # from get_real_status import *
from datetime import datetime,timedelta from datetime import datetime,timedelta

View File

@@ -1,6 +1,6 @@
import pytest import pytest
import random import random
from tjnetwork import * from app.services.tjnetwork import *
class TestApi: class TestApi:
def enter(self, p): def enter(self, p):