From d222a4b81fcc9858c36b013f68fd3008f179980e Mon Sep 17 00:00:00 2001 From: Mark Dawson Date: Tue, 5 Sep 2023 15:28:19 +0100 Subject: [PATCH] added scan to schema and resolvers added name to CONTRIBUTING.md --- CONTRIBUTING.md | 1 + cylc/uiserver/resolvers.py | 20 +++++++++++++++++--- cylc/uiserver/schema.py | 12 ++++++++++++ cylc/uiserver/tests/test_authorise.py | 3 +++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b68ad6a..6de00e76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,7 @@ below. - David Matthews - Mel Hall - Christopher Bennett + - Mark Dawson (All contributors are identifiable with email addresses in the git version diff --git a/cylc/uiserver/resolvers.py b/cylc/uiserver/resolvers.py index 3e8251da..e1e85e47 100644 --- a/cylc/uiserver/resolvers.py +++ b/cylc/uiserver/resolvers.py @@ -279,6 +279,15 @@ async def clean( await workflows_mgr.scan() return cls._return("Workflow(s) cleaned") + @classmethod + async def scan( + cls, + args: dict, + workflows_mgr: 'WorkflowsManager', + ): + await workflows_mgr.scan() + return cls._return("Scan requested") + @classmethod async def play(cls, workflows, args, workflows_mgr, log): """Calls `cylc play`.""" @@ -534,9 +543,10 @@ async def service( info: 'ResolveInfo', command: str, workflows: Iterable['Tokens'], - kwargs: Dict[str, Any] + kwargs: Dict[str, Any], ) -> List[Union[bool, str]]: - if command == 'clean': + + if command == 'clean': # noqa: SIM116 return await Services.clean( workflows, kwargs, @@ -544,7 +554,6 @@ async def service( log=self.log, executor=self.executor ) - elif command == 'play': return await Services.play( workflows, @@ -552,6 +561,11 @@ async def service( self.workflows_mgr, log=self.log ) + elif command == 'scan': + return await Services.scan( + kwargs, + self.workflows_mgr + ) raise NotImplementedError() diff --git a/cylc/uiserver/schema.py b/cylc/uiserver/schema.py index cb00726b..3deb6237 100644 --- a/cylc/uiserver/schema.py +++ b/cylc/uiserver/schema.py @@ -270,6 +270,17 @@ class Arguments: result = GenericScalar() +class Scan(graphene.Mutation): + class Meta: + description = sstrip(''' + Scan the filesystem for file changes. + + Valid for: stopped workflows. + ''') + resolver = partial(mutator, command='scan') + result = GenericScalar() + + async def get_jobs(root, info, **kwargs): if kwargs['live']: return await get_nodes_all(root, info, **kwargs) @@ -545,6 +556,7 @@ class Logs(graphene.ObjectType): class UISMutations(Mutations): play = _mut_field(Play) clean = _mut_field(Clean) + scan = _mut_field(Scan) schema = graphene.Schema( diff --git a/cylc/uiserver/tests/test_authorise.py b/cylc/uiserver/tests/test_authorise.py index 9915e604..73a93a8e 100644 --- a/cylc/uiserver/tests/test_authorise.py +++ b/cylc/uiserver/tests/test_authorise.py @@ -42,6 +42,7 @@ "reload", "remove", "resume", + "scan", "set_graph_window_extent", "set_hold_point", "set_outputs", @@ -66,6 +67,7 @@ "reload", "remove", "resume", + "scan", "set_graph_window_extent", "set_hold_point", "set_outputs", @@ -126,6 +128,7 @@ "play", "trigger", "resume", + "scan", "set_verbosity", "set_graph_window_extent", "read",