Skip to content
Snippets Groups Projects

Add orca passthrough

Merged Robert Rosca requested to merge feat/orca-passthrough into master
All threads resolved!
+ 51
0
@@ -21,6 +21,7 @@ from subprocess import PIPE, run
from threading import Thread
from typing import Any, Dict, List, Optional, Tuple
import requests
import yaml
import zmq
import zmq.asyncio
@@ -698,6 +699,42 @@ async def update_mdc_status(mdc: MetadataClient, action: str,
logging.error(Errors.MDC_RESPONSE.format(response))
def _orca_passthrough(
proposal_number = None,
runs = None,
action = None,
route = "execute",
**kwargs,
):
""" Passes through requests received by the webservice to Orca for use during
the transition to the new webservice
Due to network restrictions on Maxwell, this sends post requests to localhost on
port 42751 (a random port number), so either Orca should be running locally or a
ssh tunnel should be set up with `ssh -L 42751:localhost:42751 TARGET-SERVER -N &`
"""
try:
base_url = "http://localhost"
port = "42751"
args = []
args.append(f"action={action}") if action else None
args.append(f"runs={','.join(str(r) for r in runs)}") if runs else None
args.extend([f"{k}={v}" for k, v in kwargs.items()])
url = f"{base_url}:{port}/{route}/{proposal_number}?{'&'.join(filter(None, args))}"
except Exception as e:
logging.warning("error building orca passthrough request", exc_info=True)
return None
try:
requests.post(url)
except Exception as e:
logging.error(f"orca post request error for url {url}", exc_info=True)
class ActionsServer:
def __init__(self, config, mode):
self.config = config
@@ -821,6 +858,12 @@ class ActionsServer:
proposal = self._normalise_proposal_num(proposal)
pconf_full = self.load_proposal_config(cycle, proposal)
_orca_passthrough(
proposal_number=proposal,
runs=[runnr],
route="execute",
)
data_conf = pconf_full['data-mapping']
if instrument in pconf_full['correct']:
pconf = pconf_full['correct'][instrument]
@@ -942,6 +985,14 @@ class ActionsServer:
proposal = self._normalise_proposal_num(proposal)
_orca_passthrough(
proposal_number=proposal,
runs=runs,
action="dark",
route="execute",
karabo_id=karabo_id,
)
pconf_full = self.load_proposal_config(cycle, proposal)
data_conf = pconf_full['data-mapping']
Loading