Skip to content

Commit b043bb9

Browse files
authored
Merge pull request #493 from markgrahamdawson/feature-add-scan-mutation
Feature add scan mutation
2 parents 0305779 + d222a4b commit b043bb9

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ below.
5858
- David Matthews
5959
- Mel Hall
6060
- Christopher Bennett
61+
- Mark Dawson
6162
<!-- end-shortlog -->
6263

6364
(All contributors are identifiable with email addresses in the git version

cylc/uiserver/resolvers.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ async def clean(
279279
await workflows_mgr.scan()
280280
return cls._return("Workflow(s) cleaned")
281281

282+
@classmethod
283+
async def scan(
284+
cls,
285+
args: dict,
286+
workflows_mgr: 'WorkflowsManager',
287+
):
288+
await workflows_mgr.scan()
289+
return cls._return("Scan requested")
290+
282291
@classmethod
283292
async def play(cls, workflows, args, workflows_mgr, log):
284293
"""Calls `cylc play`."""
@@ -534,24 +543,29 @@ async def service(
534543
info: 'ResolveInfo',
535544
command: str,
536545
workflows: Iterable['Tokens'],
537-
kwargs: Dict[str, Any]
546+
kwargs: Dict[str, Any],
538547
) -> List[Union[bool, str]]:
539-
if command == 'clean':
548+
549+
if command == 'clean': # noqa: SIM116
540550
return await Services.clean(
541551
workflows,
542552
kwargs,
543553
self.workflows_mgr,
544554
log=self.log,
545555
executor=self.executor
546556
)
547-
548557
elif command == 'play':
549558
return await Services.play(
550559
workflows,
551560
kwargs,
552561
self.workflows_mgr,
553562
log=self.log
554563
)
564+
elif command == 'scan':
565+
return await Services.scan(
566+
kwargs,
567+
self.workflows_mgr
568+
)
555569

556570
raise NotImplementedError()
557571

cylc/uiserver/schema.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,17 @@ class Arguments:
270270
result = GenericScalar()
271271

272272

273+
class Scan(graphene.Mutation):
274+
class Meta:
275+
description = sstrip('''
276+
Scan the filesystem for file changes.
277+
278+
Valid for: stopped workflows.
279+
''')
280+
resolver = partial(mutator, command='scan')
281+
result = GenericScalar()
282+
283+
273284
async def get_jobs(root, info, **kwargs):
274285
if kwargs['live']:
275286
return await get_nodes_all(root, info, **kwargs)
@@ -545,6 +556,7 @@ class Logs(graphene.ObjectType):
545556
class UISMutations(Mutations):
546557
play = _mut_field(Play)
547558
clean = _mut_field(Clean)
559+
scan = _mut_field(Scan)
548560

549561

550562
schema = graphene.Schema(

cylc/uiserver/tests/test_authorise.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"reload",
4343
"remove",
4444
"resume",
45+
"scan",
4546
"set_graph_window_extent",
4647
"set_hold_point",
4748
"set_outputs",
@@ -66,6 +67,7 @@
6667
"reload",
6768
"remove",
6869
"resume",
70+
"scan",
6971
"set_graph_window_extent",
7072
"set_hold_point",
7173
"set_outputs",
@@ -126,6 +128,7 @@
126128
"play",
127129
"trigger",
128130
"resume",
131+
"scan",
129132
"set_verbosity",
130133
"set_graph_window_extent",
131134
"read",

0 commit comments

Comments
 (0)