Source code for plynx.constants.node_enums

"""Node constants"""
from typing import Set

from bson.objectid import ObjectId


[docs]class NodeRunningStatus: """Running status enum"""
[docs] STATIC: str = 'STATIC'
[docs] CREATED: str = 'CREATED'
[docs] READY: str = 'READY'
[docs] IN_QUEUE: str = 'IN_QUEUE'
[docs] RUNNING: str = 'RUNNING'
[docs] SUCCESS: str = 'SUCCESS'
[docs] RESTORED: str = 'RESTORED'
[docs] FAILED: str = 'FAILED'
[docs] FAILED_WAITING: str = 'FAILED_WAITING'
[docs] CANCELED: str = 'CANCELED'
[docs] SPECIAL: str = 'SPECIAL'
[docs] _FAILED_STATUSES: Set[str] = { FAILED, CANCELED, FAILED_WAITING,
}
[docs] _SUCCEEDED_STATUSES: Set[str] = { STATIC, SUCCESS, RESTORED, SPECIAL,
}
[docs] _AWAITING_STATUSES: Set[str] = { READY, IN_QUEUE, RUNNING,
}
[docs] _NON_CHANGEABLE_STATUSES: Set[str] = { STATIC, SPECIAL,
}
[docs] _FINISHED_STATUSES: Set[str] = _FAILED_STATUSES | _SUCCEEDED_STATUSES
@staticmethod
[docs] def is_finished(node_running_status: str) -> bool: """Check if the status is final""" return node_running_status in NodeRunningStatus._FINISHED_STATUSES
@staticmethod
[docs] def is_succeeded(node_running_status: str) -> bool: """Check if the status is final and successful""" return node_running_status in NodeRunningStatus._SUCCEEDED_STATUSES
@staticmethod
[docs] def is_failed(node_running_status: str) -> bool: """Check if the status is final and failed""" return node_running_status in NodeRunningStatus._FAILED_STATUSES
@staticmethod
[docs] def is_non_changeable(node_running_status: str) -> bool: """Check if the status is in static or special""" return node_running_status in NodeRunningStatus._NON_CHANGEABLE_STATUSES
[docs]class NodeStatus: """Node permanent status"""
[docs] CREATED: str = 'CREATED'
[docs] READY: str = 'READY'
[docs] DEPRECATED: str = 'DEPRECATED'
[docs] MANDATORY_DEPRECATED: str = 'MANDATORY_DEPRECATED'
[docs]class NodePostAction: """HTTP post action"""
[docs] SAVE: str = 'SAVE'
[docs] APPROVE: str = 'APPROVE'
[docs] CREATE_RUN: str = 'CREATE_RUN'
[docs] CREATE_RUN_FROM_SCRATCH: str = 'CREATE_RUN_FROM_SCRATCH'
[docs] CLONE: str = 'CLONE'
[docs] VALIDATE: str = 'VALIDATE'
[docs] DEPRECATE: str = 'DEPRECATE'
[docs] MANDATORY_DEPRECATE: str = 'MANDATORY_DEPRECATE'
[docs] PREVIEW_CMD: str = 'PREVIEW_CMD'
[docs] REARRANGE_NODES: str = 'REARRANGE_NODES'
[docs] UPGRADE_NODES: str = 'UPGRADE_NODES'
[docs] CANCEL: str = 'CANCEL'
[docs] GENERATE_CODE: str = 'GENERATE_CODE'
[docs]class NodePostStatus: """Standard HTTP response status"""
[docs] SUCCESS: str = 'SUCCESS'
[docs] FAILED: str = 'FAILED'
[docs] VALIDATION_FAILED: str = 'VALIDATION_FAILED'
[docs]class NodeClonePolicy: """Clone algorithm"""
[docs] NODE_TO_NODE: int = 0
[docs] NODE_TO_RUN: int = 1
[docs] RUN_TO_NODE: int = 2
[docs]class NodeVirtualCollection: """Virtual collection"""
[docs] OPERATIONS: str = 'operations'
[docs] WORKFLOWS: str = 'workflows'
[docs]class SpecialNodeId: """Special Node IDs in the workflows"""
[docs] INPUT: ObjectId = ObjectId('2419f9500000000000000000')
[docs] OUTPUT: ObjectId = ObjectId('56274ccc0000000000000000')
[docs]class NodeOrigin: """Enum that indicates where the Node came from"""
[docs] DB: str = "DB"
[docs] BUILT_IN_HUBS: str = "BUILT_IN_HUBS"
[docs]IGNORED_CACHE_PARAMETERS = {'cmd', '_timeout'}