Skip to content
Snippets Groups Projects
Select Git revision
  • 8775aca047e94e64d744c87dad0bffc3a90bfe6d
  • main default protected
  • parcoach
  • fix-rma-lockunlock
  • paper_repro
  • fortran
  • usertypes
  • must-toolcoverage
  • toolcoverage
  • tools
  • must-json
  • merged
  • tools-parallel
  • coll
  • rma
  • dtypes
  • p2p
  • infrastructure-patch-3
  • infrastructure-patch2
  • devel-TJ
  • infrasructure-patch-1
21 results

Instruction.py

Blame
  • Instruction.py 1.35 KiB
    #! /usr/bin/python3
    from __future__ import annotations
    
    from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
    
    
    class Instruction(object):
        """
        Base class to represent an Instruction
        the identifier is used, in order to reference that instruction in the Template Manager (e.g. to change it). can be None
        """
    
        def __init__(self, str_representation: str, rank: str | int = 'all', identifier: str = None):
            self._str_representation = str_representation
            self._has_error = False
            self._identifier = identifier
            if isinstance(rank, str):
                assert rank in ['all', 'not0']
            self._rank = rank
    
        def set_has_error(self, has_error: bool = True):
            self._has_error = has_error
    
        def get_identifier(self) -> str:
            return self._identifier
    
        def set_identifier(self, identifier: str):
            self._identifier = identifier
    
        def get_ranks_executing(self) -> str | int:
            return self._rank
    
        def set_ranks_executing(self, rank: str | int):
            if isinstance(rank, str):
                assert rank in ['all', 'not0']
            self._rank = rank
    
        def __str__(self):
            if self._has_error:
                return ERROR_MARKER_COMMENT_BEGIN + self._str_representation + ERROR_MARKER_COMMENT_END
            else:
                return self._str_representation