Skip to content

Commit

Permalink
added scan to schema and resolvers
Browse files Browse the repository at this point in the history
added name to CONTRIBUTING.md
  • Loading branch information
Mark Dawson committed Sep 13, 2023
1 parent 0f3205a commit d222a4b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ below.
- David Matthews
- Mel Hall
- Christopher Bennett
- Mark Dawson
<!-- end-shortlog -->

(All contributors are identifiable with email addresses in the git version
Expand Down
20 changes: 17 additions & 3 deletions cylc/uiserver/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down Expand Up @@ -534,24 +543,29 @@ 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,
self.workflows_mgr,
log=self.log,
executor=self.executor
)

elif command == 'play':
return await Services.play(
workflows,
kwargs,
self.workflows_mgr,
log=self.log
)
elif command == 'scan':
return await Services.scan(
kwargs,
self.workflows_mgr
)

raise NotImplementedError()

Expand Down
12 changes: 12 additions & 0 deletions cylc/uiserver/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions cylc/uiserver/tests/test_authorise.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"reload",
"remove",
"resume",
"scan",
"set_graph_window_extent",
"set_hold_point",
"set_outputs",
Expand All @@ -66,6 +67,7 @@
"reload",
"remove",
"resume",
"scan",
"set_graph_window_extent",
"set_hold_point",
"set_outputs",
Expand Down Expand Up @@ -126,6 +128,7 @@
"play",
"trigger",
"resume",
"scan",
"set_verbosity",
"set_graph_window_extent",
"read",
Expand Down

0 comments on commit d222a4b

Please sign in to comment.