settings = process_manager.service(ConfigObject) settings['analysisName'] = 'esk112_parallel_fork_demo' settings['version'] = 0 # --- now set up the chains and links ch = Chain('Start') ch.n_fork = 100 fe = core_ops.ForkExample() fe.store_key = 'forkstoredemo' fe.logger.log_level = LogLevel.DEBUG ch.add(fe) dc = core_ops.ForkDataCollector() dc.keys = [{'key_ds': fe.store_key, 'func': len}] dc.logger.log_level = LogLevel.DEBUG ch.add(dc) ch = Chain('Overview') link = core_ops.PrintDs() link.keys = [fe.store_key] ch.add(link) logger.debug('Done parsing configuration file esk112_parallel_fork_demo.') if __name__ == "__main__": import escore escore.eskapade_run()
# --- example loops over the first chain 10 times. if settings['do_example']: # --- a loop is set up in the chain MyChain. # we iterate over the chain until the link RepeatChain is done. # then move on to the next chain (Overview) ch = Chain('MyChain') link = core_ops.HelloWorld(name='HelloWorld') link.logger.log_level = LogLevel.DEBUG ch.add(link) # --- this link sends out a signal to repeat the execution of the chain. # It serves as the 'continue' statement of the loop. # go back to start of the chain until counter reaches 10. repeater = core_ops.RepeatChain() # repeat max of 10 times repeater.maxcount = 10 repeater.logger.log_level = LogLevel.DEBUG ch.add(repeater) # --- print contents of the datastore. # which in this case is empty. overview = Chain('Overview') pds = core_ops.PrintDs(name='End') overview.add(pds) ######################################################################################### logger.debug('Done parsing configuration file esk107_chain_looper')
######################################################################################### # --- now set up the chains and links based on configuration flags ds = process_manager.service(DataStore) ds['hello'] = 'world' ds['d'] = {'a': 1, 'b': 2, 'c': 3} ######################################################################################### # --- now set up the chains and links based on configuration flags ch = Chain('Overview') # 1. printdatastore prints an overview of the contents in the datastore # at the state of executing the link. # The overview consists of list of keys in the datastore and and the object types. link = core_ops.PrintDs(name='printer1') # keys are the items for which the contents of the actual item is printed. link.keys = ['hello', 'd'] ch.add(link) # 2. This link will start a python session. # from this session, one can access the datastore and the configobject with: # >>> ds # or # >>> settings # Try to add something to the datastore in this session! # >>> ds['foo'] = 'bar' if not settings['TESTING']: link = core_ops.IPythonEmbed() ch.add(link)
ch = Chain('chain1') # the link ToDsDict adds objects to the datastore # by default this happens at the execution of the link. # (optionally, this can be done at initialization.) # Here it is used as a dummy data generator. link = core_ops.ToDsDict(name='intods_1') link.obj = f # copydict = true: all items in dict f are added to the datastore link.copydict = True ch.add(link) # print contents of datastore link = core_ops.PrintDs() link.keys = ['n_favorite', 'hello'] ch.add(link) ######### # chain 2 # - asserting the presence of items in the datastore. # - deleting individual items from the datastore. ch = Chain('chain2') # the link AssertInDs checks the presence # of certain objects in the datastore link = core_ops.AssertInDs() link.keySet = ['hello', 'n_favorite'] ch.add(link)