From 6ffe38d1740294a7170765ab875b363f4ae82cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Fri, 26 Nov 2021 10:49:06 +0100 Subject: [PATCH] docs: move psutil import into benchmark methods to avoid needing it as a dependency for doc building --- docs/requirements.txt | 3 +-- snakemake/benchmark.py | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 26c5fac61..d1abb074d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,5 +5,4 @@ sphinx_rtd_theme docutils myst-parser configargparse -appdirs -psutil \ No newline at end of file +appdirs \ No newline at end of file diff --git a/snakemake/benchmark.py b/snakemake/benchmark.py index 0e47905bf..b59c2a4ca 100644 --- a/snakemake/benchmark.py +++ b/snakemake/benchmark.py @@ -11,8 +11,6 @@ import time import threading -import psutil - from snakemake.exceptions import WorkflowError @@ -192,6 +190,7 @@ class BenchmarkTimer(ScheduledPeriodicTimer): """Allows easy observation of a given PID for resource usage""" def __init__(self, pid, bench_record, interval=BENCHMARK_INTERVAL): + import psutil ScheduledPeriodicTimer.__init__(self, interval) #: PID of observed process self.pid = pid @@ -203,6 +202,7 @@ def __init__(self, pid, bench_record, interval=BENCHMARK_INTERVAL): def work(self): """Write statistics""" + import psutil try: self._update_record() except psutil.NoSuchProcess: @@ -212,6 +212,7 @@ def work(self): def _update_record(self): """Perform the actual measurement""" + import psutil # Memory measurements rss, vms, uss, pss = 0, 0, 0, 0 # I/O measurements