Skip to content

Commit

Permalink
Merge pull request #23 from oda-hub/rt-data
Browse files Browse the repository at this point in the history
adding parameter for realtime data WPdomains
  • Loading branch information
volodymyrss authored May 10, 2023
2 parents e61dc1f + b9debf5 commit 532f97a
Show file tree
Hide file tree
Showing 4 changed files with 352 additions and 139 deletions.
17 changes: 7 additions & 10 deletions dispatcher_plugin_integral_all_sky/spiacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,18 @@ def common_instr_query():
#TODO make a special class
#max_pointings=Integer(value=50,name='max_pointings')



instr_query_pars=[]


return instr_query_pars


def spiacs_factory():
print('--> Spiacs Factory')
src_query=SourceQuery('src_query')

src_query = SourceQuery('src_query')

instr_query_pars = common_instr_query()

instr_query_pars=common_instr_query()

instr_query=InstrumentQuery(
instr_query = InstrumentQuery(
name='spiacs_parameters',
extra_parameters_list=instr_query_pars,
input_prod_list_name=None,
Expand All @@ -79,7 +74,7 @@ def spiacs_factory():



light_curve =SpiacsLightCurveQuery('spi_acs_lc_query')
light_curve = SpiacsLightCurveQuery('spi_acs_lc_query')



Expand All @@ -90,9 +85,11 @@ def spiacs_factory():
print('--> conf_file',conf_file)
print('--> conf_dir', conf_dir)



return Instrument('spi_acs',
asynch=False,
data_serve_conf_file=conf_file,
data_serve_conf_file=conf_file,
src_query=src_query,
instrumet_query=instr_query,
product_queries_list=[light_curve],
Expand Down
25 changes: 18 additions & 7 deletions dispatcher_plugin_integral_all_sky/spiacs_dataserver_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from builtins import (bytes, str, open, super, range,
zip, round, input, int, pow, object, map, zip)
import re

__author__ = "Volodymyr Savchenko, Andrea Tramacere"

Expand Down Expand Up @@ -77,7 +78,7 @@ def __init__(self, message='Spiacs unknown exception', debug_message=''):
super(SpiacsUnknownException, self).__init__(message, debug_message)


class SpiacsDispatcher(object):
class SpiacsDispatcher:

def __init__(self, config=None, param_dict=None, instrument=None):
logger.info('--> building class SpiacsDispatcher instrument: %s config: %s', instrument, config)
Expand Down Expand Up @@ -131,9 +132,6 @@ def __init__(self, config=None, param_dict=None, instrument=None):
_data_server_port = config.data_server_port

except Exception as e:
# #print(e)

print("ERROR->")
raise RuntimeError(f"failed to use config {e}")

self.config(_data_server_url, _data_server_port)
Expand Down Expand Up @@ -176,13 +174,25 @@ def _run_test(self, t1=1482049941, t2=1482049941+100, dt=0.1, e1=10, e2=500):
def _run(self, data_server_url, param_dict):

try:

url = data_server_url.format(
t0_isot=param_dict['t0_isot'],
dt_s=param_dict['dt_s'],
)
logger.debug('calling GET on %s', url)
res = requests.get("%s" % (url), params=param_dict)

url_ephs = data_server_url.replace("genlc/ACS", "ephs").rsplit('/', 1)[0].format(
t0_isot=param_dict['t0_isot'],
)

if param_dict['data_level'] == 'realtime':
url = url.replace("genlc/ACS", "rtlc") + "?json&prophecy"

logger.info("calling data server %s with %s", data_server_url, param_dict)
logger.info('calling GET on %s', url)

res = requests.get(url, params=param_dict)
res_ephs = requests.get(url_ephs)

if len(res.content) < 8000: # typical length to avoid searching in long strings, which can not be errors of this kind
if 'this service are limited' in res.text or 'Over revolution' in res.text:
raise SpiacsAnalysisException(f"SPI-ACS backend refuses to process this request, due to resource constrain: {res.text}")
Expand All @@ -195,7 +205,7 @@ def _run(self, data_server_url, param_dict):
f'Spiacs Analysis error: {e}')


return res
return res, res_ephs

def run_query(self, call_back_url=None, run_asynch=False, logger=None, param_dict=None,):

Expand All @@ -212,6 +222,7 @@ def run_query(self, call_back_url=None, run_asynch=False, logger=None, param_dic
logger.info('call_back_url %s', call_back_url)
logger.info('data_server_url %s', self.data_server_url)
logger.info('*** run_asynch %s', run_asynch)
logger.warning('param_dict %s', param_dict)

res = self._run(self.data_server_url, param_dict)

Expand Down
Loading

0 comments on commit 532f97a

Please sign in to comment.