def test_graphql_query_preproc(): """It should format graphql query fragments from the input data.""" pipe = graphql_query(['a', 'b', 'c']) assert pipe.args[0] == dedent(''' a b c ''') pipe = graphql_query({'a': None, 'b': None, 'c': None}) assert pipe.args[0] == dedent(''' a b c ''') pipe = graphql_query({'a': None, 'b': ['ba', 'bb'], 'c': None}) assert pipe.args[0] == dedent(''' a c b { ba bb } ''')
def get_pipe(opts, formatter, scan_dir=None): """Construct a pipe for listing flows.""" if scan_dir: pipe = scan(scan_dir=scan_dir) elif opts.source: pipe = scan_multi( Path(path).expanduser() for path in glbl_cfg().get(['install', 'source dirs']) ) opts.states = {'stopped'} else: pipe = scan show_running = 'running' in opts.states show_paused = 'paused' in opts.states show_active = show_running or show_paused or 'stopping' in opts.states # show_active = bool({'running', 'paused'} & opts.states) show_inactive = bool({'stopped'} & opts.states) # filter by flow name if opts.name: pipe |= filter_name(*opts.name) # filter by flow state if show_active: pipe |= is_active(True, filter_stop=(not show_inactive)) elif show_inactive: pipe |= is_active(False) # get contact file information if show_active: pipe |= contact_info graphql_fields = {} graphql_filters = set() # filter paused/running flows if show_active and not (show_running and show_paused): graphql_fields['status'] = None graphql_filters.add((('status',), tuple(opts.states))) # get fancy data if requested if formatter == _format_rich: # graphql_fields['status'] = None graphql_fields.update(RICH_FIELDS) # add graphql queries / filters to the pipe if show_active and graphql_fields: pipe |= graphql_query(graphql_fields, filters=graphql_filters) elif opts.ping: # check the flow is running even if not required # by display format or filters pipe |= graphql_query({'status': None}) # yield results as they are processed pipe.preserve_order = False return pipe
async def test_scan_sigstop(flow, scheduler, run, one_conf, test_dir, caplog): """It should log warnings if workflows are un-contactable. Note: This replaces tests/functional/cylc-scan/02-sigstop.t last found in Cylc Flow 8.0a2 which used sigstop to make the flow unresponsive. """ # run a workflow reg = flow(one_conf) schd = scheduler(reg) async with run(schd): # stop the server to make the flow un-responsive schd.server.stop() # try scanning the workflow pipe = scan(test_dir) | graphql_query(['status']) caplog.clear() async for flow in pipe: raise Exception("There shouldn't be any scan results") # there should, however, be a warning name = Path(reg).name assert [(level, msg) for _, level, msg in caplog.record_tuples] == [ (30, f'Workflow not running: {name}') ]
def get_pipe(opts, formatter, scan_dir=None): """Construct a pipe for listing flows.""" if scan_dir: pipe = scan(scan_dir=scan_dir) else: pipe = scan show_running = 'running' in opts.states show_held = 'held' in opts.states show_active = show_running or show_held or 'stopping' in opts.states # show_active = bool({'running', 'held'} & opts.states) show_inactive = bool({'stopped'} & opts.states) # filter by flow name if opts.name: pipe |= filter_name(*opts.name) # filter by flow state if show_active: pipe |= is_active(True, filter_stop=(not show_inactive)) elif show_inactive: pipe |= is_active(False) # get contact file information if show_active: pipe |= contact_info graphql_fields = {} graphql_filters = set() # filter held/running flows if show_active and not (show_running and show_held): graphql_fields['status'] = None graphql_filters.add((('status', ), tuple(opts.states))) # get fancy data if requested if formatter == _format_rich: # graphql_fields['status'] = None graphql_fields.update(RICH_FIELDS) # add graphql queries / filters to the pipe if show_active and graphql_fields: pipe |= graphql_query(graphql_fields, filters=graphql_filters) # yield results as they are processed pipe.preserve_order = False return pipe