예제 #1
0
 def test_should_save_profile(self):
     # given
     copyfile(TestSparkUIProfile.MOCK_JSON, TestSparkUIProfile.MOCK_TEST_JSON)
     sut = Profile(path_to_beakerx_json=TestSparkUIProfile.MOCK_TEST_JSON)
     profile_to_save = [
         {
             'name': 'pf_new1',
             'spark.executor.memory': '8g',
             'spark.master': 'local[10]',
             'spark.executor.cores': '10',
             'properties': []
         },
         {
             'name': 'pf_new2',
             'spark.executor.memory': '8g',
             'spark.master': 'local[10]',
             'spark.executor.cores': '10',
             'properties': [{
                 "name": "prop1",
                 "value": "value1"
             }]
         }
     ]
     # when
     result, err = sut.save(profile_to_save)
     # then
     self.assertTrue(err is None)
     self.assertTrue(result)
     result, err = sut.load_profiles()
     profiles = result["profiles"]
     self.assertTrue("pf_new" in profiles[0]["name"])
     os.remove(TestSparkUIProfile.MOCK_TEST_JSON)
예제 #2
0
 def test_should_load_profiles(self):
     # given
     sut = Profile(path_to_beakerx_json=TestSparkUIProfile.MOCK_JSON)
     # when
     result, err = sut.load_profiles()
     # then
     self.assertTrue(err is None)
     self.assertTrue("profiles" in result)
예제 #3
0
 def test_should_save_current_profile(self):
     # given
     copyfile(TestSparkUIProfile.MOCK_JSON, TestSparkUIProfile.MOCK_TEST_JSON)
     sut = Profile(path_to_beakerx_json=TestSparkUIProfile.MOCK_TEST_JSON)
     # when
     result, err = sut.save_current_profile("new_profile_name1")
     # then
     self.assertTrue(err is None)
     self.assertTrue(result)
     result, err = sut.load_profiles()
     current_profile = result["current_profile"]
     self.assertTrue(current_profile == "new_profile_name1")
     os.remove(TestSparkUIProfile.MOCK_TEST_JSON)
예제 #4
0
 def spark(self, line, cell):
     self.clear_spark_session()
     ipython = get_ipython()
     result, err = self._runCellCode(cell, ipython)
     if err is not None:
         print(err, file=sys.stderr)
         return
     builder = result.result
     ui_options = magic_arguments.parse_argstring(self.spark, line)
     factory = self._create_spark_factory(
         builder, IpythonManager(ipython), BeakerxSparkServerFactory(),
         Profile(), ui_options, self._display_ui,
         SparkexMagics.SINGLE_SPARK_SESSION)
     result, err = factory.create_spark()
     if err is not None:
         print(err, file=sys.stderr)
     elif result is not None:
         print(result)
     return