Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,6 @@ jobs:
env:
REFERENCE_BRANCH: ${{ github['base_ref'] || github['head_ref'] }}

pylint-py27:
name: Pylint for Python 2.7 in Pilot files
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/DIRAC'
steps:
- uses: actions/checkout@v4
- name: Fail-fast for outdated pipelines
run: .github/workflows/fail-fast.sh
- name: prepare environment
run: |
conda config --set add_pip_as_python_dependency false
conda create -c conda-forge -n test-env python=2.7 pylint=1.9.2 astroid=1.6.5
- name: run pilot wrapper test
run: |
eval "$(conda shell.bash hook)" && conda activate test-env
pylint -j 0 -E \
tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py \
src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py \
src/DIRAC/Resources/Computing/BatchSystems/*.py

diracx:
name: DiracX Unit Tests
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pilotWrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
fail-fast: False
matrix:
python:
- 2.7.5
- 2.7.13
- 3.6.8
- 3.11.4
pilot_branch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where:
- configure means adding dirac specific configuration files (which, at a minimum, should include the location of a DIRAC configuration service)


A pilot has to run on each and every computing resource type, provided that Python 2.6+ is on the WN.
A pilot has to run on each and every computing resource type, provided that Python 3.6+ is on the WN.
The same pilot script can be used everywhere.

.. image:: Pilots2.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Installing DIRAC client
The DIRAC client installation procedure consists of few steps.
You can do these steps as any user without the need to be root.

Python3 DIRAC installations rely on the environment provided by `DIRACOS2 <https://github.com/DIRACGrid/DIRACOS2>`_.
DIRAC installations rely on the environment provided by `DIRACOS2 <https://github.com/DIRACGrid/DIRACOS2>`_.
So, you first install DIRACOS2 and only then install DIRAC in it::

$ curl -LO https://github.com/DIRACGrid/DIRACOS2/releases/latest/download/DIRACOS-Linux-$(uname -m).sh
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,9 @@ console_scripts =
[pycodestyle]
# Pep8 codes:
# E203 - Whitespace before ':' (spaces should be present for list slices)
# E211 - Whitespace before '(' (black incorrectly formats exec when in Python 2 mode)
# E266 - Too many leading '#' for block comment
# E402 - module level import not at top of file (for scripts)
# W503 - line break before binary operator (stupid, complains after or before...)
ignore = E203, E211, E266, E402, W503
ignore = E203, E266, E402, W503
# TODO: This should be reduced back to 120 at some point
max_line_length=130
3 changes: 1 addition & 2 deletions src/DIRAC/Core/Utilities/Plotting/FileCoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def extractRequestFromFileId(fileId):
if compressType == "Z":
gLogger.info("Compressed request, uncompressing")
try:
# Encoding is only required for Python 2 and can be removed when Python 2 support is no longer needed
stub = base64.urlsafe_b64decode(stub.encode())
stub = base64.urlsafe_b64decode(stub)
except Exception as e:
gLogger.error("Oops! Plot request is not properly encoded!", str(e))
return S_ERROR(f"Oops! Plot request is not properly encoded!: {str(e)}")
Expand Down
3 changes: 0 additions & 3 deletions src/DIRAC/Resources/Computing/BatchSystems/Condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
LocalComputingElement and SSHComputingElement classes
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import json
import re
import tempfile
Expand Down
3 changes: 0 additions & 3 deletions src/DIRAC/Resources/Computing/BatchSystems/GE.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
SubmitOption = -l ct=6000
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import re
import shlex
import subprocess
Expand Down
4 changes: 0 additions & 4 deletions src/DIRAC/Resources/Computing/BatchSystems/Host.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
with LocalComputingElement or SSHComputingElement objects
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import os
import glob
import shutil
Expand Down
3 changes: 0 additions & 3 deletions src/DIRAC/Resources/Computing/BatchSystems/LSF.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
LocalComputingElement and SSHComputingElement classes
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import re
import subprocess
import shlex
Expand Down
4 changes: 0 additions & 4 deletions src/DIRAC/Resources/Computing/BatchSystems/OAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
LocalComputingElement and SSHComputingElement classes
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import subprocess
import shlex
import os
Expand Down
4 changes: 0 additions & 4 deletions src/DIRAC/Resources/Computing/BatchSystems/SLURM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
LocalComputingElement and SSHComputingElement classes
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import os
import re
import subprocess
Expand Down
4 changes: 0 additions & 4 deletions src/DIRAC/Resources/Computing/BatchSystems/Torque.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
LocalComputingElement and SSHComputingElement classes
"""

from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import subprocess
import shlex
import os
Expand Down
8 changes: 5 additions & 3 deletions src/DIRAC/Resources/Computing/SSHComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ def __executeHostCommand(self, command, options, ssh=None, host=None):
options = json.dumps(options)
options = quote(options)

cmd = (
"bash --login -c 'python3 %s/execute_batch %s || python %s/execute_batch %s || python2 %s/execute_batch %s'"
% (self.sharedArea, options, self.sharedArea, options, self.sharedArea, options)
cmd = "bash --login -c 'python3 {}/execute_batch {} || python {}/execute_batch {}'".format(
self.sharedArea,
options,
self.sharedArea,
options,
)

self.log.verbose(f"CE submission command: {cmd}")
Expand Down
46 changes: 11 additions & 35 deletions src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
py='python'
elif command -v python3 &> /dev/null; then
py='python3'
elif command -v python2 &> /dev/null; then
py='python2'
fi
/usr/bin/env $py << EOF

Expand Down Expand Up @@ -63,14 +61,8 @@
import shlex
from uuid import uuid1

try:
# For Python 3.0 and later
from urllib.request import urlopen, HTTPError, URLError
from urllib.parse import urlencode
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen, HTTPError, URLError
from urllib import urlencode
from urllib.request import urlopen, HTTPError, URLError
from urllib.parse import urlencode

try:
from cStringIO import StringIO
Expand All @@ -93,10 +85,7 @@ def formatTime(self, record, datefmt=None):
# formatter = logging.Formatter(fmt='%%(asctime)s UTC %%(levelname)-8s %%(message)s', datefmt='%%Y-%%m-%%d %%H:%%M:%%S')
formatter = MicrosecondFormatter('%%(asctime)s %%(levelname)-8s [%%(name)s] %%(message)s')
logging.Formatter.converter = time.gmtime
try:
screen_handler = logging.StreamHandler(stream=sys.stdout)
except TypeError: # python2.6
screen_handler = logging.StreamHandler(strm=sys.stdout)
screen_handler = logging.StreamHandler(stream=sys.stdout)
screen_handler.setFormatter(formatter)

# add a string buffer handler
Expand Down Expand Up @@ -276,28 +265,15 @@ def pilotWrapperScript(
# Getting the json, tar, and checksum file
try:

# urllib is different between python 2 and 3
if sys.version_info < (3,):
from urllib2 import urlopen as url_library_urlopen
from urllib2 import URLError as url_library_URLError
else:
from urllib.request import urlopen as url_library_urlopen
from urllib.error import URLError as url_library_URLError
from urllib.request import urlopen
from urllib.error import URLError

for fileName in ['checksums.sha512', 'pilot.json', 'pilot.tar']:
# needs to distinguish whether urlopen method contains the 'context' param
# in theory, it should be available from python 2.7.9
# in practice, some prior versions may be composed of recent urllib version containing the param
if 'context' in url_library_urlopen.__code__.co_varnames:
import ssl
context = ssl._create_unverified_context()
remoteFile = url_library_urlopen(os.path.join(loc, fileName),
timeout=10,
context=context)

else:
remoteFile = url_library_urlopen(os.path.join(loc, fileName),
timeout=10)
import ssl
context = ssl._create_unverified_context()
remoteFile = urlopen(os.path.join(loc, fileName),
timeout=10,
context=context)

localFile = open(fileName, 'wb')
localFile.write(remoteFile.read())
Expand All @@ -320,7 +296,7 @@ def pilotWrapperScript(
raise
# if we get here we break out of the loop of locations
break
except (url_library_URLError, Exception) as e:
except (URLError, Exception) as e:
print('%%s unreacheable (this is normal!)' %% loc, file=sys.stderr)
logger.error('%%s unreacheable (this is normal!)' %% loc)
logger.exception(e)
Expand Down
10 changes: 4 additions & 6 deletions tests/CI/run_pilot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ cp /ca/certs/pilot_proxy /tmp/x509up_u$UID

eval "${PILOT_DOWNLOAD_COMMAND}"

echo "${PILOT_JSON}" > pilot.json
jq < pilot.json
echo "${PILOT_JSON}" >pilot.json
jq <pilot.json

if command -v python &> /dev/null; then
if command -v python &>/dev/null; then
py='python'
elif command -v python3 &> /dev/null; then
elif command -v python3 &>/dev/null; then
py='python3'
elif command -v python2 &> /dev/null; then
py='python2'
fi

# shellcheck disable=SC2086
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# - starts it
#
# It should be executed for different versions of python, e.g.:
# - 2.7.x (x < 9)
# - 2.7.x (x >= 9)
# - 3.6.x
# - 3.11.x
#
Expand All @@ -25,20 +23,12 @@

# 1) gets the (DIRAC-free) PilotWrapper.py

# urllib is different between python 2 and 3
if sys.version_info < (3,):
from urllib2 import urlopen as url_library_urlopen # pylint: disable=import-error
else:
from urllib.request import urlopen as url_library_urlopen # pylint: disable=import-error,no-name-in-module
from urllib.request import urlopen # pylint: disable=import-error,no-name-in-module

import ssl # pylint: disable=import-error

if sys.version_info >= (2, 7, 9):
import ssl # pylint: disable=import-error

context = ssl._create_unverified_context()
rf = url_library_urlopen(sys.argv[1], context=context)
else:
rf = url_library_urlopen(sys.argv[1])
context = ssl._create_unverified_context()
rf = urlopen(sys.argv[1], context=context)
locc = sys.argv[2]

with open("PilotWrapper.py", "wb") as pj:
Expand Down
Loading