Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit 93e123d

Browse files
authored
Merge pull request #353 from PanDAWMS/next
2.12.1.62
2 parents 29c4352 + 59af5af commit 93e123d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3446
-1806
lines changed

.github/workflows/build-docs.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ jobs:
3030
run: |
3131
cd ./doc
3232
make github
33-
cd ..
33+
34+
- name: Add nojekyll file to repo root dir
35+
run: |
36+
touch .nojekyll
3437
3538
- name: Push docs to repo
3639
run: |
3740
git config user.name "brinick"
3841
git config user.email "brinick@users.noreply.github.com"
39-
git add docs
40-
git commit -m "Adding documentation"
42+
git add docs .nojekyll
43+
git commit -m "Adding Pilot documentation"
4144
git push
4245

PILOTVERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.11.2.22
1+
2.12.1.62

pilot.py

+25-69
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# - Paul Nilsson, paul.nilsson@cern.ch, 2017-2019
1111

1212
from __future__ import print_function # Python 2 (2to3 complains about this)
13+
from __future__ import absolute_import
1314

1415
import argparse
1516
import logging
@@ -68,7 +69,7 @@ def main():
6869
infosys.init(args.queue)
6970
# check if queue is ACTIVE
7071
if infosys.queuedata.state != 'ACTIVE':
71-
logger.critical('specified queue is NOT ACTIVE: %s -- aborting' % infosys.queuedata.name)
72+
logger.critical('specified queue is NOT ACTIVE: %s -- aborting', infosys.queuedata.name)
7273
return errors.PANDAQUEUENOTACTIVE
7374
except PilotException as error:
7475
logger.fatal(error)
@@ -81,14 +82,14 @@ def main():
8182
environ['PILOT_SITENAME'] = infosys.queuedata.resource #args.site # TODO: replace with singleton
8283

8384
# set requested workflow
84-
logger.info('pilot arguments: %s' % str(args))
85+
logger.info('pilot arguments: %s', str(args))
8586
workflow = __import__('pilot.workflow.%s' % args.workflow, globals(), locals(), [args.workflow], 0) # Python 3, -1 -> 0
8687

8788
# execute workflow
8889
try:
8990
exit_code = workflow.run(args)
9091
except Exception as e:
91-
logger.fatal('main pilot function caught exception: %s' % e)
92+
logger.fatal('main pilot function caught exception: %s', e)
9293
exit_code = None
9394

9495
return exit_code
@@ -101,62 +102,6 @@ class Args:
101102
pass
102103

103104

104-
# rename module to pilot2 to avoid conflict in import with pilot directory
105-
def import_module(**kwargs):
106-
"""
107-
This function allows for importing the pilot code.
108-
109-
:param kwargs: pilot options (dictionary).
110-
:return: pilot error code (integer).
111-
"""
112-
113-
argument_dictionary = {'-a': kwargs.get('workdir', ''),
114-
'-d': kwargs.get('debug', None),
115-
'-w': kwargs.get('workflow', 'generic'),
116-
'-l': kwargs.get('lifetime', '3600'),
117-
'-q': kwargs.get('queue'), # required
118-
'-r': kwargs.get('resource'), # required
119-
'-s': kwargs.get('site'), # required
120-
'-j': kwargs.get('job_label', 'ptest'), # change default later to 'managed'
121-
'-i': kwargs.get('version_tag', 'PR'),
122-
'-t': kwargs.get('verify_proxy', True),
123-
'-z': kwargs.get('update_server', True),
124-
'--cacert': kwargs.get('cacert', None),
125-
'--capath': kwargs.get('capath'),
126-
'--url': kwargs.get('url', ''),
127-
'-p': kwargs.get('port', '25443'),
128-
'--country-group': kwargs.get('country_group', ''),
129-
'--working-group': kwargs.get('working_group', ''),
130-
'--allow-other-country': kwargs.get('allow_other_country', 'False'),
131-
'--allow-same-user': kwargs.get('allow_same_user', 'True'),
132-
'--pilot-user': kwargs.get('pilot_user', 'generic'),
133-
'--input-dir': kwargs.get('input_dir', ''),
134-
'--output-dir': kwargs.get('output_dir', ''),
135-
'--hpc-resource': kwargs.get('hpc_resource', ''),
136-
'--harvester-workdir': kwargs.get('harvester_workdir', ''),
137-
'--harvester-datadir': kwargs.get('harvester_datadir', ''),
138-
'--harvester-eventstatusdump': kwargs.get('harvester_eventstatusdump', ''),
139-
'--harvester-workerattributes': kwargs.get('harvester_workerattributes', ''),
140-
'--harvester-submitmode': kwargs.get('harvester_submitmode', ''),
141-
'--resource-type': kwargs.get('resource_type', '')
142-
}
143-
144-
args = Args()
145-
parser = argparse.ArgumentParser()
146-
try:
147-
_items = list(argument_dictionary.items()) # Python 3
148-
except Exception:
149-
_items = argument_dictionary.iteritems() # Python 2
150-
for key, value in _items:
151-
print(key, value)
152-
parser.add_argument(key)
153-
parser.parse_args(args=[key, value], namespace=args) # convert back int and bool strings to int and bool??
154-
155-
# call main pilot function
156-
157-
return 0
158-
159-
160105
def str2bool(v):
161106
""" Helper function to convert string to bool """
162107

