Don't try to retrieve info for a push again if we failed to do it in the past 10 days

This commit is contained in:
Marco Castelluccio 2020-03-16 17:54:45 +01:00
Родитель 95a2254696
Коммит 655c29bed5
2 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -58,10 +58,10 @@ def get_model(model_name, force_cache=False):
else:
raise
# Cache the model only if it was last used less than two hours ago.
# Cache the model only if it was last used less than one hour ago.
if force_cache or (
model_name in MODEL_LAST_LOADED
and MODEL_LAST_LOADED[model_name] > datetime.now() - relativedelta(hours=2)
and MODEL_LAST_LOADED[model_name] > datetime.now() - relativedelta(hours=1)
):
MODEL_CACHE[model_name] = model
else:

Просмотреть файл

@ -79,6 +79,10 @@ class Retriever(object):
db.upload(ADR_CACHE_DB)
# We keep in the cache the fact that we failed to analyze a push for 10
# days, so if we re-run often we don't retry the same pushes many times.
MISSING_CACHE_RETENTION = 10 * 24 * 60
# We'll use the past TRAINING_MONTHS months only for training the model,
# but we use half TRAINING_MONTHS months more than that to calculate the
# failure statistics.
@ -105,7 +109,9 @@ class Retriever(object):
if adr.config.cache.has(key):
num_cached += 1
push_data.append(adr.config.cache.get(key))
value = adr.config.cache.get(key)
if value is not None:
push_data.append(value)
else:
try:
if runnable == "label":
@ -125,8 +131,10 @@ class Retriever(object):
logger.warning(
f"Tasks for push {push.rev} can't be found on ActiveData"
)
adr.config.cache.put(key, None, MISSING_CACHE_RETENTION)
except Exception:
traceback.print_exc()
adr.config.cache.put(key, None, MISSING_CACHE_RETENTION)
if time.monotonic() - start_time >= 3600:
upload_adr_cache()