예제 #1
0
파일: __test__.py 프로젝트: fishroot/nemoa
    def test_session_list(self):

        with self.subTest(cmd="nemoa.list('bases')"):
            test = 'user' in nemoa.list('bases')
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('workspaces')"):
            worktree = nemoa.list('workspaces')
            test = isinstance(worktree, dict) \
                and 'user' in worktree \
                and 'site' in worktree \
                and 'cwd' in worktree
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('workspaces', base = 'site')"):
            workspaces = nemoa.list('workspaces', base='site')
            test = isinstance(workspaces, list) \
                and 'testsuite' in workspaces
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('workspaces', base = 'user')"):
            workspaces = nemoa.list('workspaces', base='user')
            test = isinstance(workspaces, list)
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('datasets')"):
            datasets = nemoa.list('datasets')
            test = isinstance(datasets, list) \
                and 'linear' in datasets \
                and 'logistic' in datasets \
                and 'sinus' in datasets
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('networks')"):
            networks = nemoa.list('networks')
            test = isinstance(networks, list) \
                and 'deep' in networks \
                and 'shallow' in networks
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('systems')"):
            systems = nemoa.list('systems')
            test = isinstance(systems, list) \
                and 'ann' in systems \
                and 'dbn' in systems \
                and 'grbm' in systems \
                and 'rbm' in systems
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('models')"):
            models = nemoa.list('models')
            test = isinstance(models, list) and 'test' in models
            self.assertTrue(test)

        with self.subTest(cmd="nemoa.list('scripts')"):
            scripts = nemoa.list('scripts')
            test = isinstance(scripts, list)
            self.assertTrue(test)
예제 #2
0
파일: cli.py 프로젝트: fishroot/nemoa
def print_workspaces() -> None:
    """Print list of workspaces to standard output."""
    nemoa.set('mode', 'silent')
    workspaces = nemoa.list('workspaces', base='user')
    ui.info('Workspaces:\n')
    for workspace in workspaces:
        ui.info('    %s' % (workspace))
    ui.info('')
예제 #3
0
파일: cli.py 프로젝트: fishroot/nemoa
def print_workspaces() -> None:
    """Print list of workspaces to standard output."""
    nemoa.set('mode', 'silent')
    workspaces = nemoa.list('workspaces', base='user')
    ui.info('Workspaces:\n')
    for workspace in workspaces:
        ui.info('    %s' % (workspace))
    ui.info('')
예제 #4
0
파일: cli.py 프로젝트: fishroot/nemoa
def print_scripts(workspace: str) -> None:
    """Print list of scripts to standard output."""
    nemoa.set('mode', 'silent')

    if nemoa.open(workspace):
        ui.info('Scripts in workspace %s:\n' % (nemoa.get('workspace')))
        for script in nemoa.list('scripts'):
            ui.info('    %s' % (script))
        ui.info('')
예제 #5
0
파일: cli.py 프로젝트: fishroot/nemoa
def print_scripts(workspace: str) -> None:
    """Print list of scripts to standard output."""
    nemoa.set('mode', 'silent')

    if nemoa.open(workspace):
        ui.info('Scripts in workspace %s:\n' % (nemoa.get('workspace')))
        for script in nemoa.list('scripts'):
            ui.info('    %s' % (script))
        ui.info('')
예제 #6
0
    def test_session_path(self):
        with self.subTest(cmd="nemoa.path('basepath')"):
            test = isinstance(nemoa.path('basepath'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('baseconf')"):
            test = isinstance(nemoa.path('baseconf'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('datasets')"):
            test = isinstance(nemoa.path('datasets'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('networks')"):
            test = isinstance(nemoa.path('networks'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('systems')"):
            test = isinstance(nemoa.path('systems'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('models')"):
            test = isinstance(nemoa.path('models'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('scripts')"):
            test = isinstance(nemoa.path('scripts'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('cache')"):
            test = isinstance(nemoa.path('cache'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('inifile')"):
            test = isinstance(nemoa.path('inifile'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('logfile')"):
            test = isinstance(nemoa.path('logfile'), str)
            self.assertTrue(test)
        with self.subTest(cmd="nemoa.path('expand', )"):
            valid = nemoa.path('expand',
                               '%basepath%',
                               '%workspace%',
                               check=True)
            invalid = nemoa.path('expand',
                                 '%basepath%',
                                 '%workspace%',
                                 'invalid_path_name',
                                 check=True)
            test = valid and not invalid
            self.assertTrue(test)

        # test paths of configured objects
        objtypes = ['dataset', 'network', 'system', 'model', 'script']
        for objtype in objtypes:
            for name in nemoa.list(objtype + 's'):
                cmd = "nemoa.path('%s', '%s')" % (objtype, name)
                with self.subTest(cmd=cmd):
                    path = nemoa.path(objtype, name)
                    self.assertIsInstance(path, str)
예제 #7
0
파일: console.py 프로젝트: Goatbuster/nemoa
 def list(*args, **kwargs):
     """Wrapping function to nemoa.list()."""
     retval = nemoa.list(*args, **kwargs)
     if isinstance(retval, dict):
         for key, val in retval.items():
             if not val: continue
             if hasattr(val, '__iter__'):
                 nemoa.log('note', '%s: %s' % (key, ', '.join(val)))
             else:
                 nemoa.log('note', '%s: %s' % (key, val))
     elif hasattr(retval, '__iter__'):
         nemoa.log('note', ', '.join(retval))
     return None
예제 #8
0
    def print_workspaces():
        """Print list of workspaces to standard output."""

        import nemoa

        nemoa.set('mode', 'silent')
        workspaces = nemoa.list('workspaces', base='user')
        print('Workspaces:\n')
        for workspace in workspaces:
            print(('    %s' % (workspace)))
        print()

        return True
예제 #9
0
    def print_scripts(workspace):
        """Print list of scripts to standard output."""

        import nemoa

        nemoa.set('mode', 'silent')
        if not nemoa.open(workspace): return False
        print(('Scripts in workspace %s:\n' % (nemoa.get('workspace'))))
        for script in nemoa.list('scripts'):
            print(('    %s' % (script)))
        print()

        return True
예제 #10
0
    def list(self, type):
        """Return a list of known objects."""

        return nemoa.list(type,
                          workspace=self._get_name(),
                          base=self._get_base())