两台服务器,optuna 版本 2.10.1,一台服务器正常运行,一台服务器报错 assert version is not None。
查看源码【optuna.storages._rdb.storage — Optuna 2.10.1 documentation】发现,context.get_current_revision() 提取当前版本为 None 导致。
def get_current_version(self) -> str:
context = alembic.migration.MigrationContext.configure(self.engine.connect())
version = context.get_current_revision()
assert version is not None
return version
接下来观察一下 optuna 的依赖库版本。安装 pipdeptree
,打印 optuna 的依赖结构。
pip install pipdeptree -i https://pypi.douban.com/simple
pipdeptree -p optuna
optuna==2.10.1
- alembic [required: Any, installed: 1.7.7]
- importlib-metadata [required: Any, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- importlib-resources [required: Any, installed: 5.4.0]
- zipp [required: >=3.1.0, installed: 3.6.0]
- Mako [required: Any, installed: 1.1.6]
- MarkupSafe [required: >=0.9.2, installed: 2.0.1]
- SQLAlchemy [required: >=1.3.0, installed: 1.4.45]
- greenlet [required: !=0.4.17, installed: 2.0.1]
- importlib-metadata [required: Any, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- cliff [required: Any, installed: 3.10.1]
- autopage [required: >=0.4.0, installed: 0.5.1]
- cmd2 [required: >=1.0.0, installed: 2.4.2]
- attrs [required: >=16.3.0, installed: 22.2.0]
- importlib-metadata [required: >=1.6.0, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- pyperclip [required: >=1.6, installed: 1.8.2]
- typing-extensions [required: Any, installed: 4.1.1]
- wcwidth [required: >=0.1.7, installed: 0.2.5]
- pbr [required: >=2.0.0,!=2.1.0, installed: 5.11.0]
- PrettyTable [required: >=0.7.2, installed: 2.5.0]
- importlib-metadata [required: Any, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- wcwidth [required: Any, installed: 0.2.5]
- pyparsing [required: >=2.1.0, installed: 3.0.9]
- PyYAML [required: >=3.12, installed: 6.0]
- stevedore [required: >=2.0.1, installed: 3.5.2]
- importlib-metadata [required: >=1.7.0, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- pbr [required: >=2.0.0,!=2.1.0, installed: 5.11.0]
- cmaes [required: >=0.8.2, installed: 0.9.0]
- numpy [required: Any, installed: 1.19.5]
- colorlog [required: Any, installed: 6.7.0]
- numpy [required: Any, installed: 1.19.5]
- packaging [required: >=20.0, installed: 21.3]
- pyparsing [required: >=2.0.2,!=3.0.5, installed: 3.0.9]
- PyYAML [required: Any, installed: 6.0]
- scipy [required: !=1.4.0, installed: 1.5.4]
- numpy [required: >=1.14.5, installed: 1.19.5]
- sqlalchemy [required: >=1.1.0, installed: 2.0.3]
- greenlet [required: !=0.4.17, installed: 2.0.1]
- importlib-metadata [required: Any, installed: 4.8.3]
- typing-extensions [required: >=3.6.4, installed: 4.1.1]
- zipp [required: >=0.5, installed: 3.6.0]
- tqdm [required: Any, installed: 4.64.1]
- importlib-resources [required: Any, installed: 5.4.0]
- zipp [required: >=3.1.0, installed: 3.6.0]
发现报错服务器环境的 sqlalchemy==2.0.3
,无报错服务器环境的 sqlalchemy==1.4.45
,将 sqlalchemy 从 2.0.3
将至 1.4.45
后,assert version is not None
解决。
网友评论