Skip to content

Commit

Permalink
Implemented actors execs stop which maps to actors.deleteMessages(). C…
Browse files Browse the repository at this point in the history
…loses #255
  • Loading branch information
mwvaughn committed Apr 23, 2021
1 parent 14d2741 commit 8bd60e0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ tapis.cli =
actors_execs_show = tapis_cli.commands.taccapis.v2.actors:ActorsExecsShow
actors_execs_list = tapis_cli.commands.taccapis.v2.actors:ActorsExecsList
actors_execs_logs = tapis_cli.commands.taccapis.v2.actors:ActorsExecsLogs
actors_execs_stop = tapis_cli.commands.taccapis.v2.actors:ActorsExecsStop
actors_aliases_show = tapis_cli.commands.taccapis.v2.actors:ActorsAliasesShow
actors_aliases_delete = tapis_cli.commands.taccapis.v2.actors:ActorsAliasesDelete
actors_aliases_list = tapis_cli.commands.taccapis.v2.actors:ActorsAliasesList
Expand Down
1 change: 1 addition & 0 deletions tapis_cli/commands/taccapis/v2/actors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .execs_show import ActorsExecsShow
from .execs_list import ActorsExecsList
from .execs_logs import ActorsExecsLogs
from .execs_stop import ActorsExecsStop
from .workers_list import ActorsWorkersList
from .workers_show import ActorsWorkersShow
from .workers_delete import ActorsWorkersDelete
Expand Down
53 changes: 53 additions & 0 deletions tapis_cli/commands/taccapis/v2/actors/execs_stop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from tapis_cli.display import Verbosity
from tapis_cli.utils import fnmatches
from .mixins import ActorIdentifier

from . import API_NAME, SERVICE_VERSION
from .formatters import ActorsFormatOne
from .models import Execution
from .mixins import GlobListFilter

__all__ = ['ActorsExecsStop']


class ActorsExecsStop(ActorsFormatOne, ActorIdentifier):

HELP_STRING = 'Delete queued messages from the Actor mailbox, preventing their execution. Running executions will continue.'
LEGACY_COMMMAND_STRING = None

VERBOSITY = Verbosity.BRIEF
EXTRA_VERBOSITY = Verbosity.RECORD
FILTERABLE_KEYS = Execution.FILTERABLE_KEYS
ACCEPT_NONCE = True

def get_parser(self, prog_name):
parser = super(ActorsExecsStop, self).get_parser(prog_name)
parser = ActorIdentifier.extend_parser(self, parser)
return parser

def take_action(self, parsed_args):
parsed_args = self.preprocess_args(parsed_args)
actor_id = ActorIdentifier.get_identifier(self, parsed_args)
orig_messages_count = self.tapis_client.actors.getMessages(
actorId=actor_id, **self.client_extra_args).get('messages', -1)
try:
results = self.tapis_client.actors.deleteMessages(
actorId=actor_id, **self.client_extra_args)
except KeyError:
# The KeyError is raised because the OpenAPI def for
# deleteMessages is missing the corresponding
# response class. It is OK to swallow this error.
# TODO - remove this once ActorMessagesDeleteResponse is added to https://github.com/TACC/agavepy/blob/bd948d6da9be7e84b5330aa4d5fe1e07d82ad34c/agavepy/resources/api_actors.json.j2
pass
except Exception:
raise
new_messages_count = self.tapis_client.actors.getMessages(
actorId=actor_id, **self.client_extra_args).get('messages', -1)
# custom headers to print all the execution id and status for a
# given actor id
headers = [
"original_message_queue_length", "current_message_queue_length"
]
records = [orig_messages_count, new_messages_count]

return (tuple(headers), tuple(records))

0 comments on commit 8bd60e0

Please sign in to comment.