Closed micheleAlberto closed 5 months ago
@micheleAlberto Would you mind updating your commit to include a Signed-off-by
? See https://github.com/bloomberg/memray/blob/main/CONTRIBUTING.md#contribution-licensing
Since this is multiple commits, the easiest way to do that would be using a git rebase -i
against the main branch and then doing reword
for each commit to add the Signed-off-by
line.
Attention: Patch coverage is 71.42857%
with 6 lines
in your changes are missing coverage. Please review.
Project coverage is 92.96%. Comparing base (
41248ed
) to head (7ff82f7
). Report is 79 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
src/memray/commands/protocol.py | 60.00% | 4 Missing :warning: |
src/memray/commands/run.py | 81.81% | 2 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thank you for the work you put in here, @micheleAlberto, but after some reflection, I've decided against going ahead with this approach.
The risk that this approach introduces is that, because the set of reporters to be exposed in any given environment is determined implicitly by whether they can be successfully imported, we might introduce a new dependency on a library that's not guaranteed to be installed, and accidentally trigger the removal of a reporter that we meant to include in our default set. This case isn't as far fetched as it might seem, and some of these dependencies are quite subtle. For instance, memray summary
can't be imported unless Textual is installed. This isn't because it uses Textual, but rather because it imports a single function from memray.reporters.tui
, to avoid duplication, which causes textual
to be imported. The fix for that is factoring the function that needs to be shared into a common module that both memray.reporters.tui
and memray.reporters.summary
can depend upon, but just ignoring every module that can't be imported would lead to us not identifying problems like that, and potentially cause regressions if similar problems are introduced in the future.
Going further, another problem with making detection of optional libraries implicit rather than explicit is that we don't have a good way to notify the user of the missing dependency. I think what we want is for memray tree
to be present in the --help
and runnable from the CLI, but to emit a message if it's run explaining that it needs Textual to work, and explaining how to go about installing that dependency. But, emitting that message is only doable if we know what package to tell the user to install: we need to know that memray tree
depends on Textual but memray flamegraph
depends on Jinja2 to emit the right error message for each.
I do appreciate the work that you put in here, and it's certainly helped me solidify my understanding of the problem and what a solution needs to look like, but I don't think it's a good starting point to get to the best solution.
Sorry!
Issue number of the reported bug or feature request: #557
Describe your changes This PR allows the
memray
cli to run with a reduced set of dependencies. The cli will only list commands that are supported by installed packages and ignore the commands that require additional packages.Testing performed without textual
results in
without jinja2
results in
without jinja2 and textual
results in
Additional context Add any other context about your contribution here.