Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PY3] unit test fixed for Aligenmnet #28286

Merged
merged 1 commit into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions Alignment/CommonAlignment/scripts/tkal_create_file_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import bisect
import random
import signal
import cPickle
if sys.version_info[0]>2:
import _pickle as cPickle
else:
import cPickle
import difflib
import argparse
import functools
Expand Down Expand Up @@ -363,14 +366,14 @@ def _request_dataset_information(self):
for d in self._datasets: print_msg("\t"+d)
print_msg("This may take a while...")

result = pool.map_async(get_events_per_dataset, self._datasets).get(sys.maxsize)
result = pool.map_async(get_events_per_dataset, self._datasets).get(3600)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smuzaffar sys.maxint has gone in python3, but isn't sys.maxsize still available, according to https://docs.python.org/3/library/sys.html ? What is the rationale behind this hardcoded value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ints are gone in python3. so maxsize is available but does not give the same answer as in python2.

The error is
OverflowError: timestamp too large to convert to C _PyTime_t (which instead is a 64-bit int in C)

but perhaps 2147483647 would conserve the old behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos , sys.maxint and sys.maxsize are used here to set a timeout (i.e. 9223372036854775807 sec). There is no need to set such long timeouts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidlange6 according to the documentation sys.maxsize is now a variable of type Py_ssize_t so not what is desired here, I agree

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smuzaffar this argument is more related to the functionality of the unit test I would say, waiting for an infinite time is not what is desired

self._events_in_dataset = sum(result)

result = pool.map_async(get_max_run, self._datasets).get(sys.maxsize)
result = pool.map_async(get_max_run, self._datasets).get(3600)
self._max_run = max(result)

result = sum(pool.map_async(get_file_info, self._datasets).get(sys.maxint), [])
files = pool.map_async(_make_file_info, result).get(sys.maxint)
result = sum(pool.map_async(get_file_info, self._datasets).get(3600), [])
files = pool.map_async(_make_file_info, result).get(3600)
self._file_info = sorted(fileinfo for fileinfo in files)

self.rereco = any(len(fileinfo.runs)>1 for fileinfo in self._file_info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# parseParameter will override the config values.
##

import ConfigParser
import configparser as ConfigParser
import logging
import os

Expand Down
7 changes: 5 additions & 2 deletions Alignment/MillePedeAlignmentAlgorithm/scripts/mps_alisetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import os
import re
import sys
import cPickle
if sys.version_info[0]>2:
import _pickle as cPickle
else:
import cPickle
import argparse
import itertools
import subprocess
import collections
import ConfigParser
import configparser as ConfigParser
import Alignment.MillePedeAlignmentAlgorithm.mpslib.tools as mps_tools
import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib
import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.iniparser as mpsv_iniparser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
print("=======================================")
print()
import subprocess
execfile(subprocess.check_output(["which", "tkal_create_file_lists.py"]).rstrip())
exec(open(subprocess.check_output(["which", "tkal_create_file_lists.py"], universal_newlines=True).rstrip()).read())
5 changes: 4 additions & 1 deletion Alignment/MillePedeAlignmentAlgorithm/scripts/mps_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import sys
import glob
import shutil
import cPickle
if sys.version_info[0]>2:
import _pickle as cPickle
else:
import cPickle
import subprocess
import re
import argparse
Expand Down