From e034c16e91c7275156d1e52957f4e14870630e2a Mon Sep 17 00:00:00 2001 From: "Loevenich, Mathis" Date: Wed, 17 Nov 2021 18:38:07 +0100 Subject: [PATCH] rebase with pylint --- .../event_handler/event_handler.py | 37 ++++++++++--------- .../log_analyzer/event_handler/job_events.py | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/htcanalyze/log_analyzer/event_handler/event_handler.py b/htcanalyze/log_analyzer/event_handler/event_handler.py index c3e0119..fd6a0df 100755 --- a/htcanalyze/log_analyzer/event_handler/event_handler.py +++ b/htcanalyze/log_analyzer/event_handler/event_handler.py @@ -69,7 +69,6 @@ class HTCJobEventWrapper: """ def __init__(self, job_event: HTCJobEvent): - self.wrapped_class = job_event self.event_number = job_event.get('EventTypeNumber') self.time_stamp = date_time.strptime( @@ -81,19 +80,24 @@ def __getattr__(self, attr): return getattr(self.wrapped_class, attr) def get(self, *args, **kwargs): + """Wraps wrapped_class get function.""" return self.wrapped_class.get(*args, **kwargs) def items(self): + """Wraps wrapped_class items method.""" return self.wrapped_class.items() def keys(self): + """Wraps wrapped_class keys method.""" return self.wrapped_class.keys() def values(self): + """Wraps wrapped_class values method.""" return self.wrapped_class.values() def to_dict(self): - return {key: val for key, val in self.items()} + """Turns wrapped_class items into a dictionary.""" + return dict(self.items()) def __repr__(self): return json.dumps( @@ -217,10 +221,8 @@ def get_job_terminated_event( ) ) - normal_termination = event.get('TerminatedNormally') - # differentiate between normal and abnormal termination - if normal_termination: + if event.get('TerminatedNormally'): self._state = NormalTerminationState() return_value = event.get('ReturnValue') return NormalTerminationEvent( @@ -229,16 +231,16 @@ def get_job_terminated_event( resources, return_value ) - else: - return_value = event.get('TerminatedBySignal') - self._state = AbnormalTerminationState() - return AbnormalTerminationEvent( - event.event_number, - event.time_stamp, - resources, - return_value - ) - # Todo: include description when possible + # else: + return_value = event.get('TerminatedBySignal') + self._state = AbnormalTerminationState() + return AbnormalTerminationEvent( + event.event_number, + event.time_stamp, + resources, + return_value + ) + # Todo: include description when possible @staticmethod def get_job_evicted_event( @@ -325,6 +327,7 @@ def get_job_held_event(event: HTCJobEventWrapper) -> JobHeldEvent: def get_job_disconnected_event( event: HTCJobEventWrapper ) -> JobDisconnectedEvent: + """Reads and returns a JobDisconnectedEvent.""" assert event.type == jet.JOB_DISCONNECTED reason = f"{event.get('DisconnectReason')}" return JobDisconnectedEvent( @@ -337,18 +340,18 @@ def get_job_disconnected_event( def get_job_reconnected_event( event: HTCJobEventWrapper ) -> JobReconnectedEvent: + """Reads and returns a JobReconnectedEvent.""" assert event.type == jet.JOB_RECONNECTED - reason = f"{event.get('Reason')}" return JobReconnectedEvent( event.event_number, event.time_stamp, - reason ) @staticmethod def get_job_reconnect_failed_event( event: HTCJobEventWrapper ) -> JobReconnectFailedEvent: + """Reads and returns a JobReconnectFailedEvent.""" assert event.type == jet.JOB_RECONNECT_FAILED reason = f"{event.get('Reason')}" return JobReconnectFailedEvent( diff --git a/htcanalyze/log_analyzer/event_handler/job_events.py b/htcanalyze/log_analyzer/event_handler/job_events.py index f16f043..4bfa238 100755 --- a/htcanalyze/log_analyzer/event_handler/job_events.py +++ b/htcanalyze/log_analyzer/event_handler/job_events.py @@ -187,7 +187,7 @@ class JobCheckpointedEvent(JobEvent): Event Number: 003 Event Name: Job was checkpointed - Event Description: The job’s complete state was written to a checkpoint + Event Description: The job’s complete state was written to a checkpoint file. This might happen without the job being removed from a machine, because the checkpointing can happen periodically.