async def test_api_version(): """It should filter flows by api version.""" version = ContactFileFields.API pipe = api_version('>= 4, < 5') assert await pipe.func( {version: '4'}, *pipe.args ) pipe = api_version('>= 4, < 5') assert not await pipe.func( {version: '5'}, *pipe.args )
def __init__(self, uiserver, log, context=None, run_dir=None) -> None: self.uiserver = uiserver self.log = log if context is None: self.context = zmq.asyncio.Context() else: self.context = context self.owner = getuser() # all workflows currently tracked self.workflows: 'Dict[str, Dict]' = {} # the "workflow pipe" used to detect workflows on the filesystem self._scan_pipe = ( # all flows on the filesystem scan(run_dir) # stop here is the flow is stopped, else... | is_active(is_active=True, filter_stop=False) # extract info from the contact file | contact_info # only flows which are using the same api version | api_version(f'=={API}')) # queue for requesting new scans, valid queued values are: # * True - (stop=True) The stop signal (stops the scanner) # * False - (stop=False) Request a new scan # * None - The "stopped" signal, sent after the scan task has stooped self._queue: 'asyncio.Queue[Union[bool, None]]' = asyncio.Queue() # signal that the scanner is stopping, subsequent scan requests # will be ignored self._stopping = False
def __init__(self, uiserver, context=None, run_dir=None): self.uiserver = uiserver if context is None: self.context = zmq.asyncio.Context() else: self.context = context self.owner = getuser() self.active = {} self.stopping = set() self.inactive = set() self._scan_pipe = ( # all flows on the filesystem scan(run_dir) # only flows which have a contact file # | is_active(True) # stop here is the flow is stopped, else... | is_active(True, filter_stop=False) # extract info from the contact file | contact_info # only flows which are using the same api version | api_version(f'=={API}'))