在其他Python程序中调用hydrotopo的find_edge_nodes性能骤降问题排查
问题汇总:性能瓶颈与测试报错
1. 函数调用性能骤降问题
我开发的工具hydrotopo中,独立运行find_edge_nodes处理约10万条线要素的拓扑关系仅需10秒;但在其他程序中调用该方法时,耗时飙升至约30分钟。调用代码片段如下:
# extract from torchhydro/datasets/data_sets.py#L872 import hydrotopo.ig_path as htip # 同样的方法耗时约30分钟 graph_lists = htip.find_edge_nodes(node_features, network_features, node_idx, 'up', cutoff) return graph_lists
调试模式下暂停时,程序频繁停在predicates.has_z处,我的代码中并无过多循环逻辑,想了解has_z为何会消耗大量时间,或者有什么其他解决方案。
2. 环境信息更新
- hydrotopo与调用它的torchhydro均使用Python 3.11,通过Intellij IDEA的pytest进行测试
- 已确认hydrotopo完成编译,编译文件路径:
/home/username/.conda/envs/torchhydro1/lib/python3.11/site-packages/hydrotopo/__pycache__/ig_path.cpython-311.pyc
3. pytest调试导入报错问题
尝试通过pytest调试test_run_model时出现导入错误,执行命令及报错信息如下:
(torchhydro1) username@vm-jupyterhub-server:~/torchhydro$ pytest experiments/train_with_era5land_gnn.py::run_test_model platform linux -- Python 3.11.9, pytest-8.3.2, pluggy-1.5.0 rootdir: /home/username/torchhydro configfile: setup.cfg collected 0 items / 1 error ImportError while importing test module '/home/username/torchhydro/experiments/train_with_era5land_gnn.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: ../.conda/envs/torchhydro1/lib/python3.11/importlib/__init__.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) experiments/train_with_era5land_gnn.py:14: in <module> from torchhydro.configs.config import cmd, default_config_file, update_cfg E ModuleNotFoundError: No module named 'torchhydro' ERROR: found no collectors for /home/username/torchhydro/experiments/train_with_era5land_gnn.py::run_test_model
内容的提问来源于stack exchange,提问作者forestbat
相关产品推荐
相关产品推荐

