From 381a3daf1bb015dba785e54f58f0c0a48b41e4aa Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Fri, 1 Sep 2023 13:35:06 +0200 Subject: [PATCH 1/2] snap --- src/radical/analytics/session.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/radical/analytics/session.py b/src/radical/analytics/session.py index 50e6a10..3bc8723 100644 --- a/src/radical/analytics/session.py +++ b/src/radical/analytics/session.py @@ -1,5 +1,6 @@ # pylint: disable=W0102,W0212 +import re import os import sys import copy @@ -484,16 +485,32 @@ def _apply_filter(self, etype=None, uid=None, state=None, # which match the given set of filters (after removing all events which # are not in the given time ranges) etype = ru.as_list(etype) - uid = ru.as_list(uid ) state = ru.as_list(state) event = ru.as_list(event) time = ru.as_list(time ) + + if isinstance(uid, re.Pattern): + # uid is actually a regex we use for matching + uid_regex = True + else: + # uid is a list of strings to look out for + uid_regex = False + uid = ru.as_list(uid) + + ret = list() for eid,entity in list(self._entities.items()): if etype and entity.etype not in etype: continue - if uid and entity.uid not in uid : continue + + if uid: + if uid_regex: + if not uid.match(entity.uid): + continue + else: + if entity.uid not in uid: + continue if state: match = False From 03b353292dc572b96ad0ab43fddf5595fd3ae74e Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Mon, 2 Oct 2023 23:42:35 +0200 Subject: [PATCH 2/2] improve filter semantics --- src/radical/analytics/session.py | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/radical/analytics/session.py b/src/radical/analytics/session.py index 3bc8723..feede29 100644 --- a/src/radical/analytics/session.py +++ b/src/radical/analytics/session.py @@ -485,32 +485,32 @@ def _apply_filter(self, etype=None, uid=None, state=None, # which match the given set of filters (after removing all events which # are not in the given time ranges) etype = ru.as_list(etype) + uids = ru.as_list(uid) state = ru.as_list(state) event = ru.as_list(event) time = ru.as_list(time ) - - if isinstance(uid, re.Pattern): - # uid is actually a regex we use for matching - uid_regex = True - else: - # uid is a list of strings to look out for - uid_regex = False - uid = ru.as_list(uid) - - ret = list() for eid,entity in list(self._entities.items()): if etype and entity.etype not in etype: continue - if uid: - if uid_regex: - if not uid.match(entity.uid): - continue - else: - if entity.uid not in uid: - continue + if uids: + keep = False + for uid in uids: + if isinstance(uid, re.Pattern): + # uid is actually a regex we use for matching + if uid.match(entity.uid): + keep = True + break + else: + # uid is a specific string to look out for + if entity.uid == uid: + keep = True + break + + if not keep: + continue if state: match = False