示例#1
0
    def test_valid_pipeline02(self):
        ok_01 = """
%labels
   GOO hello goo
   BLA hello bla
   KIVE_THREADS 100
   KIVE_MEMORY 1000
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
%help
   the simple
   help line
%bla
gggg
%runscript
   bash echo 'hello world'
"""
        app_lst = deffile.parse_string(ok_01)
        assert isinstance(app_lst, list), "list expected"
        assert len(app_lst) == 1, "one expected"
        app_dct = app_lst[0]
        assert set(
            app_dct.keys()) == deffile.AppInfo.KEY_WORD_SET, 'faulty dict keys'
        self.assertIsNone(app_dct[deffile.AppInfo.KW_ERROR_MESSAGES])
        n_thread = app_dct[deffile.AppInfo.KW_NUM_THREADS]
        self.assertEqual(100, n_thread)
        n_mem = app_dct[deffile.AppInfo.KW_MEMORY]
        assert isinstance(n_mem, int), "int expected"
        assert n_mem == 1000, "1000 expected"
示例#2
0
    def test_ignore01(self):
        """Keywords of no interest to us should be be silently ignored.
        get_io_args() should return (None, None) when KIVE_INPUTS and KIVE_OUTPUTS
        entries are missing.
        Dito get_num_threads() and get_memory().
        """
        faulty = """
%labels
   GOO hello goo
   BLA hello bla
%help
   the simple
   help line
%bla
gggg
%runscript
   bash echo 'hello world'
"""
        app_lst = deffile.parse_string(faulty)
        assert isinstance(app_lst, list), "list expected"
        assert len(app_lst) == 1, "one expected"
        app_dct = app_lst[0]
        assert isinstance(app_dct, dict), "dict expected"
        assert set(
            app_dct.keys()) == deffile.AppInfo.KEY_WORD_SET, 'faulty dict keys'
        # print("mainapp: {}".format(app_dct))
        iotup = app_dct[deffile.AppInfo.KW_IO_ARGS]
        assert iotup == (None, None), "none expected"
        assert app_dct[deffile.AppInfo.KW_NUM_THREADS] is None, "none expected"
        assert app_dct[deffile.AppInfo.KW_MEMORY] is None, "none expected"
示例#3
0
    def test_parse_whitespace_line(self):
        def_file = _DEFFILE_01.replace('\n%files', '    \n%files')
        app_list = deffile.parse_string(def_file)

        main_app = app_list[0]

        self.assertEqual('', main_app['appname'])
        self.assertIsNone(main_app['error_messages'])
示例#4
0
    def test_parse01(self):
        """Retrieve app information from a legal singularity def file."""
        expected_apps = [
            dict(appname='',
                 io_args=('names_csv', 'greetings_csv'),
                 memory=None,
                 numthreads=None,
                 error_messages=None),
            dict(appname='sums_and_products',
                 io_args=('input_csv', 'output_csv'),
                 memory=None,
                 numthreads=None,
                 error_messages=None)
        ]

        app_lst = deffile.parse_string(_DEFFILE_01)

        for app in app_lst:
            del app['helpstring']
            del app['runstring']
            del app['labeldict']
        self.assertEqual(expected_apps, app_lst)
示例#5
0
    def test_faulty01(self):
        """Parsing a variety of faulty singularity def files should raise a RuntimeError"""
        scenarios = [
            ("""
%help
the help line
%labels
   GOO hello goo
   BLA hello bla
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
""", {
                '': ['run string not set']
            }),
            ("""
%help
   the simple
   help line
%runscript
   bash echo 'hello world'
""", {
                '': ['labels string not set']
            }),
            ("""
%help
   the simple
   help line
%runscript
   bash echo 'hello world'
%labels
   GOO hello goo
   BLA hello bla
   KIVE_INPUTS in1_csv
""", {
                '': ['missing label KIVE_OUTPUTS']
            }),
            ("""
%help
   the simple
   help line
%runscript
   bash echo 'hello world'
%labels
   GOO hello goo
   BLA hello bla
""", {
                '':
                ['missing label KIVE_INPUTS', 'missing label KIVE_OUTPUTS']
            }),
            ("""
%apphelp bla
   the simple
   help line
%apprun blu
   bash echo 'hello world'
%applabels bla
   GOO hello goo
   BLA hello bla
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
""", {
                '': ['labels string not set', 'run string not set'],
                'bla': ['run string not set'],
                'blu': ['labels string not set']
            }),
            ("""
%labels
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
%runscript
   bash echo 'hello world'
%apphelp bla
   the simple
   help line
%apprun bla
   bash echo 'hello world'
%applabels bla
   GOO
   BLA hello bla
""", {
                'bla': ['empty label definition', 'labels string not set']
            }),
            ("""
%labels
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
%runscript
   bash echo 'hello world'
%apphelp bla
   the simple
   help line
%apprun bla
   bash echo 'hello world'
%applabels bla
   GOO  val1
   GOO val2
""", {
                'bla': ['label GOO defined twice', 'labels string not set']
            }),
            ("""
%labels
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
%runscript
   bash echo 'hello world'
%applabels bla
   FUNNY val1
   VALENTINE hello bla1 bla2
%apphelp bla
   the simple
   help line
%apprun bla
   bash echo 'hello world'
%applabels bla
   GOO val1
   BLA hello bla
""", {
                'bla': ['label string set twice']
            }),
            ("""
%labels
   KIVE_INPUTS in1_csv
   KIVE_OUTPUTS out1_csv
%runscript
   bash echo 'hello world'
%applabels main
   FUNNY val1
   VALENTINE hello bla1 bla2
   KIVE_THREADS 100 # a comment
%apphelp main
   the simple
   help line
%apprun main
   bash echo 'hello world'
""", {
                'main':
                ['value for KIVE_THREADS (100 # a comment) is not an integer']
            })
        ]

        for faulty_text, expected_errors in scenarios:
            app_list = deffile.parse_string(faulty_text)
            self.assertTrue(app_list)
            error_lists = {
                app_info[deffile.AppInfo.KW_APP_NAME]:
                app_info[deffile.AppInfo.KW_ERROR_MESSAGES]
                for app_info in app_list
                if app_info[deffile.AppInfo.KW_ERROR_MESSAGES]
            }
            self.assertEqual(expected_errors, error_lists)