Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/plasma-umass/scalene
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Oct 31, 2024
2 parents f9419a9 + ad5373f commit 3ffdd68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scalene/scalene_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def strip_magic_line(source: str) -> str:
# The above line will fail if not running in a notebook,
# in which case we return the original source unchanged.
# Regular expression to match and replace magic commands with comments
source = re.sub(r'(^\s*)%{1,2}', r'\1#', source, flags=re.MULTILINE)
source = re.sub(r'(^\s*)%{1,2}(\w+)', r'\1# \2', source, flags=re.MULTILINE)
finally:
return source

4 changes: 2 additions & 2 deletions scalene/scalene_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class FunctionDetail(BaseModel):

@model_validator(mode="after")
def check_cpu_percentages(cls, values):
total_cpu_usage = math.ceil(
total_cpu_usage = math.floor(
values.n_cpu_percent_c
+ values.n_cpu_percent_python
+ values.n_sys_percent
)
if total_cpu_usage > 100:
raise ValueError(
f"The sum of n_cpu_percent_c, n_cpu_percent_python, and n_sys_percent must be < 100 but is {total_cpu_usage}"
f"The sum of n_cpu_percent_c, n_cpu_percent_python, and n_sys_percent must be <= 100 but is {total_cpu_usage}"
)
return values

Expand Down

0 comments on commit 3ffdd68

Please sign in to comment.