|
31 | 31 | from functools import partial |
32 | 32 | from dataclasses import dataclass |
33 | 33 |
|
34 | | -from cylc.flow.network.client_factory import get_client |
35 | | -from cylc.flow.option_parsers import CylcOptionParser as COP |
| 34 | +from cylc.flow.exceptions import CylcError |
36 | 35 | from cylc.flow.terminal import cli_function |
| 36 | +from cylc.flow.option_parsers import CylcOptionParser as COP |
| 37 | +from cylc.flow.network.client_factory import get_client |
37 | 38 |
|
38 | 39 |
|
39 | 40 | PID_REGEX = re.compile(r"([^:]*\d{6,}.*)") |
@@ -117,6 +118,8 @@ def parse_memory_file(process: Process): |
117 | 118 | if "total_rss" in line: |
118 | 119 | return int(''.join(filter(str.isdigit, line))) |
119 | 120 |
|
| 121 | + raise CylcError("Unable to find memory usage data") |
| 122 | + |
120 | 123 |
|
121 | 124 | def parse_memory_allocated(process: Process) -> int: |
122 | 125 | """Open the memory stat file and copy the appropriate data""" |
@@ -148,7 +151,7 @@ def parse_cpu_file(process: Process) -> int: |
148 | 151 | # Cgroups v1 uses nanoseconds |
149 | 152 | return int(line) // 1000000 |
150 | 153 |
|
151 | | - raise ValueError("Unable to find cpu usage data") |
| 154 | + raise CylcError("Unable to find cpu usage data") |
152 | 155 |
|
153 | 156 |
|
154 | 157 | def get_cgroup_version(cgroup_location: str, cgroup_name: str) -> int: |
@@ -177,8 +180,8 @@ def get_cgroup_name(): |
177 | 180 | result = PID_REGEX.search(result).group() |
178 | 181 | return result |
179 | 182 | except FileNotFoundError as err: |
180 | | - raise FileNotFoundError( |
181 | | - '/proc/' + str(pid) + '/cgroup not found') from err |
| 183 | + raise CylcError( |
| 184 | + '/proc/' + str(pid) + '/cgroup not found') from None |
182 | 185 |
|
183 | 186 | except AttributeError as err: |
184 | 187 | raise AttributeError("No cgroup found for process:", pid) from err |
@@ -206,7 +209,7 @@ def get_cgroup_paths(location) -> Process: |
206 | 209 | memory_allocated_path="", |
207 | 210 | cgroup_version=cgroup_version, |
208 | 211 | ) |
209 | | - raise ValueError("Unable to determine cgroup version") |
| 212 | + raise CylcError("Unable to determine cgroup version") |
210 | 213 |
|
211 | 214 |
|
212 | 215 | def profile(_process: Process, delay, keep_looping=lambda: True): |
|
0 commit comments