-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard] Add utility functions for actor and memory APIs #11011
[Dashboard] Add utility functions for actor and memory APIs #11011
Conversation
…w and memory view APIs
…hot-reloading local dev environment.
dashboard/memory_utils.py
Outdated
else: | ||
return False | ||
|
||
def __dict__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a Python's magic method? If not, it's better to rename it to as_dict
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a magic method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as_dict is also fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, I can't find the official document for the __dict__
method. I know there is a __dict__
special attribute, it's not a method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are right. I've searched about it, and it was not the magic method :o
I didn't know about this so far... We should change to as_dict
. Thanks for caching this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, __dict__
returns the Python object's attributes as a dict. Good catch, I'll rename it.
dashboard/memory_utils.py
Outdated
self.table.sort(key=lambda entry: entry.reference_type) | ||
else: | ||
raise ValueError( | ||
"Give sorting type: {} is invalid.".format(sorting_type)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use fstring.
dashboard/memory_utils.py
Outdated
return self.call_site | ||
else: | ||
raise ValueError( | ||
"group by type {} is invalid.".format(group_by_type)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use fstring.
This will sort entries first and gruop them after. | ||
Sort order will be still kept. | ||
""" | ||
self._sort_by(sort_by_type)._group_by(group_by_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the self._sort_by(...)._group_by(...)
equals with self._group_by(...)._sort_by(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not equal, which I agree is somewhat confusing. That said, it is sorted before grouped in all code paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR doesn't actually seem to add memory dashboard functionalities to the new dashboard?
dashboard/memory_utils.py
Outdated
else: | ||
return False | ||
|
||
def __dict__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a magic method.
dashboard/memory_utils.py
Outdated
else: | ||
return False | ||
|
||
def __dict__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think as_dict is also fine though.
for actor in actors.values(): | ||
actor_class = actor["actorClass"] | ||
groups[actor_class].append(actor) | ||
return dict(groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't groups already dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No groups is a defaultdict.
@rkooo567 correct, this PR just adds some utility files that get used by the logical view and memory view in another PR. |
Why are these changes needed?
There are several utility classes / functions leaned upon by the Memory and Logical View APIs. This introduces the utility modules.
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.Memory utils is unit tested. There are integration tests in the PR with the meat of the memory view / logical view logic.