in exec/src/klio_exec/commands/profile.py [0:0]
def _profile_memory_per_line(self, get_maximum=False):
profiler = self._get_memory_line_profiler()
decorators.ACTIVE_PROFILER = self._get_memory_line_wrapper(
profiler, get_maximum
)
# "a"ppend if output per element; "w"rite (once) for maximum.
# append will append a file with potentially already-existing data
# (i.e. from a previous run), which may be confusing; but with how
# memory_profiler treats streams, there's no simple way to prevent
# appending data for per-element without re-implementing parts of
# memory_profiler (maybe someday?) @lynn
fmode = "w" if get_maximum else "a"
with smart_open(self.output_file, fmode=fmode) as f:
self._stream = f
self._run_pipeline()
if get_maximum:
memory_profiler.show_results(profiler, stream=self._stream)