From 3a2fb617c834ac35ad3285f4159035962e34aea7 Mon Sep 17 00:00:00 2001 From: Jake Kurlander Date: Thu, 25 Jul 2024 13:13:36 -0700 Subject: [PATCH] Request failing now continues with an error message rather than halting the pipeline --- .../ap/association/mpSkyEphemerisQuery.py | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/python/lsst/ap/association/mpSkyEphemerisQuery.py b/python/lsst/ap/association/mpSkyEphemerisQuery.py index 210783cd..59f2523a 100644 --- a/python/lsst/ap/association/mpSkyEphemerisQuery.py +++ b/python/lsst/ap/association/mpSkyEphemerisQuery.py @@ -98,7 +98,7 @@ class MPSkyEphemerisQueryTask(PipelineTask): def runQuantum(self, butlerQC, inputRefs, outputRefs): inputs = butlerQC.get(inputRefs) - inputs["visit"] = butlerQC.quantum.dataId["visit"] + # inputs["group"] = butlerQC.quantum.dataId["group"] outputs = self.run(**inputs) @@ -187,39 +187,40 @@ def _MPSkyConeSearch(self, expCenter, epochMJD, queryRadius): try: response = requests.get(self.config.MPSkyURL, params=params) response.raise_for_status() + with pa.input_stream(memoryview(response.content)) as fp: + fp.seek(0) + p = pa.ipc.read_tensor(fp) + op = pa.ipc.read_tensor(fp) + op, p = op, p + with pa.ipc.open_stream(fp) as reader: + r = next(reader) + + ObjID = r["name"].to_numpy(zero_copy_only=False) + ra = r["ra"].to_numpy() + dec = r["dec"].to_numpy() + + # ObjID, ra, dec, obj_poly, obs_poly = mpsky.query_service('https://sky.dirac.dev/ephemerides/', + # epochMJD, fieldRA, fieldDec, queryRadius) + + MPSkySsObjects = pd.DataFrame() + MPSkySsObjects['ObjID'] = ObjID + MPSkySsObjects['ra'] = ra + MPSkySsObjects['dec'] = dec + MPSkySsObjects['obj_poly'] = list(np.zeros((len(MPSkySsObjects), 5))) # fix, eventually + MPSkySsObjects['obs_poly'] = list(np.zeros((len(MPSkySsObjects), 5))) # fix, eventually + MPSkySsObjects['Err(arcsec)'] = 2 + MPSkySsObjects['ssObjectId'] = [abs(hash(v)) for v in MPSkySsObjects['ObjID'].values] + nFound = len(MPSkySsObjects) + + if nFound == 0: + self.log.info("No Solar System objects found for visit.") + + self.log.info("%d Solar System Objects in visit", nFound) except requests.exceptions.ConnectionError as e: print("failed to connect to the remote ephemerides service. details:", file=sys.stderr) print(e, file=sys.stderr) - exit(-1) - - with pa.input_stream(memoryview(response.content)) as fp: - fp.seek(0) - p = pa.ipc.read_tensor(fp) - op = pa.ipc.read_tensor(fp) - op, p = op, p - with pa.ipc.open_stream(fp) as reader: - r = next(reader) - - ObjID = r["name"].to_numpy(zero_copy_only=False) - ra = r["ra"].to_numpy() - dec = r["dec"].to_numpy() - - # ObjID, ra, dec, obj_poly, obs_poly = mpsky.query_service('https://sky.dirac.dev/ephemerides/', - # epochMJD, fieldRA, fieldDec, queryRadius) - - MPSkySsObjects = pd.DataFrame() - MPSkySsObjects['ObjID'] = ObjID - MPSkySsObjects['ra'] = ra - MPSkySsObjects['dec'] = dec - MPSkySsObjects['obj_poly'] = list(np.zeros((len(MPSkySsObjects), 5))) # fix, eventually - MPSkySsObjects['obs_poly'] = list(np.zeros((len(MPSkySsObjects), 5))) # fix, eventually - MPSkySsObjects['Err(arcsec)'] = 2 - MPSkySsObjects['ssObjectId'] = [abs(hash(v)) for v in MPSkySsObjects['ObjID'].values] - nFound = len(MPSkySsObjects) - - if nFound == 0: - self.log.info("No Solar System objects found for visit.") - - self.log.info("%d Solar System Objects in visit", nFound) + MPSkySsObjects = pd.DataFrame( + columns=['ObjID', 'ra', 'dec', 'obj_poly', 'obs_poly', + 'Err(arcsec)', 'ssObjectId']) return MPSkySsObjects