Without this patch, the 'sanity-check phase fails because loading the debug_utils.py module triggers command-line parsing. Taken from: . diff --git a/ddsmt/debug_utils.py b/ddsmt/debug_utils.py index 7c44971..6cacfe2 100644 --- a/ddsmt/debug_utils.py +++ b/ddsmt/debug_utils.py @@ -53,30 +53,30 @@ class Profiler: function, this argument should never be set to True. """ - enabled = options.args().profile + enabled = lambda: options.args().profile # static profiler, global within one process profiler = None def __init__(self, is_main=False): """Create a profiler.""" - if Profiler.enabled: + if Profiler.enabled(): if multiprocessing.parent_process() is None: - self.enabled = True + self.enabled = lambda: True self.filename = '.profile.prof' else: - self.enabled = True + self.enabled = lambda: True self.filename = f'.profile-{os.getpid()}.prof' if Profiler.profiler is None: Profiler.profiler = cProfile.Profile() def __enter__(self): """Start profiling, if ``--profile`` was given.""" - if Profiler.enabled and self.enabled: + if Profiler.enabled() and self.enabled(): Profiler.profiler.enable() def __exit__(self, type, value, traceback): """Stop profiling and write results to file.""" - if Profiler.enabled and self.enabled: + if Profiler.enabled() and self.enabled(): try: Profiler.profiler.disable() Profiler.profiler.dump_stats(self.filename)