def init_sml_config(self):
     """
     Initialize the ML_Framework object with the test_json config
     """
     current_dir = os.path.dirname(__file__)
     test_json_file = os.path.join(current_dir,
                                   "../resources/test_json.json")
     self._config = cu.parse_json_file(test_json_file)
コード例 #2
0
ファイル: dsl.py プロジェクト: bigluster/monasca-analytics
    def load_configuration(self, config_file_path):
        """Load a configuration from the file passed as parameter

        :type config_file_path: str
        :param config_file_path: file path containing the
               configuration that will be loaded
        """
        self._config = cu.parse_json_file(config_file_path)
        self._init_ids_dictionary()
コード例 #3
0
    def load_configuration(self, config_file_path):
        """Load a configuration from the file passed as parameter

        :type config_file_path: str
        :param config_file_path: file path containing the
               configuration that will be loaded
        """
        self._config = cu.parse_json_file(config_file_path)
        self._init_ids_dictionary()
コード例 #4
0
 def test_parse_json_file(self):
     current_dir = os.path.dirname(__file__)
     test_json_file = os.path.join(current_dir,
                                   "../resources/test_json.json")
     parsed_json = common_util.parse_json_file(test_json_file)
     six.assertCountEqual(
         self, parsed_json["sources"]["src1"], {
             "module": "src_module1",
             "params": {
                 "param1": "val1",
                 "param2": "val2",
                 "model_id": 3
             }
         })
     six.assertCountEqual(self, parsed_json["ingestors"]["ing1"],
                          {"module": "ingestor_module"})
     six.assertCountEqual(self, parsed_json["smls"]["sml1"],
                          {"module": "sml_module"})
     self.assertEqual(parsed_json["voters"]["vot1"],
                      {"module": "voter_module"})
     six.assertCountEqual(self, parsed_json["sinks"]["snk1"],
                          {"module": "sink_module1"})
     six.assertCountEqual(self, parsed_json["sinks"]["snk2"],
                          {"module": "sink_module2"})
     six.assertCountEqual(self, parsed_json["ldps"]["ldp1"],
                          {"module": "ldps_module1"})
     six.assertCountEqual(
         self, parsed_json["connections"], {
             "src1": ["ing1"],
             "src2": ["ing1"],
             "ing1": ["aggr1", "ldp1", "sin1"],
             "snk1": [],
             "snk2": [],
             "sml1": ["vot1", "snk1"],
             "vot1": ["ldp1", "snk1"],
             "ldp1": ["snk2"]
         })
     six.assertCountEqual(self, parsed_json["feedback"], {
         "snk1": ["sml1"],
         "snk2": ["vot1"]
     })
コード例 #5
0
 def test_parse_json_file(self):
     current_dir = os.path.dirname(__file__)
     test_json_file = os.path.join(current_dir,
                                   "../resources/test_json.json")
     parsed_json = common_util.parse_json_file(test_json_file)
     six.assertCountEqual(self, parsed_json["sources"]["src1"],
                          {"module": "src_module1",
                           "params": {
                               "param1": "val1",
                               "param2": "val2",
                               "model_id": 3}
                           })
     six.assertCountEqual(self, parsed_json["ingestors"]["ing1"],
                          {"module": "ingestor_module"})
     six.assertCountEqual(self, parsed_json["smls"]["sml1"],
                          {"module": "sml_module"})
     self.assertEqual(parsed_json["voters"]["vot1"],
                      {"module": "voter_module"})
     six.assertCountEqual(self, parsed_json["sinks"]["snk1"],
                          {"module": "sink_module1"})
     six.assertCountEqual(self, parsed_json["sinks"]["snk2"],
                          {"module": "sink_module2"})
     six.assertCountEqual(self, parsed_json["ldps"]["ldp1"],
                          {"module": "ldps_module1"})
     six.assertCountEqual(self, parsed_json["connections"],
                          {"src1": ["ing1"],
                           "src2": ["ing1"],
                           "ing1": ["aggr1", "ldp1", "sin1"],
                           "snk1": [],
                           "snk2": [],
                           "sml1": ["vot1", "snk1"],
                           "vot1": ["ldp1", "snk1"],
                           "ldp1": ["snk2"]})
     six.assertCountEqual(self, parsed_json["feedback"],
                          {"snk1": ["sml1"],
                           "snk2": ["vot1"]})
コード例 #6
0
 def get_config(self):
     current_dir = os.path.dirname(__file__)
     test_json_file = os.path.join(current_dir,
                                   "../resources/test_json.json")
     return common_util.parse_json_file(test_json_file)
コード例 #7
0
 def get_config(self):
     current_dir = os.path.dirname(__file__)
     test_json_file = os.path.join(current_dir,
                                   "../resources/test_json.json")
     return common_util.parse_json_file(test_json_file)
コード例 #8
0
        import pydevd
        pydevd.settrace(suspend=False)
    try:
        try:
            cu.setup_logging(sys.argv[2])
        except IOError:
            raise err.MonanasMainError("File not found: \
                `{0}`.".format(sys.argv[2]))
        except ValueError:
            raise err.MonanasMainError("`{0}` is not a valid logging \
                config file.".format(sys.argv[2]))

        logger = logging.getLogger(__name__)

        try:
            config = cu.parse_json_file(sys.argv[1])
        except IOError:
            raise err.MonanasMainError("File not found: \
                `{0}`.".format(sys.argv[1]))
        except ValueError as e:
            raise err.MonanasMainError("`{0}` is not a \
                valid json file.".format(sys.argv[1]))
        except voluptuous.Invalid:
            raise err.MonanasMainError("`{0}` has an \
                invalid schema.".format(sys.argv[1]))

        monanas = Monanas(config)
        web_service = ws.WebService(monanas, config["server"])
        web_service.listen(config["server"]["port"])
        ioloop.IOLoop.instance().start()
    except IOError as e:
コード例 #9
0
        import pydevd
        pydevd.settrace(suspend=False)
    try:
        try:
            cu.setup_logging(sys.argv[2])
        except IOError:
            raise err.MonanasMainError("File not found: \
                `{0}`.".format(sys.argv[2]))
        except ValueError:
            raise err.MonanasMainError("`{0}` is not a valid logging \
                config file.".format(sys.argv[2]))

        logger = logging.getLogger(__name__)

        try:
            config = cu.parse_json_file(sys.argv[1])
        except IOError:
            raise err.MonanasMainError("File not found: \
                `{0}`.".format(sys.argv[1]))
        except ValueError as e:
            raise err.MonanasMainError("`{0}` is not a \
                valid json file.".format(sys.argv[1]))
        except voluptuous.Invalid:
            raise err.MonanasMainError("`{0}` has an \
                invalid schema.".format(sys.argv[1]))

        monanas = Monanas(config)
        web_service = ws.WebService(monanas, config["server"])
        web_service.listen(config["server"]["port"])
        ioloop.IOLoop.instance().start()
    except IOError as e: