def __init__(self): self.configname = './tests/test_configs/tasks.cfg' Settings.init(config_file=self.configname) ContextLogger.createLoggingHandlers(config=Settings.config) self.taskdir = Settings.config.get('tasks', 'savedir') if not os.path.isdir(self.taskdir): os.mkdir(self.taskdir) savename = Settings.config.get('tasks', 'savename') self.taskfile = self.taskdir + savename + '.json'
def main(): Settings.init() print('Settings file: "{}"'.format(Settings.fileName())) q = Queue(1) pandaScene = PandaScene() sceneGraphManager = SceneGraphManager(pandaScene) eventManager = EventManager(sceneGraphManager) gui = GuiThread(q, eventManager) gui.start() pandaScene.run()
def test_simulate_multidomain(self): '''Run HDC policy for domains in 2 multi domain dialogues ''' Settings.init(config_file='./tests/test_configs/simulate_multiDomains_HDC.cfg') ContextLogger.createLoggingHandlers(config=Settings.config) logger = ContextLogger.getLogger('') logger.info("Starting HDC Multidomain Simulation") reload(Ontology.FlatOntologyManager) # since this has a singleton class Ontology.init_global_ontology() simulator = Simulate.SimulationSystem(error_rate=0.1) simulator.run_dialogs(2) # run 2 dialogues
def test_simulate_multidomain(self): '''Run 2 dialogues with the multidomain system and GP policies (NB: config needs to explicitly set each domain to use gp actually...) ''' Settings.init(config_file='./tests/test_configs/simulate_multiDomains_GP.cfg') ContextLogger.createLoggingHandlers(config=Settings.config) logger = ContextLogger.getLogger('') logger.info("Starting GP Multidomain Simulation") reload(Ontology.FlatOntologyManager) # since this has a singleton class Ontology.init_global_ontology() simulator = Simulate.SimulationSystem(error_rate=0.1) simulator.run_dialogs(2) # run 2 dialogues
def test_simulate_singledomain_for_all_domains(self): '''Loop over all domains and runs 2 dialogues with GP policy in each ''' import numpy.random as nprand # not seeding this - so will be based on system clock--> meaning TESTING here will be somewhat random --> # NOTE --> THIS IS !!!REALLY REALLY REALLY!!! NOT IN THE SPIRIT OF (UNIT) TESTING - WHICH SHOULD NEVER BE ~RANDOM # doing it to get a little more coverage of testing without writing permutations of explicit tests ... Settings.init( config_file= './tests/test_configs/simulate_singledomain_for_all_domains.cfg') ContextLogger.createLoggingHandlers(config=Settings.config) logger = ContextLogger.getLogger('') domains = TestingUtils.get_loop_over_domains() for dstring in domains: Settings.config.set("GENERAL", 'domains', dstring) logger.info("Starting GP Single Domain Simulation for " + dstring) # [policy_DOMAINTAG] Settings.config.add_section('policy_' + dstring) Settings.config.set('policy_' + dstring, 'learning', 'True') Settings.config.set('policy_' + dstring, 'policytype', 'gp') # no inpolicy file give --> starts with empty file (random policy) Settings.config.set('policy_' + dstring, 'outpolicyfile', 'tests/test_gp/' + dstring) if nprand.uniform() > 0.5: Settings.config.set('policy_' + dstring, 'belieftype', 'baseline') else: Settings.config.set('policy_' + dstring, 'belieftype', 'focus') # [gppolicy_DOMAINTAG] Settings.config.add_section('gppolicy_' + dstring) if nprand.uniform() > 0.5: Settings.config.set('gppolicy_' + dstring, 'kernel', 'polysort') else: Settings.config.set('gppolicy_' + dstring, 'kernel', 'gausssort') if nprand.uniform() > 0.5: Settings.config.set('gppolicy_' + dstring, 'actionkerneltype', 'delta') else: Settings.config.set('gppolicy_' + dstring, 'actionkerneltype', 'hdc') reload(Ontology.FlatOntologyManager ) # since this has a singleton class Ontology.init_global_ontology() simulator = Simulate.SimulationSystem(error_rate=0.1) simulator.run_dialogs(2) # run 2 dialogues
def test_simulate_singledomain_for_all_domains(self): '''Loop over all domains and run 2 dialogues via HDC policy in each ''' Settings.init(config_file='./tests/test_configs/simulate_singledomain_for_all_domains.cfg') ContextLogger.createLoggingHandlers(config=Settings.config) logger = ContextLogger.getLogger('') domains = TestingUtils.get_loop_over_domains() for dstring in domains: Settings.config.set("GENERAL", 'domains', dstring) # no policy settings given --> defaults to HDC logger.info("Starting HDC Single Domain Simulation for "+dstring) reload(Ontology.FlatOntologyManager) # since this has a singleton class Ontology.init_global_ontology() simulator = Simulate.SimulationSystem(error_rate=0.1) simulator.run_dialogs(2) # run 2 dialogues
def do(self, pandaScene: PandaScene): node = pandaScene.getMainNode() node.children.clear() class QtCommands(): "Classes to do main job for qt ui action" class ActorAdded(): def __init__(self, name: str): self.name = name def do(self, wnd: MainWindow): wnd.ModelAdded(self.name) if __name__ == "__main__": Settings.init(applicationName='ai_object_browser') print('Settings file: "{}"'.format(Settings.fileName())) from queue import Queue pandaThreadQeue = Queue(16) app = QtWidgets.QApplication(sys.argv) m = MainWindow() PandaSceneThread = PandaSceneThread() PandaSceneThread.start() m.show() app.exec_() print('app.exec_()') PandaSceneThread.stop()
type=argparse.FileType('r')) parser.add_argument('-n', '--number', help='set the number of dialogues', type=int) parser.add_argument('-r', '--error', help='set error rate', type=int) parser.set_defaults(use_color=True) parser.add_argument('--nocolor', dest='use_color', action='store_false', help='no color in logging. best to\ turn off if dumping to file. Will be overriden by [logging] config setting of "usecolor=".' ) parser.add_argument('-s', '--seed', help='set random seed', type=int) args = parser.parse_args() if args.error is None: args.error = 0 # default simulated error rate if args.number is None: args.number = 1 # default number of dialogs seed = Settings.init(config_file=args.config.name, seed=args.seed) ContextLogger.createLoggingHandlers(config=Settings.config, use_color=args.use_color) logger.info("Random Seed is {}".format(seed)) Ontology.init_global_ontology() simulator = SimulationSystem(error_rate=float(args.error) / 100) simulator.run_dialogs(args.number) #END OF FILE
''' from utils import Settings, ContextLogger from topictracking import TopicTracking from ontology import Ontology from utils.DiaAct import DiaAct, DiaActWithProb import time, re logger = ContextLogger.getLogger('') __author__ = "cued_dialogue_systems_group" __version__ = Settings.__version__ import os global seed seed = Settings.init(os.getcwd() + "/pydial/config/Tut-hdc-CamInfo.cfg", None) global Ontology Ontology.init_global_ontology() #---------------------------------------------------------------- # DIALOGUE AGENT #---------------------------------------------------------------- class DialogueAgent(object): ''' Contains all components required for multi domain dialogue: {topic tracking, semi belief tracking, policy, semo} - each of these components is a manager for that ability for all domains. - DialogueAgent() controls the flow of calls/information passing between all of these components in order to execute a dialog ''' # pylint: disable=too-many-instance-attributes def __init__(self, agent_id='Smith', hub_id='dialogueserver'):
bcm_mapping['real2abstract'] = real2abstract bcm_mapping['abstract2real'] = abstract2real with open('slot_abstractions/'+dstring+'.json','w+') as f: import json json.dump(bcm_mapping,f, indent=4) #--------------------------------------------------------------------------------- class SlotAbstractor(object): def __init__(self): pass #--------------------------------------------------------------------------------- if __name__ == '__main__': Settings.init(config_file='../config/simulate_BCM.cfg') Ontology.init_global_ontology() domain = sys.argv[1] c = CreateSlotAbstractionMappings() if domain == 'all': from ontology import OntologyUtils for dstring in OntologyUtils.MULTIDOMAIN_GROUPS['all']: c.create(dstring) else: c.create(domain) # END OF FILE
def __init__(self): # cfg = 'tests/test_configs/dialogueserver-KUSTOM.cfg' cfg = 'tests/test_configs/dialogueserver-Films.cfg' assert (os.path.exists(cfg)) Settings.init(config_file=cfg) ContextLogger.createLoggingHandlers(config=Settings.config)
self.names = names def do(self, pandaScene: PandaScene): node = pandaScene.getMainNode() # node.ne # self.names class QtCommands(): "Classes to do main job for qt ui action" class ActorAdded(): def __init__(self, name: str): self.name = name def do(self, wnd: MainWindow): wnd.ModelAdded(self.name) if __name__ == "__main__": Settings.init() print('Settings file: "{}"'.format(Settings.fileName())) app = QtWidgets.QApplication(sys.argv) m = MainWindow() PandaSceneThread = PandaSceneThread() PandaSceneThread.start() m.show() app.exec_() print('app.exec_()') PandaSceneThread.stop()
from parlai.core.worlds import validate from parlai.mturk.core.worlds import MTurkOnboardWorld, MTurkTaskWorld import Texthub import argparse, re, os, sys, random from Agent import DialogueAgent from utils import ContextLogger from utils import Settings from ontology import Ontology __author__ = "cued_dialogue_systems_group" __version__ = Settings.__version__ global seed #seed = Settings.init("/home/t-xinxu/ParlAI/parlai/mturk/tasks/pydail_collection/config/Tut-hdc-CamInfo.cfg", None) seed = Settings.init("./config/Tut-hdc-CamInfo.cfg", None) global Ontology Ontology.init_global_ontology() class QADataCollectionOnboardWorld(MTurkOnboardWorld): def parley(self): ad = {} ad['id'] = 'System' ad['text'] = 'Welcome onboard!' self.mturk_agent.observe(ad) self.mturk_agent.act() self.episodeDone = True class QADataCollectionWorld(MTurkTaskWorld):