Skip to content

Commit

Permalink
Request failing now continues with an error message rather than halti…
Browse files Browse the repository at this point in the history
…ng the pipeline
  • Loading branch information
Gerenjie committed Jul 25, 2024
1 parent fd9279d commit 3a2fb61
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions python/lsst/ap/association/mpSkyEphemerisQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

0 comments on commit 3a2fb61

Please sign in to comment.