Skip to content

Commit

Permalink
Get rid reason/scaling lookup error handling (#411)
Browse files Browse the repository at this point in the history
* bump all product versions to 2

* add global error detection in pipeline logger (not just main process)

* add exception handling for get_reason
nicHoch authored Nov 25, 2024
1 parent ae330f3 commit 5262249
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -164,3 +164,4 @@ stixcore/data/publish/
stixcore/data/test/products/end2end/
monitor_status.json
stixcore/data/test/idb/v2.26.38/idb.sqlite
.python-version
12 changes: 8 additions & 4 deletions stixcore/io/RidLutManager.py
Original file line number Diff line number Diff line change
@@ -70,9 +70,13 @@ def get_reason(self, rid):
str
verbal description of the request purpose
"""
request = self.rid_lut.loc[rid]
reason = " ".join(np.atleast_1d(request['description']))
return reason
try:
request = self.rid_lut.loc[rid]
reason = " ".join(np.atleast_1d(request['description']))
return reason
except IndexError:
logger.warning("can't get request purpose: no request founds for rid: {rid}")
return ""

def get_scaling_factor(self, rid):
"""Gets the trigger descaling factor connected to the BSD request.
@@ -165,7 +169,7 @@ def read_rid_lut(cls, file, update=False):
# the stix datacenter API is throttled to 2 calls per second
time.sleep(0.5)
except Exception:
logger.error("RID API ERROR", exc_info=True)
logger.warning("RID API ERROR", exc_info=True)

rid_lut = unique(rid_lut, silent=True)
ascii.write(rid_lut, file, overwrite=True, delimiter=",", quotechar='"')
3 changes: 2 additions & 1 deletion stixcore/processing/pipeline.py
Original file line number Diff line number Diff line change
@@ -149,6 +149,7 @@ def emit(self, record):
"""Called in case of a logging event."""
self.allright = False
self.error = record
self.err_file.touch()

def __enter__(self):
return self
@@ -159,7 +160,7 @@ def __exit__(self, type, value, traceback):
logging.getLogger().removeHandler(self.fh)
PipelineStatus.instance.last_tm = (self.tm_file, datetime.now())
PipelineStatus.instance.current_tm = (None, datetime.now())
if not self.allright:
if not self.allright or self.err_file.exists():
shutil.copyfile(self.log_file, self.err_file)
PipelineStatus.instance.last_error = (self.tm_file, datetime.now(),
self.error, self.err_file)

0 comments on commit 5262249

Please sign in to comment.