Exemplo n.º 1
0
    def test_it_should_import_skills_in_a_directory_correctly(self):
        with patch('pytlas.training') as train_mock:
            with patch('pytlas.intent') as intent_mock:
                import_skills(
                    os.path.join(os.path.dirname(__file__), '../__skills'))

                expect(train_mock.call_count).to.equal(2)
                expect(intent_mock.call_count).to.equal(2)
Exemplo n.º 2
0
def list_skills():  # pragma: no cover
    """List installed skills for this instance.
    """
    import_skills(CONFIG.getpath(SKILLS_DIR))

    metas = instantiate_skill_manager().get()

    for meta in metas:
        click.echo(meta)
Exemplo n.º 3
0
def serve(data_dir, default):
    """Starts the server.
    """
    agents_factory = FromFile(data_dir, default)

    # Let's load the configuration and load the skills
    CONFIG.load_from_file(agents_factory._default_conf_path)  # pylint: disable=protected-access
    import_skills(CONFIG.getpath(SKILLS_DIR, os.path.join(data_dir, 'skills')),
                  CONFIG.getbool(WATCH))

    server = Server(agents_factory)

    with MQTTChannel() as mqtt:
        mqtt.attach(server)
        input('Press any key, anytime to stop the broker')
Exemplo n.º 4
0
def instantiate_and_fit_interpreter(training_file=None):  # pragma: no cover
    if not training_file:
        import_skills(CONFIG.getpath(SKILLS_DIR), CONFIG.getbool(WATCH))

    try:
        from pytlas.understanding.snips import SnipsInterpreter  # pylint: disable=import-outside-toplevel

        interpreter = SnipsInterpreter(CONFIG.get(LANGUAGE),
                                       CONFIG.getpath(CACHE_DIR))

        if training_file:
            interpreter.fit_from_file(training_file)
        else:
            interpreter.fit_from_skill_data()

        return interpreter
    except ImportError:
        logging.critical(
            'Could not import the "snips" interpreter, is "snips-nlu" installed?'
        )
Exemplo n.º 5
0
 def test_it_should_not_raise_error_when_skills_folder_does_not_exist(self):
     import_skills('/does/not/exists')
Exemplo n.º 6
0
 def ready(self):
     install_logs(CONFIG.getbool(VERBOSE),
                  CONFIG.getbool(DEBUG, section='web'))
     import_skills(CONFIG.getpath(SKILLS_DIR))