Skip to content

Commit

Permalink
feat: Put details last. fix: Remove set notation {}. nit: Use walrus …
Browse files Browse the repository at this point in the history
…operator. Use tuple instead of list.
  • Loading branch information
jpmckinney committed Jan 23, 2025
1 parent 9079500 commit 942a2fe
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions data_registry/process_manager/task/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,18 @@ def get_status(self):

scrapy_log = ScrapyLogFile(scrapy_log_url)

for key in scrapy_log.logparser["log_categories"]:
if scrapy_log.logparser["log_categories"][key]["count"] > 0:
logger.warning("%s: %s", self, {scrapy_log.logparser["log_categories"][key]["details"]})
if scrapy_log.error_rate:
logger.warning("%s: crawl error rate was %s", self, {scrapy_log.error_rate})

if not scrapy_log.is_finished():
logger.warning("%s: crawl finish reason %s ", self, {scrapy_log.logparser["finish_reason"]})
for stat in ["item_dropped_count", "invalid_json_count"]:
if scrapy_log.logparser["crawler_stats"].get(stat):
logger.warning("%s: crawl %s: %s", self, stat, scrapy_log.logparser["crawler_stats"].get(stat))
self.job.context[stat] = scrapy_log.logparser["crawler_stats"].get(stat)
logger.warning("%s: crawl finish reason: %s", self, scrapy_log.logparser["finish_reason"])
if scrapy_log.error_rate:
logger.warning("%s: crawl error rate: %s", self, scrapy_log.error_rate)
for key in ("item_dropped_count", "invalid_json_count"):
if value := scrapy_log.logparser["crawler_stats"].get(key):
logger.warning("%s: crawl %s: %s", self, key, value)
self.job.context[key] = value
self.job.save(update_fields=["modified", "context"])
for key in scrapy_log.logparser["log_categories"]:
if scrapy_log.logparser["log_categories"][key]["count"]:
logger.warning("%s: %s", self, scrapy_log.logparser["log_categories"][key]["details"])

return Task.Status.COMPLETED

Expand Down

0 comments on commit 942a2fe

Please sign in to comment.