Skip to content

Commit

Permalink
merge from devel
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-merzky committed Jun 27, 2024
2 parents b3f9cca + 00aaa00 commit 8adea0c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/radical/analytics/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def __init__(self, _uid, _profile, _details):
self._cfg = self._details.get('cfg', dict())
self._resources = self._details.get('resources', dict())

self._name = self._description.get('name') \
or self._description.get('job_name') \
or self._uid

# if have no etype tree information, guess the etype from uid
if not self._etype:
self._etype = self._uid.split('.')[0]
Expand Down Expand Up @@ -64,6 +68,7 @@ def __getstate__(self):

state = {
'uid' : self._uid,
'name' : self._name,
'etype' : self._etype,
'details' : self._details,
'description' : self._description,
Expand Down Expand Up @@ -101,6 +106,10 @@ def __setstate__(self, state):
self._t_stop = state['t_stop']
self._ttc = state['ttc']

self._name = self._description.get('name') \
or self._description.get('job_name') \
or self._uid


# --------------------------------------------------------------------------
#
Expand All @@ -124,6 +133,10 @@ def t_range(self):
def uid(self):
return self._uid

@property
def name(self):
return self._name

@property
def etype(self):
return self._etype
Expand Down
44 changes: 35 additions & 9 deletions src/radical/analytics/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,15 @@ def _initialize_properties(self):

# --------------------------------------------------------------------------
#
def _apply_filter(self, etype=None, uid=None, state=None,
event=None, time=None):
def _apply_filter(self, etype=None, uid=None, name=None,
state=None, event=None, time=None):

# iterate through all self._entities and collect UIDs of all entities
# 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)
names = ru.as_list(name)
state = ru.as_list(state)
event = ru.as_list(event)
time = ru.as_list(time )
Expand Down Expand Up @@ -519,6 +520,30 @@ def _apply_filter(self, etype=None, uid=None, state=None,
if not keep:
continue

if names:
try:
re_pattern = re.Pattern
except AttributeError:
re_pattern = None
self._log.warn('re.Pattern is not supported within this '
'python version')

keep = False
for name in names:
if re_pattern and isinstance(name, re_pattern):
# name is actually a regex we use for matching
if name.match(entity.name):
keep = True
break
else:
# name is a specific string to look out for
if entity.name == name:
keep = True
break

if not keep:
continue

if state:
match = False
for s,stuple in list(entity.states.items()):
Expand Down Expand Up @@ -588,20 +613,21 @@ def list(self, pname=None):

# --------------------------------------------------------------------------
#
def get(self, etype=None, uid=None, state=None, event=None, time=None):
def get(self, etype=None, uid=None, name=None,
state=None, event=None, time=None):

uids = self._apply_filter(etype=etype, uid=uid, state=state,
event=event, time=time)
uids = self._apply_filter(etype=etype, uid=uid, name=name,
state=state, event=event, time=time)
return [self._entities[_uid] for _uid in uids]


# --------------------------------------------------------------------------
#
def filter(self, etype=None, uid=None, state=None, event=None, time=None,
inplace=True):
def filter(self, etype=None, uid=None, name=None,
state=None, event=None, time=None, inplace=True):

uids = self._apply_filter(etype=etype, uid=uid, state=state,
event=event, time=time)
uids = self._apply_filter(etype=etype, uid=uid, name=name,
state=state, event=event, time=time)

if inplace:
# filter our own entity list, and refresh the entity based on
Expand Down
1 change: 1 addition & 0 deletions src/radical/analytics/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pandas as pd
import numpy as np
import matplotlib as mpl

import radical.utils as ru


Expand Down

0 comments on commit 8adea0c

Please sign in to comment.