forked from PanDAWMS/pilot3
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Nilsson
committed
Nov 1, 2024
1 parent
f495201
commit fc76bce
Showing
1 changed file
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
||
|
@@ -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) | ||
|
||
|
||
|
@@ -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}') | ||
|