Skip to content

Commit

Permalink
Substitute more references to the old package name
Browse files Browse the repository at this point in the history
There are a bunch of references that we missed to the old package name
in class names, strings, errors and other places.
  • Loading branch information
pablogsal committed Apr 12, 2022
1 parent d191b5d commit 581f6dc
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 53 deletions.
2 changes: 1 addition & 1 deletion docs/_static/flamegraphs/memray-flamegraph-mandelbrot.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h5 class="modal-title" id="memoryModalLabel">Resident set size over time</h5>
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="statsModalLabel">Pensieve run stats</h5>
<h5 class="modal-title" id="statsModalLabel">Memray run stats</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)


class BuildPensieve(build_ext_orig):
class BuildMemray(build_ext_orig):
def run(self):
self.build_js_files()
self.build_libbacktrace()
Expand Down Expand Up @@ -154,7 +154,7 @@ def build_js_files(self):

DEFINE_MACROS = []

# memray uses thread local storage (TLS) variables. As pensieve is compiled
# memray uses thread local storage (TLS) variables. As memray is compiled
# into a Python extension, is a shared object. TLS variables in shared objects
# use the most conservative and slow TLS model available by default:
# global-dynamic. This TLS model generates function calls (__tls_get_addr) to
Expand Down Expand Up @@ -259,7 +259,7 @@ def build_js_files(self):
],
},
cmdclass={
"build_ext": BuildPensieve,
"build_ext": BuildMemray,
},
package_data={"memray": ["py.typed"]},
)
4 changes: 2 additions & 2 deletions src/memray/_errors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any


class PensieveError(Exception):
class MemrayError(Exception):
"""Exceptions raised in this package."""


class PensieveCommandError(PensieveError):
class MemrayCommandError(MemrayError):
"""Exceptions raised from this package's CLI commands."""

def __init__(self, *args: Any, exit_code: int) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/memray/_memray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def size_fmt(num, suffix='B'):
num /= 1024.0
return f"{num:.1f}Y{suffix}"

# Pensieve core
# Memray core

PYTHON_VERSION = (sys.version_info.major, sys.version_info.minor)

Expand Down
5 changes: 3 additions & 2 deletions src/memray/_memray/elf_shenanigans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ patch_symbols(const Dyn* dyn_info_struct, const Addr base, bool restore_original
JmpRelaTable jmp_relocations_table(dyn_info_struct);
overwrite_elf_table(jmp_relocations_table, symbols, base, restore_original);
} break;
default:
LOG(ERROR) << "Unknown JMPRELS relocation table type";
default: {
LOG(DEBUG) << "Unknown JMPRELS relocation table type";
} break;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/memray/_memray/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

namespace memray::exception {

class PensieveException : public std::runtime_error
class MemrayException : public std::runtime_error
{
using std::runtime_error::runtime_error;
};

class IoError : public PensieveException
class IoError : public MemrayException
{
using PensieveException::PensieveException;
using MemrayException::MemrayException;
};

} // namespace memray::exception
12 changes: 6 additions & 6 deletions src/memray/_memray/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ static int LOG_THRESHOLD = static_cast<int>(logLevel::WARNING);
static const char*
prefixFromLogLevel(int level)
{
if (level >= CRITICAL) return "Pensieve CRITICAL: ";
if (level >= ERROR) return "Pensieve ERROR: ";
if (level >= WARNING) return "Pensieve WARNING: ";
if (level >= INFO) return "Pensieve INFO: ";
if (level >= DEBUG) return "Pensieve DEBUG: ";
return "Pensieve TRACE: ";
if (level >= CRITICAL) return "Memray CRITICAL: ";
if (level >= ERROR) return "Memray ERROR: ";
if (level >= WARNING) return "Memray WARNING: ";
if (level >= INFO) return "Memray INFO: ";
if (level >= DEBUG) return "Memray DEBUG: ";
return "Memray TRACE: ";
}

void
Expand Down
8 changes: 4 additions & 4 deletions src/memray/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
except ImportError:
from typing_extensions import Protocol # type: ignore

from memray._errors import PensieveCommandError
from memray._errors import PensieveError
from memray._errors import MemrayCommandError
from memray._errors import MemrayError
from memray._memray import set_log_level

