-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from PanDAWMS/next
3.5.1.17
- Loading branch information
Showing
12 changed files
with
162 additions
and
41 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 |
---|---|---|
@@ -1 +1 @@ | ||
3.5.0.31 | ||
3.5.1.17 |
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Authors: | ||
# - Paul Nilsson, [email protected], 2021 | ||
# - Paul Nilsson, [email protected], 2021-2023 | ||
# - Shuwei | ||
|
||
import os | ||
|
@@ -18,7 +18,10 @@ | |
try: | ||
from google.cloud import storage | ||
except Exception: | ||
pass | ||
storage_client = storage.Client() | ||
else: | ||
storage_client = None | ||
|
||
try: | ||
import pathlib # Python 3 | ||
except Exception: | ||
|
@@ -127,10 +130,9 @@ def download_file(path, surl, object_name=None): | |
object_name = os.path.basename(path) | ||
|
||
try: | ||
client = storage.Client() | ||
target = pathlib.Path(object_name) | ||
with target.open(mode="wb") as downloaded_file: | ||
client.download_blob_to_file(surl, downloaded_file) | ||
storage_client.download_blob_to_file(surl, downloaded_file) | ||
except Exception as error: | ||
diagnostics = 'exception caught in gs client: %s' % error | ||
logger.critical(diagnostics) | ||
|
@@ -234,8 +236,7 @@ def upload_file(file_name, bucket, object_name=None, content_type=None): | |
|
||
# upload the file | ||
try: | ||
client = storage.Client() | ||
gs_bucket = client.get_bucket(bucket) | ||
gs_bucket = storage_client.get_bucket(bucket) | ||
# remove any leading slash(es) in object_name | ||
object_name = object_name.lstrip('/') | ||
logger.info('uploading a file to bucket=%s in full path=%s in content_type=%s', bucket, object_name, content_type) | ||
|
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
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
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
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Authors: | ||
# - Paul Nilsson, [email protected], 2018-2022 | ||
# - Paul Nilsson, [email protected], 2018-2023 | ||
|
||
from os import environ | ||
|
||
|
@@ -16,7 +16,7 @@ | |
def get_job_metrics_entry(name, value): | ||
""" | ||
Get a formatted job metrics entry. | ||
Return a a job metrics substring with the format 'name=value ' (return empty entry if value is not set). | ||
Return a job metrics substring with the format 'name=value ' (return empty entry if value is not set). | ||
:param name: job metrics parameter name (string). | ||
:param value: job metrics parameter value (string). | ||
|
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
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 |
---|---|---|
|
@@ -5,11 +5,12 @@ | |
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Authors: | ||
# - Paul Nilsson, [email protected], 2017-2022 | ||
# - Paul Nilsson, [email protected], 2017-2023 | ||
|
||
import os | ||
import re | ||
import logging | ||
from shutil import which | ||
|
||
#from subprocess import getoutput | ||
|
||
|
@@ -253,6 +254,27 @@ def get_cpu_model(): | |
return modelstring | ||
|
||
|
||
def lscpu(): | ||
""" | ||
Execute lscpu command. | ||
:return: exit code (int), stdout (string). | ||
""" | ||
|
||
cmd = 'lscpu' | ||
if not which(cmd): | ||
logger.warning('command={cmd} does not exist - cannot check number of available cores') | ||
return 1, "" | ||
|
||
ec, stdout, _ = execute(cmd) | ||
if isinstance(stdout, bytes): | ||
stdout = stdout.decode("utf-8") | ||
|
||
logger.debug(f'lscpu:\n{stdout}') | ||
|
||
return ec, stdout | ||
|
||
|
||
def get_cpu_cores(modelstring): | ||
""" | ||
Get core count from /proc/cpuinfo and update modelstring (CPU model). | ||
|
@@ -263,29 +285,51 @@ def get_cpu_cores(modelstring): | |
""" | ||
|
||
number_of_cores = 0 | ||
re_cores = re.compile(r'^cpu cores\s+:\s+(\d+)') | ||
|
||
with open("/proc/cpuinfo", "r") as _fp: | ||
ec, stdout = lscpu() | ||
if ec: | ||
return modelstring | ||
|
||
# loop over all lines in cpuinfo | ||
for line in _fp.readlines(): | ||
cores_per_socket = 0 | ||
sockets = 0 | ||
for line in stdout.split('\n'): | ||
|
||
# try to grab core count from current line | ||
cores = re_cores.search(line) | ||
if cores: | ||
# found core count | ||
try: | ||
number_of_cores += int(cores.group(1)) | ||
except Exception: | ||
pass | ||
|
||
if number_of_cores > 0 and '-Core' not in modelstring: | ||
if 'Core Processor' in modelstring: | ||
modelstring = modelstring.replace('Core', '%d-Core' % number_of_cores) | ||
elif 'Processor' in modelstring: | ||
modelstring = modelstring.replace('Processor', '%d-Core Processor' % number_of_cores) | ||
else: | ||
modelstring += ' %d-Core Processor' | ||
try: | ||
pattern = r'Core\(s\)\ per\ socket\:\ +(\d+)' | ||
_cores = re.findall(pattern, line) | ||
if _cores: | ||
cores_per_socket = int(_cores[0]) | ||
continue | ||
except Exception as exc: | ||
logger.warning(f'exception caught: {exc}') | ||
|
||
try: | ||
pattern = r'Socket\(s\)\:\ +(\d+)' | ||
_sockets = re.findall(pattern, line) | ||
if _sockets: | ||
sockets = int(_sockets[0]) | ||
break | ||
except Exception as exc: | ||
logger.warning(f'exception caught: {exc}') | ||
|
||
if cores_per_socket and sockets: | ||
number_of_cores = cores_per_socket * sockets | ||
logger.info(f'found {number_of_cores} cores ({cores_per_socket} cores per socket, {sockets} sockets)') | ||
|
||
logger.debug(f'current model string: {modelstring}') | ||
if number_of_cores > 0 and '-Core' not in modelstring: | ||
if '-Core Processor' in modelstring: # NN-Core info already in string - update it | ||
pattern = r'(\d+)\-Core Processor' | ||
_nn = re.findall(pattern, modelstring) | ||
if _nn: | ||
modelstring = modelstring.replace(f'{_nn[0]}-Core', f'{number_of_cores}-Core') | ||
if 'Core Processor' in modelstring: | ||
modelstring = modelstring.replace('Core', '%d-Core' % number_of_cores) | ||
elif 'Processor' in modelstring: | ||
modelstring = modelstring.replace('Processor', '%d-Core Processor' % number_of_cores) | ||
else: | ||
modelstring += ' %d-Core Processor' % number_of_cores | ||
logger.debug(f'updated model string: {modelstring}') | ||
|
||
return modelstring | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# config file for pypi | ||
[metadata] | ||
description-file = README.md |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# | ||
# Authors: | ||
# - Fernando Barreiro Megino, [email protected], 2019 | ||
# - Paul Nilsson, [email protected], 2019-2021 | ||
# - Paul Nilsson, [email protected], 2019-2023 | ||
import sys | ||
|
||
from setuptools import setup, find_packages | ||
|
@@ -26,10 +26,11 @@ | |
author='PanDA Team', | ||
author_email='[email protected]', | ||
url='https://github.com/PanDAWMS/pilot3/wiki', | ||
python_requires='>=2.7', | ||
python_requires='>=3.6', | ||
packages=find_packages(), | ||
install_requires=[], | ||
data_files=[], | ||
package_data={'': ['PILOTVERSION']}, | ||
include_package_data=True, | ||
scripts=['pilot.py'] | ||
scripts=[] | ||
) |