-
Notifications
You must be signed in to change notification settings - Fork 298
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
Add memray plugin #2875
Add memray plugin #2875
Conversation
875779e
to
5ed181e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2875 +/- ##
==========================================
- Coverage 45.53% 43.89% -1.65%
==========================================
Files 196 199 +3
Lines 20418 20820 +402
Branches 2647 2676 +29
==========================================
- Hits 9298 9138 -160
- Misses 10658 11448 +790
+ Partials 462 234 -228 ☔ View full report in Codecov by Sentry. |
b2c7770
to
8e67334
Compare
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 wicked cool!
Can you add flytekit-memray
to https://github.com/flyteorg/flytekit/blob/master/.github/workflows/pythonbuild.yml#L319-L364 ?
✅ |
plugins/flytekit-memray/README.md
Outdated
image = ImageSpec( | ||
name="memray_demo", | ||
packages=["flytekitplugins_memray"], | ||
env={"PYTHONMALLOC": "malloc"}, |
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.
Instead of hard coding this into the environment, can we now trace_python_allocators=True
?
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 tested that and its not throwing any warnings but the results look different though:
Thats the task I tested without having the env variable set:
@task(container_image=image, enable_deck=True)
@memray_profiling(trace_python_allocators=True, memray_reporter_args=["--leaks"])
def memory_leakage(n: int) -> str:
generate_data(n=n)
return "Well"
Not sure if this is expected
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.
For completeness, what do you see when you set trace_python_allocators=False
?
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.
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 weird that it gives two different flamegraphs. The new flamegraph makes more sense to me because the tracker is wrapping the user code and you can clearly see the generete_data
.
I can not really see where the generate_data
is on your original flamegraph.
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.
@task(enable_deck=True) | ||
@memray_profiling |
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.
Not actionable for this PR I wish there was a way to ensure that enable_deck=True
when using memray_profiling
. Otherwise, we just add overhead without any reports.
@eapolinario @pingsutw What do you think of making deck_fields=None
and set enable_decks=True
?
https://github.com/flyteorg/flytekit/blob/master/flytekit/core/task.py#L203-L210
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.
What if we added a way to carry over task kwargs from successive flytekit decorators? Something like #2911.
573d98c
to
a5007f3
Compare
.. currentmodule:: flytekitplugins.wandb | ||
|
||
This package contains things that are useful when extending Flytekit. | ||
|
||
.. autosummary:: | ||
:template: custom.rst | ||
:toctree: generated/ | ||
|
||
wandb_init |
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.
replace mentions to wandb
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.
What exactly is supposed to be in this comment section of __init__.py
?
I planned to just get rid of it actually?
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 exposed as the landing page for the plugin in the docs, e.g. https://docs.flyte.org/en/latest/api/flytekit/plugins/wandb.html
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.
In fact, in order to show this new plugin in https://docs.flyte.org/en/latest/api/flytekit/plugins/index.html we need to update the index and add the corresponding file under like the one for wandb.
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.
Good catch - updated!
edit: uargh, looks like changes in flytesnacks and flyte are necessary to get the mondocs build to succeed- will follow up
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.
Removed adding docs from this PR, since we need a published version of thi plugin on pypi to continue with the process of adding docs to flytesnacks & flyte. Will follow up with docs as soon this is merged.
Ok with you @eapolinario & can you please have a last review if times allows
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
This reverts commit 621756e. Signed-off-by: Jan Fiedler <[email protected]>
1477ee5
to
a820916
Compare
Signed-off-by: Jan Fiedler <[email protected]>
* wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * rename memray_profiling Signed-off-by: Jan Fiedler <[email protected]> * finish readme Signed-off-by: Jan Fiedler <[email protected]> * adjust memray_reporter_args type Signed-off-by: Jan Fiedler <[email protected]> * ruff check --fix Signed-off-by: Jan Fiedler <[email protected]> * ruff format Signed-off-by: Jan Fiedler <[email protected]> * codespell Signed-off-by: Jan Fiedler <[email protected]> * add flytekit-memray to pythonbuild workflows Signed-off-by: Jan Fiedler <[email protected]> * allow memray.Tracker arguments in profiling Signed-off-by: Jan Fiedler <[email protected]> * extend memray_profiling args description Signed-off-by: Jan Fiedler <[email protected]> * spelling Signed-off-by: Jan Fiedler <[email protected]> * move tests Signed-off-by: Jan Fiedler <[email protected]> * move tests again 🤡 Signed-off-by: Jan Fiedler <[email protected]> * adjust README.md to not use PYMALLOC env variable Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * add import sys Signed-off-by: Jan Fiedler <[email protected]> * adjust memray __init__.py Signed-off-by: Jan Fiedler <[email protected]> * plugin docs Signed-off-by: Jan Fiedler <[email protected]> * Revert "plugin docs" This reverts commit 621756e. Signed-off-by: Jan Fiedler <[email protected]> * support from python 3.9 Signed-off-by: Jan Fiedler <[email protected]> --------- Signed-off-by: Jan Fiedler <[email protected]> Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Katrina Rogan <[email protected]>
* wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * wip Signed-off-by: Jan Fiedler <[email protected]> * rename memray_profiling Signed-off-by: Jan Fiedler <[email protected]> * finish readme Signed-off-by: Jan Fiedler <[email protected]> * adjust memray_reporter_args type Signed-off-by: Jan Fiedler <[email protected]> * ruff check --fix Signed-off-by: Jan Fiedler <[email protected]> * ruff format Signed-off-by: Jan Fiedler <[email protected]> * codespell Signed-off-by: Jan Fiedler <[email protected]> * add flytekit-memray to pythonbuild workflows Signed-off-by: Jan Fiedler <[email protected]> * allow memray.Tracker arguments in profiling Signed-off-by: Jan Fiedler <[email protected]> * extend memray_profiling args description Signed-off-by: Jan Fiedler <[email protected]> * spelling Signed-off-by: Jan Fiedler <[email protected]> * move tests Signed-off-by: Jan Fiedler <[email protected]> * move tests again 🤡 Signed-off-by: Jan Fiedler <[email protected]> * adjust README.md to not use PYMALLOC env variable Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * Update plugins/flytekit-memray/flytekitplugins/memray/profiling.py Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: Jan Fiedler <[email protected]> * add import sys Signed-off-by: Jan Fiedler <[email protected]> * adjust memray __init__.py Signed-off-by: Jan Fiedler <[email protected]> * plugin docs Signed-off-by: Jan Fiedler <[email protected]> * Revert "plugin docs" This reverts commit 621756e. Signed-off-by: Jan Fiedler <[email protected]> * support from python 3.9 Signed-off-by: Jan Fiedler <[email protected]> --------- Signed-off-by: Jan Fiedler <[email protected]> Co-authored-by: Thomas J. Fan <[email protected]> Signed-off-by: 400Ping <[email protected]>
Why are the changes needed?
What changes were proposed in this pull request?
How was this patch tested?
Setup process
Screenshots
Flamegraph
Table
Check all the applicable boxes
Related PRs
Docs link