Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:47:22

0001 #!/usr/bin/env python3
0002 """jev-config-neighbors.py — configurations like this one: for each
0003 physics configuration, its nearest configurations in physics, ranked by
0004 Jev (TypeSafe AI) on one rubric (swf-epicprod docs/JEV.md, Neighbours;
0005 logic in swf_epicprod/config_neighbors.py).
0006 
0007 The prod-ops agent's doer for ``jev_config_neighbors``: all
0008 configurations nightly by cron enqueue, or the configurations named in
0009 the message. Stores the cached product ``jev_config_neighbors`` and
0010 records one ``jev_config_neighbors`` action. Django-bootstrap
0011 standalone script, also usable by hand::
0012 
0013     cd /data/wenauseic/github/swf-monitor/src
0014     source ../../swf-testbed/.venv/bin/activate && source ~/.env
0015     python ../scripts/jev-config-neighbors.py [--label pc434 ...] [--created-by NAME]
0016 
0017 Prints one ``SUMMARY`` JSON line; exit 1 when nothing was computed.
0018 """
0019 import argparse
0020 import json
0021 import os
0022 import sys
0023 
0024 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
0025 sys.path.insert(0, os.path.join(THIS_DIR, '..', 'src'))
0026 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'swf_monitor_project.settings')
0027 
0028 import django  # noqa: E402
0029 django.setup()
0030 
0031 from swf_epicprod.config_neighbors import run  # noqa: E402
0032 
0033 
0034 def main():
0035     ap = argparse.ArgumentParser(description=__doc__.split('\n\n')[0])
0036     ap.add_argument('--label', action='append', default=[],
0037                     help='a configuration to compute (repeatable); all when absent')
0038     ap.add_argument('--created-by', default='jev_config_neighbors')
0039     args = ap.parse_args()
0040     summary = run(labels=args.label or None, created_by=args.created_by)
0041     print('SUMMARY ' + json.dumps(summary, default=str))
0042     return 0 if summary.get('computed') else 1
0043 
0044 
0045 if __name__ == '__main__':
0046     sys.exit(main())