Skip to content

Commit

Permalink
Polish minor details
Browse files Browse the repository at this point in the history
  • Loading branch information
blokhin authored Oct 2, 2024
1 parent 71fafa5 commit 7435cdd
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions yascheduler/aiida_plugin.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
"""
Aiida plugin for yascheduler.
With respect to the supported yascheduler engines.
Aiida plugin for yascheduler
with respect to the supported yascheduler engines.
"""

import aiida.schedulers # pylint: disable=import-error
import requests
from aiida.orm import load_node # pylint: disable=import-error

# pylint: disable=import-error
from aiida.schedulers.datastructures import (
JobInfo,
JobState,
NodeNumberJobResource,
)
import requests

from .config import Config
from .variables import CONFIG_FILE
Expand Down Expand Up @@ -114,7 +112,7 @@ def _parse_submit_output(self, retval, stdout, stderr):
command returned by _get_submit_command command.
"""
if stderr.strip():
self.logger.warning(f"Stderr when submitting: {stderr.strip()}")
self.logger.warning(f"Stderr while submitting: {stderr.strip()}")

output = stdout.strip()

Expand Down Expand Up @@ -162,23 +160,17 @@ def _send_webhook(self, webhook_url, **argv):
}

response = requests.get(webhook_url, params=params)

if response.status_code == 200:
self.logger.debug(f"Webhook for {argv['payload']} \
successfully sent.")
else:
self.logger.error(f"Failed to send webhook: \
if response.status_code != 200:
self.logger.error(f"Webhook received an error: \
{response.status_code}, {response.text}")

def _prepare_task_data(self, aiida_node):
"""Prepare the task information for the webhook."""
data = {
'payload': aiida_node.label,
'status': _process_status(aiida_node)
return {
'payload': aiida_node.label,
'status': _process_status(aiida_node)
}

return data

def handle_task_submission(self, aiida_node, webhook_url):
"""Handle the task submission, preparing
data and sending it to the webhook.
Expand All @@ -188,7 +180,7 @@ def handle_task_submission(self, aiida_node, webhook_url):


def _process_status(node) -> str:
"""Recive correct node status from node."""
"""Receive correct node status from node."""
status = node.process_state.value

if status.lower() == "finished":
Expand Down

0 comments on commit 7435cdd

Please sign in to comment.