22 lines
1.1 KiB
Python
22 lines
1.1 KiB
Python
from pathlib import Path
|
|
import subprocess
|
|
p=Path('/home/ps/huobao-vdn/app.py')
|
|
s=p.read_text()
|
|
anchor=' response.raise_for_status()\n payload = response.json()\n finally:'
|
|
assert s.count(anchor)==1
|
|
replacement=''' if response.status_code == 400:
|
|
rejected = response.json()
|
|
issues = []
|
|
for node, info in (rejected.get('node_errors') or {}).items():
|
|
for error in info.get('errors', []):
|
|
issues.append(str(node) + ': ' + str(error.get('message', '')) + ': ' + str(error.get('details', ''))[:300])
|
|
if not issues:
|
|
issues = [str(rejected.get('error', 'Workflow validation failed'))[:600]]
|
|
raise HTTPException(status_code=400, detail='; '.join(issues)[:1800])
|
|
response.raise_for_status()
|
|
payload = response.json()
|
|
finally:'''
|
|
p.write_text(s.replace(anchor,replacement))
|
|
subprocess.run(['docker','restart','huobao-vdn-normalizer'],check=True)
|
|
print('VDN validation errors now report the failing node')
|