from . import flamegraph
Expand Down Expand Up @@ -122,10 +122,10 @@ def main(args: Optional[List[str]] = None) -> int:

try:
arg_values.entrypoint(arg_values, parser)
except PensieveCommandError as e:
except MemrayCommandError as e:
print(e, file=sys.stderr)
return e.exit_code
except PensieveError as e:
except MemrayError as e:
print(e, file=sys.stderr)
return 1
else:
Expand Down
8 changes: 4 additions & 4 deletions src/memray/commands/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from memray import AllocationRecord
from memray import FileReader
from memray import MemoryRecord
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray.reporters import BaseReporter


Expand Down Expand Up @@ -51,15 +51,15 @@ def validate_filenames(
"""Ensure that the filenames provided by the user are usable."""
result_path = Path(results)
if not result_path.exists() or not result_path.is_file():
raise PensieveCommandError(f"No such file: {results}", exit_code=1)
raise MemrayCommandError(f"No such file: {results}", exit_code=1)

output_file = Path(
output
if output is not None
else self.determine_output_filename(result_path)
)
if not exist_ok and output_file.exists():
raise PensieveCommandError(
raise MemrayCommandError(
f"File already exists, will not overwrite: {output_file}",
exit_code=1,
)
Expand Down Expand Up @@ -89,7 +89,7 @@ def write_report(
native_traces=reader.has_native_traces,
)
except OSError as e:
raise PensieveCommandError(
raise MemrayCommandError(
f"Failed to parse allocation records in {result_path}\nReason: {e}",
exit_code=1,
)
Expand Down
4 changes: 2 additions & 2 deletions src/memray/commands/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rich.live import Live

from memray import SocketReader
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray.reporters.tui import TUI

KEYS = {
Expand Down Expand Up @@ -88,7 +88,7 @@ def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None

def start_live_interface(self, port: int) -> None:
if port >= 2**16 or port <= 0:
raise PensieveCommandError(f"Invalid port: {port}", exit_code=1)
raise MemrayCommandError(f"Invalid port: {port}", exit_code=1)
with SocketReader(port=port) as reader:
tui = TUI(reader.pid, reader.command_line, reader.has_native_traces)

Expand Down
6 changes: 3 additions & 3 deletions src/memray/commands/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

from memray import dump_all_records
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError


class ParseCommand:
Expand All @@ -13,15 +13,15 @@ def prepare_parser(self, parser: argparse.ArgumentParser) -> None:

def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None:
if os.isatty(1):
raise PensieveCommandError(
raise MemrayCommandError(
"You must redirect stdout to a file or shell pipeline.",
exit_code=1,
)

try:
dump_all_records(args.results)
except OSError as e:
raise PensieveCommandError(
raise MemrayCommandError(
f"Failed to parse allocation records in {args.results}\nReason: {e}",
exit_code=1,
)
14 changes: 7 additions & 7 deletions src/memray/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from memray import FileDestination
from memray import SocketDestination
from memray import Tracker
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray.commands.live import LiveCommand


Expand All @@ -43,7 +43,7 @@ def _run_tracker(
kwargs["follow_fork"] = True
tracker = Tracker(destination=destination, native_traces=args.native, **kwargs)
except OSError as error:
raise PensieveCommandError(str(error), exit_code=1)
raise MemrayCommandError(str(error), exit_code=1)

with tracker:
sys.argv[1:] = args.script_args
Expand Down Expand Up @@ -81,7 +81,7 @@ def _run_child_process_and_attach(args: argparse.Namespace) -> None:
if port is None:
port = _get_free_port()
if not 2**16 > port > 0:
raise PensieveCommandError(f"Invalid port: {port}", exit_code=1)
raise MemrayCommandError(f"Invalid port: {port}", exit_code=1)

arguments = (
f"{port},{args.native},{args.run_as_module},{args.quiet},"
Expand Down Expand Up @@ -109,15 +109,15 @@ def _run_child_process_and_attach(args: argparse.Namespace) -> None:
if process.returncode:
if process.stderr:
print(process.stderr.read(), file=sys.stderr)
raise (PensieveCommandError(exit_code=process.returncode))
raise (MemrayCommandError(exit_code=process.returncode))


def _run_with_socket_output(args: argparse.Namespace) -> None:
port = args.live_port
if port is None:
port = _get_free_port()
if not 2**16 > port > 0:
raise PensieveCommandError(f"Invalid port: {port}", exit_code=1)
raise MemrayCommandError(f"Invalid port: {port}", exit_code=1)

if not args.quiet:
memray_cli = f"memray{sys.version_info.major}.{sys.version_info.minor}"
Expand Down Expand Up @@ -156,7 +156,7 @@ def _run_with_file_output(args: argparse.Namespace) -> None:
follow_fork=args.follow_fork,
)
except OSError as error:
raise PensieveCommandError(str(error), exit_code=1)
raise MemrayCommandError(str(error), exit_code=1)


class RunCommand:
Expand Down Expand Up @@ -240,7 +240,7 @@ def validate_target_file(self, args: argparse.Namespace) -> None:
source = pathlib.Path(args.script).read_bytes()
ast.parse(source)
except (SyntaxError, ValueError):
raise PensieveCommandError(
raise MemrayCommandError(
"Only Python files can be executed under memray", exit_code=1
)

Expand Down
6 changes: 3 additions & 3 deletions src/memray/commands/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

from memray import FileReader
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray.reporters.stats import StatsReporter


Expand Down Expand Up @@ -43,7 +43,7 @@ def valid_positive_int(value: str) -> int:
def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None:
result_path = Path(args.results)
if not result_path.exists() or not result_path.is_file():
raise PensieveCommandError(f"No such file: {args.results}", exit_code=1)
raise MemrayCommandError(f"No such file: {args.results}", exit_code=1)
reader = FileReader(os.fspath(args.results))
try:
if args.include_all_allocations:
Expand All @@ -53,7 +53,7 @@ def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None
reader.get_high_watermark_allocation_records(merge_threads=True)
)
except OSError as e:
raise PensieveCommandError(
raise MemrayCommandError(
f"Failed to parse allocation records in {result_path}\nReason: {e}",
exit_code=1,
)
Expand Down
6 changes: 3 additions & 3 deletions src/memray/commands/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

from memray import FileReader
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray.reporters.summary import SummaryReporter


Expand Down Expand Up @@ -34,14 +34,14 @@ def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None

result_path = Path(args.results)
if not result_path.exists() or not result_path.is_file():
raise PensieveCommandError(f"No such file: {args.results}", exit_code=1)
raise MemrayCommandError(f"No such file: {args.results}", exit_code=1)
reader = FileReader(os.fspath(args.results))
try:
snapshot = iter(
reader.get_high_watermark_allocation_records(merge_threads=True)
)
except OSError as e:
raise PensieveCommandError(
raise MemrayCommandError(
f"Failed to parse allocation records in {result_path}\nReason: {e}",
exit_code=1,
)
Expand Down
6 changes: 3 additions & 3 deletions src/memray/commands/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rich import print as rprint

from memray import FileReader
from memray._errors import PensieveCommandError
from memray._errors import MemrayCommandError
from memray._memray import size_fmt
from memray.reporters.tree import TreeReporter

Expand All @@ -26,7 +26,7 @@ def prepare_parser(self, parser: argparse.ArgumentParser) -> None:
def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None:
result_path = Path(args.results)
if not result_path.exists() or not result_path.is_file():
raise PensieveCommandError(f"No such file: {args.results}", exit_code=1)
raise MemrayCommandError(f"No such file: {args.results}", exit_code=1)
reader = FileReader(os.fspath(args.results))
try:
snapshot = iter(
Expand All @@ -38,7 +38,7 @@ def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None
native_traces=reader.has_native_traces,
)
except OSError as e:
raise PensieveCommandError(
raise MemrayCommandError(
f"Failed to parse allocation records in {result_path}\nReason: {e}",
exit_code=1,
)
Expand Down
2 changes: 1 addition & 1 deletion src/memray/reporters/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h5 class="modal-title" id="memoryModalLabel">Resident set size over time</h5>
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="statsModalLabel">Pensieve run stats</h5>
<h5 class="modal-title" id="statsModalLabel">Memray run stats</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Expand Down
Loading

0 comments on commit 581f6dc

Please sign in to comment.