Skip to content

Commit

Permalink
rebase with pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Loevenich, Mathis committed Nov 17, 2021
1 parent 0d73e33 commit e034c16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions htcanalyze/log_analyzer/event_handler/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion htcanalyze/log_analyzer/event_handler/job_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e034c16

Please sign in to comment.