Commits (2)
  • Duncan Macleod's avatar
    setup.py: parse version from version.py don't import · ab32741c
    Duncan Macleod authored
    its simpler to parse the version number from `ligo.gracedb.version`, rather than importing, so that `six` isn't required on the build machine _before_ building. importing in setup.py has also been seen to confuse some coverage parsers, and other profiling tools.
  • Leo Pound Singer's avatar
    Make HTTPError pickleable · dd107fa3
    Leo Pound Singer authored
    According to the [Celery manual]:
    > A rarely known Python fact is that exceptions must conform to
    > some simple rules to support being serialized by the pickle
    > module.
    > Tasks that raise exceptions that aren’t pickleable won’t work
    > properly when Pickle is used as the serializer.
    > To make sure that your exceptions are pickleable the exception
    > MUST provide the original arguments it was instantiated with in
    > its .args attribute. The simplest way to ensure this is to have
    > the exception call Exception.__init__.
    The class `ligo.gracedb.exceptions.HTTPError` does not follow
    these rules, so it is not pickleable. Here is a demonstration of
        >>> import pickle
        >>> from ligo.gracedb.exceptions import HTTPError
        >>> pickle.loads(pickle.dumps(HTTPError(404, 'foo', 'bar')))
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: __init__() missing 2 required positional arguments:
        'reason' and 'message'
    This patch makes `HTTPError` pickleable so that it can be properly
    represented in Celery task stack traces.
    [Celery manual]: http://docs.celeryproject.org/en/latest/userguide/tasks.html#creating-pickleable-exceptions
......@@ -6,4 +6,4 @@ class HTTPError(Exception):
self.status = status
self.reason = reason
self.message = message
Exception.__init__(self, (status, '{} / {}'.format(reason, message)))
Exception.__init__(self, status, reason, message)
......@@ -16,12 +16,27 @@
# You should have received a copy of the GNU General Public License
# along with gracedb. If not, see <http://www.gnu.org/licenses/>.
import os
import re
from setuptools import setup, find_packages
from ligo.gracedb import __version__
def parse_version(path):
"""Extract the `__version__` string from the given file
with open(path, 'r') as fp:
version_file = fp.read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
name = "ligo-gracedb",
version = __version__,
version = parse_version(os.path.join('ligo', 'gracedb', 'version.py')),
maintainer = "Tanner Prestegard, Alexander Pace",
maintainer_email = "tanner.prestegard@ligo.org, alexander.pace@ligo.org",
description = "Gravitational Wave Candidate Event Database",