Skip to content

Commit

Permalink
Pylint updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Nilsson committed Nov 1, 2024
1 parent f495201 commit fc76bce
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pilot/user/sphenix/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@
# under the License.
#
# Authors:
# - Paul Nilsson, [email protected], 2020-2024
# - Paul Nilsson, [email protected], 2020-24

from typing import Any
import logging

from pilot.info.jobdata import JobData
from pilot.util.container import execute

import logging
logger = logging.getLogger(__name__)


def get_core_count(job: Any) -> int:
def get_core_count(job: JobData) -> int:
"""
Return the core count.
:param job: job object (Any)
:param job: job object (JobData)
:return: core count (int).
"""
if not job: # to bypass pylint warning
pass

return 0


Expand All @@ -46,6 +50,7 @@ def add_core_count(corecount: int, core_counts: list = None) -> list:
"""
if core_counts is None:
core_counts = []

return core_counts.append(corecount)


Expand All @@ -58,11 +63,11 @@ def set_core_counts(**kwargs):
job = kwargs.get('job', None)
if job and job.pgrp:
cmd = f"ps axo pgid,psr | sort | grep {job.pgrp} | uniq | awk '{{print $1}}' | grep -x {job.pgrp} | wc -l"
exit_code, stdout, stderr = execute(cmd, mute=True)
_, stdout, _ = execute(cmd, mute=True)
logger.debug(f'{cmd}: {stdout}')
try:
job.actualcorecount = int(stdout)
except Exception as e:
except (ValueError, TypeError) as e:
logger.warning(f'failed to convert number of actual cores to int: {e}')
else:
logger.debug(f'set number of actual cores to: {job.actualcorecount}')
Expand Down

0 comments on commit fc76bce

Please sign in to comment.