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-like.py — the configurations matching a request in plain words,
0003 ranked by Jev (TypeSafe AI) (swf-epicprod docs/JEV.md, Plain-language
0004 search; logic in swf_epicprod/jev_like.py).
0005 
0006 The prod-ops agent's doer for ``jev_like``, asked from the find page.
0007 Stores the cached product ``jev_like:<key>`` and records one
0008 ``jev_like`` action; the agent then publishes ``jev_like_ready``.
0009 Django-bootstrap standalone script, also usable by hand::
0010 
0011     cd /data/wenauseic/github/swf-monitor/src
0012     source ../../swf-testbed/.venv/bin/activate && source ~/.env
0013     python ../scripts/jev-like.py --text "18x275 radiative DIS Q2 above 10"
0014 
0015 Prints one ``SUMMARY`` JSON line; exit 1 when Jev gave no answer.
0016 """
0017 import argparse
0018 import json
0019 import os
0020 import sys
0021 
0022 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
0023 sys.path.insert(0, os.path.join(THIS_DIR, '..', 'src'))
0024 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'swf_monitor_project.settings')
0025 
0026 import django  # noqa: E402
0027 django.setup()
0028 
0029 from swf_epicprod.jev_like import run  # noqa: E402
0030 
0031 
0032 def main():
0033     ap = argparse.ArgumentParser(description=__doc__.split('\n\n')[0])
0034     ap.add_argument('--text', required=True)
0035     ap.add_argument('--created-by', default='jev_like')
0036     ap.add_argument('--response-url', default='',
0037                     help='a Mattermost slash command response URL to post the answer to')
0038     args = ap.parse_args()
0039     value = run(args.text, created_by=args.created_by, response_url=args.response_url)
0040     print('SUMMARY ' + json.dumps({'key': value['key'], 'ranked': len(value['ranked']),
0041                                    'error': value['error']}))
0042     return 1 if value['error'] else 0
0043 
0044 
0045 if __name__ == '__main__':
0046     sys.exit(main())