From 492e8da5c371e985530c635220b1c9ed43719bb6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 9 Jan 2023 09:00:50 -0600 Subject: [PATCH] Remove some luigi config if using newer package apparently some of these settings are no longer used by latest luigi, and it complains when they're present --- rattail_fabric2/deploy/luigi/luigi.cfg.mako | 4 ++++ rattail_fabric2/luigi.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/rattail_fabric2/deploy/luigi/luigi.cfg.mako b/rattail_fabric2/deploy/luigi/luigi.cfg.mako index d26040a..c6671b3 100644 --- a/rattail_fabric2/deploy/luigi/luigi.cfg.mako +++ b/rattail_fabric2/deploy/luigi/luigi.cfg.mako @@ -12,6 +12,8 @@ [core] logging_conf_file = ${appdir}/luigi/logging.conf +% if LUIGI2: + # Number of seconds to wait before timing out when making an API call. Defaults # to 10.0 # (sometimes things can lag for us and we simply need to give it more time) @@ -27,6 +29,8 @@ rpc_retry_attempts = 10 # (occasional network issues seem to cause us to need more/longer retries) rpc_retry_wait = 60 +% endif + [retcode] # cf. https://luigi.readthedocs.io/en/stable/configuration.html#retcode-config # The following return codes are the recommended exit codes for Luigi diff --git a/rattail_fabric2/luigi.py b/rattail_fabric2/luigi.py index 3a1eff1..4a5866c 100644 --- a/rattail_fabric2/luigi.py +++ b/rattail_fabric2/luigi.py @@ -25,6 +25,8 @@ Fabric library for Luigi apps """ import os +import re +from pkg_resources import parse_version from rattail_fabric2 import postgresql, make_deploy, mkdir @@ -48,6 +50,14 @@ def install_luigi(c, envroot, luigi='luigi', user='rattail', c.sudo("""bash -lc "workon {} && pip install '{}'" """.format(envname, luigi), user=user) + # detect luigi version + LUIGI2 = False + output = c.sudo("bash -lc 'workon {} && pip show luigi | grep Version'".format(envname), user=user).stdout.strip() + match = re.match(r'^Version: (\d+\S+)$', output) + if match: + if parse_version(match.group(1)) < parse_version('3'): + LUIGI2 = True + # dirs mkdir(c, ['{}/luigi'.format(appdir), '{}/luigi/log'.format(appdir),