@@ -379,6 +324,11 @@ def get_args():
379324
dest='jobtype',
380325
default='',
381326
help='Job type (managed, user)')
327+
arg_parser.add_argument('--use-rucio-traces',
328+
dest='use_rucio_traces',
329+
type=str2bool,
330+
default=True,
331+
help='Use rucio traces')
382332

383333
# HPC options
384334
arg_parser.add_argument('--hpc-resource',
@@ -413,10 +363,10 @@ def create_main_work_dir(args):
413363
try:
414364
# create the main PanDA Pilot work directory
415365
mkdirs(mainworkdir)
416-
except Exception as e:
366+
except PilotException as error:
417367
# print to stderr since logging has not been established yet
418-
print('failed to create workdir at %s -- aborting: %s' % (mainworkdir, e), file=sys.stderr)
419-
exit_code = shell_exit_code(e._errorCode)
368+
print('failed to create workdir at %s -- aborting: %s' % (mainworkdir, error), file=sys.stderr)
369+
exit_code = shell_exit_code(error._errorCode)
420370
else:
421371
mainworkdir = getcwd()
422372

@@ -467,9 +417,15 @@ def set_environment_variables(args, mainworkdir):
467417
# set the (HPC) resource name (if set in options)
468418
environ['PILOT_RESOURCE_NAME'] = args.hpc_resource
469419

420+
# allow for the possibility of turning off rucio traces
421+
environ['PILOT_USE_RUCIO_TRACES'] = str(args.use_rucio_traces)
422+
470423
# event service executor type
471424
environ['PILOT_ES_EXECUTOR_TYPE'] = args.executor_type
472425

426+
if args.output_dir:
427+
environ['PILOT_OUTPUT_DIR'] = args.output_dir
428+
473429
# keep track of the server urls
474430
_port = ":%s" % args.port
475431
url = args.url if _port in args.url else args.url + _port
@@ -495,9 +451,9 @@ def wrap_up(initdir, mainworkdir, args):
495451
try:
496452
rmtree(mainworkdir)
497453
except Exception as e:
498-
logging.warning("failed to remove %s: %s" % (mainworkdir, e))
454+
logging.warning("failed to remove %s: %s", mainworkdir, e)
499455
else:
500-
logging.info("removed %s" % mainworkdir)
456+
logging.info("removed %s", mainworkdir)
501457

502458
# in Harvester mode, create a kill_worker file that will instruct Harvester that the pilot has finished
503459
if args.harvester:
@@ -509,15 +465,15 @@ def wrap_up(initdir, mainworkdir, args):
509465
except Exception:
510466
exit_code = trace
511467
else:
512-
logging.info('traces error code: %d' % exit_code)
468+
logging.info('traces error code: %d', exit_code)
513469
if trace.pilot['nr_jobs'] <= 1:
514470
if exit_code != 0:
515-
logging.info('an exit code was already set: %d (will be converted to a standard shell code)' % exit_code)
471+
logging.info('an exit code was already set: %d (will be converted to a standard shell code)', exit_code)
516472
elif trace.pilot['nr_jobs'] > 0:
517473
if trace.pilot['nr_jobs'] == 1:
518-
logging.getLogger(__name__).info('pilot has finished (%d job was processed)' % trace.pilot['nr_jobs'])
474+
logging.getLogger(__name__).info('pilot has finished (%d job was processed)', trace.pilot['nr_jobs'])
519475
else:
520-
logging.getLogger(__name__).info('pilot has finished (%d jobs were processed)' % trace.pilot['nr_jobs'])
476+
logging.getLogger(__name__).info('pilot has finished (%d jobs were processed)', trace.pilot['nr_jobs'])
521477
exit_code = SUCCESS
522478
elif trace.pilot['state'] == FAILURE:
523479
logging.critical('pilot workflow failure -- aborting')
@@ -579,7 +535,7 @@ def get_pilot_source_dir():
579535
set_environment_variables(args, mainworkdir)
580536

581537
# setup and establish standard logging
582-
establish_logging(args)
538+
establish_logging(debug=args.debug, nopilotlog=args.nopilotlog)
583539

584540
# execute main function
585541
trace = main()

pilot/api/analytics.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# http://www.apache.org/licenses/LICENSE-2.0
66
#
77
# Authors:
8-
# - Paul Nilsson, paul.nilsson@cern.ch, 2018
8+
# - Paul Nilsson, paul.nilsson@cern.ch, 2018-2021
99

1010
from .services import Services
1111
from pilot.common.exception import NotDefined, NotSameLength, UnknownException
@@ -146,21 +146,20 @@ def get_fitted_data(self, filename, x_name='Time', y_name='pss+swap', precision=
146146
y = y[:-2]
147147

148148
if (len(x) > 7 and len(y) > 7) and len(x) == len(y):
149-
logger.info('fitting %s vs %s' % (y_name, x_name))
149+
logger.info('fitting %s vs %s', y_name, x_name)
150150
try:
151151
fit = self.fit(x, y)
152152
_slope = self.slope()
153153
except Exception as e:
154-
logger.warning('failed to fit data, x=%s, y=%s: %s' % (str(x), str(y), e))
154+
logger.warning('failed to fit data, x=%s, y=%s: %s', str(x), str(y), e)
155155
else:
156156
if _slope:
157157
slope = float_to_rounded_string(fit.slope(), precision=precision)
158158
chi2 = float_to_rounded_string(fit.chi2(), precision=0) # decimals are not needed for chi2
159159
if slope != "":
160-
logger.info('current memory leak: %s B/s (using %d data points, chi2=%s)' %
161-
(slope, len(x), chi2))
160+
logger.info('current memory leak: %s B/s (using %d data points, chi2=%s)', slope, len(x), chi2)
162161
else:
163-
logger.warning('wrong length of table data, x=%s, y=%s (must be same and length>=4)' % (str(x), str(y)))
162+
logger.warning('wrong length of table data, x=%s, y=%s (must be same and length>=4)', str(x), str(y))
164163

165164
return {"slope": slope, "chi2": chi2}
166165

@@ -182,8 +181,8 @@ def extract_from_table(self, table, x_name, y_name):
182181
y2_name = y_name.split('+')[1]
183182
y1_value = table.get(y1_name, [])
184183
y2_value = table.get(y2_name, [])
185-
except Exception as e:
186-
logger.warning('exception caught: %s' % e)
184+
except Exception as error:
185+
logger.warning('exception caught: %s', error)
187186
x = []
188187
y = []
189188
else:
@@ -238,7 +237,7 @@ def __init__(self, **kwargs):
238237
self.set_intersect()
239238
self.set_chi2()
240239
else:
241-
logger.warning("\'%s\' model is not implemented" % self._model)
240+
logger.warning("\'%s\' model is not implemented", self._model)
242241
raise NotImplementedError()
243242

244243
def fit(self):

0 commit comments

Comments
 (0)