From 9e1f29fcea484098f50cbcff82d9c2ec2fe878f3 Mon Sep 17 00:00:00 2001 From: Natasha Singh Date: Thu, 30 Sep 2021 10:37:09 -0400 Subject: [PATCH 1/2] :bug: Fix API logging configurations Sets the creator logger to INFO level so that messages will be processed by the handlers Remove redundant logging configurations from the settings If any module needs to do something different than the creator logger, add it as an additional block (e.g. genomic_data_loader.py) Log messages from the creator logger were being ignored by it's handlers since the handlers are set to process messages at INFO level or higher while the creator logger was set to the default log level of WARNING --- creator/settings/development.py | 17 +++-------------- creator/settings/production.py | 20 ++++---------------- creator/settings/testing.py | 19 +++++-------------- 3 files changed, 12 insertions(+), 44 deletions(-) diff --git a/creator/settings/development.py b/creator/settings/development.py index 57a4e92a7..625c21e8b 100644 --- a/creator/settings/development.py +++ b/creator/settings/development.py @@ -254,24 +254,13 @@ }, }, "loggers": { - "TaskLogger": {}, - "creator.management": {"handlers": ["command"], "level": "INFO"}, "rq.worker": {"handlers": ["rq_console"], "level": "ERROR"}, - "creator.tasks": {"handlers": ["task"], "level": "INFO"}, - "creator.slack": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.dataservice": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.buckets": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.schema": {"handlers": ["task"], "level": "INFO"}, + "TaskLogger": {"handlers": ["task"], "level": "INFO"}, + "creator": {"handlers": ["task"], "level": "INFO"}, "creator.ingest_runs.genomic_data_loader": { "handlers": ["task"], "level": "DEBUG", - }, - "creator.ingest_runs.tasks.validation_run": { - "handlers": ["task"], - "level": "INFO", - }, - "creator.data_templates.mutations.template_version": { - "handlers": ["task"], "level": "INFO" + "propagate": False, }, }, } diff --git a/creator/settings/production.py b/creator/settings/production.py index 8532f3594..96d1fbd40 100644 --- a/creator/settings/production.py +++ b/creator/settings/production.py @@ -295,29 +295,17 @@ def traces_sampler(sampling_context): }, }, "loggers": { - "TaskLogger": {"handlers": ["task"], "level": "INFO"}, + "rq.worker": {"handlers": ["rq_console"]}, "graphql.execution.utils": { "handlers": ["command"], "level": "CRITICAL", }, - "creator": {"handlers": ["task"]}, - "creator.management": {"handlers": ["command"], "level": "INFO"}, - "rq.worker": {"handlers": ["rq_console"]}, - "creator.decorators": {"handlers": ["task"]}, + "TaskLogger": {"handlers": ["task"], "level": "INFO"}, + "creator": {"handlers": ["task"], "level": "INFO"}, "creator.ingest_runs.genomic_data_loader": { "handlers": ["task"], "level": "DEBUG", - }, - "creator.ingest_runs.tasks.validation_run": { - "handlers": ["task"], - "level": "INFO", - }, - "creator.data_templates.mutations.template_version": { - "handlers": ["task"], "level": "ERROR" - }, - "creator.releases.tasks": { - "handlers": ["task"], - "level": "INFO", + "propagate": False, }, }, } diff --git a/creator/settings/testing.py b/creator/settings/testing.py index a860f939c..84789b034 100644 --- a/creator/settings/testing.py +++ b/creator/settings/testing.py @@ -252,22 +252,13 @@ }, }, "loggers": { - "TaskLogger": {}, - "creator.management": {"handlers": ["command"], "level": "INFO"}, "rq.worker": {"handlers": ["rq_console"], "level": "ERROR"}, - "creator.tasks": {"handlers": ["task"], "level": "INFO"}, - "creator.slack": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.dataservice": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.buckets": {"handlers": ["task"], "level": "INFO"}, - "creator.studies.schema": {"handlers": ["task"], "level": "INFO"}, + "TaskLogger": {"handlers": ["task"], "level": "INFO"}, + "creator": {"handlers": ["task"], "level": "INFO"}, "creator.ingest_runs.genomic_data_loader": { - "handlers": ["task"], "level": "DEBUG" - }, - "creator.ingest_runs.tasks.validation_run": { - "handlers": ["task"], "level": "INFO" - }, - "creator.data_templates.mutations.template_version": { - "handlers": ["task"], "level": "INFO" + "handlers": ["task"], + "level": "DEBUG", + "propagate": False, }, }, } From dca8ac0725371ae3bc421d7e5d8d4779a612fef6 Mon Sep 17 00:00:00 2001 From: Natasha Singh Date: Thu, 30 Sep 2021 10:44:00 -0400 Subject: [PATCH 2/2] :loud_sound: Log release and release task transitions to terminal states --- creator/releases/models.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/creator/releases/models.py b/creator/releases/models.py index 868a0dd81..0cfc1640b 100644 --- a/creator/releases/models.py +++ b/creator/releases/models.py @@ -138,7 +138,7 @@ def start(self): @transition(field=state, source="running", target="staged") def staged(self): """ The release has been staged """ - return + logger.info(f"Release {self.pk} entered staged state") @transition(field=state, source="staged", target="publishing") def publish(self): @@ -153,7 +153,7 @@ def complete(self): else: self.version = self.version.next_minor() self.save() - return + logger.info(f"Release {self.pk} entered published state") @transition(field=state, source=FAIL_SOURCES, target="canceling") def cancel(self): @@ -163,12 +163,12 @@ def cancel(self): @transition(field=state, source="canceling", target="canceled") def canceled(self): """ The release has finished canceling """ - return + logger.info(f"Release {self.pk} entered canceled state") @transition(field=state, source=FAIL_SOURCES, target="failed") def failed(self): """ The release failed """ - return + logger.info(f"Release {self.pk} entered failed state") class ReleaseTask(models.Model): @@ -305,7 +305,7 @@ def start(self): @transition(field=state, source="running", target="staged") def stage(self): - return + logger.info(f"Task {self.pk} entered staged state") @transition(field=state, source="staged", target="publishing") def publish(self): @@ -326,15 +326,15 @@ def publish(self): @transition(field=state, source="publishing", target="published") def complete(self): - return + logger.info(f"Task {self.pk} entered published state") @transition(field=state, source="waiting", target="rejected") def reject(self): - return + logger.info(f"Task {self.pk} entered rejected state") @transition(field=state, source="*", target="failed") def failed(self): - return + logger.info(f"Task {self.pk} entered failed state") @transition(field=state, source="*", target="canceled") def cancel(self): @@ -352,6 +352,7 @@ def cancel(self): ) logger.error(error) raise ValueError(error) + logger.info(f"Task {self.pk} entered canceled state") def check_state(self): """