Skip to content
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

Merged
merged 6 commits into from
Oct 2, 2020

Conversation

mfitton
Copy link
Contributor

@mfitton mfitton commented Sep 24, 2020

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

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Memory utils is unit tested. There are integration tests in the PR with the meat of the memory view / logical view logic.

@mfitton mfitton added the dashboard Issues specific to the Ray Dashboard label Sep 24, 2020
@mfitton mfitton added this to the New Dashboard milestone Sep 24, 2020
else:
return False

def __dict__(self):
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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!

Copy link
Contributor Author

@mfitton mfitton Sep 29, 2020

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.

self.table.sort(key=lambda entry: entry.reference_type)
else:
raise ValueError(
"Give sorting type: {} is invalid.".format(sorting_type))
Copy link
Contributor

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.

return self.call_site
else:
raise ValueError(
"group by type {} is invalid.".format(group_by_type))
Copy link
Contributor

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)
Copy link
Contributor

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(...)?

Copy link
Contributor Author

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.

Copy link
Contributor

@rkooo567 rkooo567 left a 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?

else:
return False

def __dict__(self):
Copy link
Contributor

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.

else:
return False

def __dict__(self):
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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 rkooo567 added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Sep 25, 2020
@mfitton
Copy link
Contributor Author

mfitton commented Sep 29, 2020

@rkooo567 correct, this PR just adds some utility files that get used by the logical view and memory view in another PR.

@mfitton mfitton removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Sep 29, 2020
@rkooo567 rkooo567 merged commit 9a6d01e into ray-project:master Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard Issues specific to the Ray Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants