当前位置: 首页>>代码示例>>Python>>正文


Python configuration.override_all函数代码示例

本文整理汇总了Python中sparkmagic.utils.configuration.override_all函数的典型用法代码示例。如果您正苦于以下问题:Python override_all函数的具体用法?Python override_all怎么用?Python override_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了override_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_execute_failure_wait_for_session_emits_event

def test_execute_failure_wait_for_session_emits_event():
    spark_events = MagicMock()
    kind = SESSION_KIND_SPARK
    http_client = MagicMock()
    http_client.post_session.return_value = tls.TestLivySession.session_create_json
    http_client.post_statement.return_value = tls.TestLivySession.post_statement_json
    http_client.get_session.return_value = tls.TestLivySession.ready_sessions_json
    http_client.get_statement.return_value = tls.TestLivySession.ready_statement_json
    conf.override_all({
        "status_sleep_seconds": 0.01,
        "statement_sleep_seconds": 0.01
    })
    session = _create_session(kind=kind, http_client=http_client)
    conf.override_all({})
    session.start(create_sql_context=False)
    session.wait_for_idle = MagicMock(side_effect=ValueError("yo"))
    command = Command("command", spark_events=spark_events)

    try:
        result = command.execute(session)
        assert False
    except ValueError as e:
        spark_events.emit_statement_execution_start_event._assert_called_once_with(session.guid, session.kind,
                                                                                   session.id, command.guid)
        spark_events.emit_statement_execution_start_event._assert_called_once_with(session.guid, session.kind,
                                                                                   session.id, command.guid,
                                                                                   -1, False, "ValueError", "yo")
        assert_equals(e, session.wait_for_idle.side_effect)
开发者ID:ganeshraju,项目名称:sparkmagic,代码行数:28,代码来源:test_command.py

示例2: test_execute_failure_post_statement_emits_event

def test_execute_failure_post_statement_emits_event():
    spark_events = MagicMock()
    kind = SESSION_KIND_SPARK
    http_client = MagicMock()
    http_client.get_statement.return_value = tls.TestLivySession.ready_statement_json
    conf.override_all({"status_sleep_seconds": 0.01, "statement_sleep_seconds": 0.01})
    session = _create_session(kind=kind, http_client=http_client)
    session.wait_for_idle = MagicMock()
    conf.override_all({})
    session.start()
    session.wait_for_idle = MagicMock()
    command = Command("command", spark_events=spark_events)

    http_client.post_statement.side_effect = KeyError("Something bad happened here")
    try:
        result = command.execute(session)
        assert False
    except KeyError as e:
        spark_events.emit_statement_execution_start_event.assert_called_once_with(
            session.guid, session.kind, session.id, command.guid
        )
        spark_events.emit_statement_execution_end_event._assert_called_once_with(
            session.guid, session.kind, session.id, command.guid, -1, False, "KeyError", "Something bad happened here"
        )
        assert_equals(e, http_client.post_statement.side_effect)
开发者ID:jupyter-incubator,项目名称:sparkmagic,代码行数:25,代码来源:test_command.py

示例3: test_execute

def test_execute():
    spark_events = MagicMock()
    kind = SESSION_KIND_SPARK
    http_client = MagicMock()
    http_client.post_session.return_value = tls.TestLivySession.session_create_json
    http_client.post_statement.return_value = tls.TestLivySession.post_statement_json
    http_client.get_session.return_value = tls.TestLivySession.ready_sessions_json
    http_client.get_statement.return_value = tls.TestLivySession.ready_statement_json
    conf.override_all({"status_sleep_seconds": 0.01, "statement_sleep_seconds": 0.01})
    session = _create_session(kind=kind, http_client=http_client)
    conf.override_all({})
    session.start()
    command = Command("command", spark_events=spark_events)

    result = command.execute(session)

    http_client.post_statement.assert_called_with(0, {"code": command.code})
    http_client.get_statement.assert_called_with(0, 0)
    assert result[0]
    assert_equals(tls.TestLivySession.pi_result, result[1])
    spark_events.emit_statement_execution_start_event.assert_called_once_with(
        session.guid, session.kind, session.id, command.guid
    )
    spark_events.emit_statement_execution_end_event.assert_called_once_with(
        session.guid, session.kind, session.id, command.guid, 0, True, "", ""
    )
开发者ID:jupyter-incubator,项目名称:sparkmagic,代码行数:26,代码来源:test_command.py

示例4: test_delete_session_emits_start_failed_end_when_delete_throws

    def test_delete_session_emits_start_failed_end_when_delete_throws(self):
        self.http_client.delete_session.side_effect = ValueError
        self.http_client.get_session.return_value = self.ready_sessions_json
        self.http_client.get_statement.return_value = self.ready_statement_json

        conf.override_all({
            "status_sleep_seconds": 0.01,
            "statement_sleep_seconds": 0.01
        })
        session = self._create_session()
        conf.override_all({})
        session.start()
        session.id = 0
        end_id = session.id
        end_status = constants.BUSY_SESSION_STATUS
        session.status = end_status

        try:
            session.delete()
            assert False
        except ValueError:
            pass

        self.spark_events.emit_session_deletion_start_event.assert_called_once_with(
            session.guid, session.kind, end_id, end_status)
        self.spark_events.emit_session_deletion_end_event.assert_called_once_with(
            session.guid, session.kind, end_id, end_status, False, "ValueError", "")
开发者ID:linchan-ms,项目名称:sparkmagic,代码行数:27,代码来源:test_livysession.py

示例5: test_constructor_throws_status_sleep_seconds

 def test_constructor_throws_status_sleep_seconds(self):
     conf.override_all({
         "status_sleep_seconds": 0,
         "statement_sleep_seconds": 2
     })
     self._create_session()
     conf.override_all({})
开发者ID:linchan-ms,项目名称:sparkmagic,代码行数:7,代码来源:test_livysession.py

示例6: test_execute_failure_get_statement_output_emits_event

def test_execute_failure_get_statement_output_emits_event():
    spark_events = MagicMock()
    kind = SESSION_KIND_SPARK
    http_client = MagicMock()
    conf.override_all({
        "status_sleep_seconds": 0.01,
        "statement_sleep_seconds": 0.01
    })
    session = _create_session(kind=kind, http_client=http_client)
    session.wait_for_idle = MagicMock()
    conf.override_all({})
    session.start(create_sql_context=False)
    session.wait_for_idle = MagicMock()
    command = Command("command", spark_events=spark_events)
    command._get_statement_output = MagicMock(side_effect=AttributeError('OHHHH'))

    try:
        result = command.execute(session)
        assert False
    except AttributeError as e:
        spark_events.emit_statement_execution_start_event._assert_called_once_with(session.guid, session.kind,
                                                                                   session.id, command.guid)
        spark_events.emit_statement_execution_start_event._assert_called_once_with(session.guid, session.kind,
                                                                                   session.id, command.guid,
                                                                                   -1, False, "AttributeError",
                                                                                   "OHHHH")
        assert_equals(e, command._get_statement_output.side_effect)
开发者ID:ganeshraju,项目名称:sparkmagic,代码行数:27,代码来源:test_command.py

示例7: test_constructor_throws_invalid_session_sql_combo

 def test_constructor_throws_invalid_session_sql_combo(self):
     conf.override_all({
         "status_sleep_seconds": 2,
         "statement_sleep_seconds": 2,
         "create_sql_context_timeout_seconds": 60
     })
     self._create_session(sql_created=True)
     conf.override_all({})
开发者ID:prabhu1984,项目名称:sparkmagic,代码行数:8,代码来源:test_livysession.py

示例8: test_constructor_throws_status_sleep_seconds

 def test_constructor_throws_status_sleep_seconds(self):
     conf.override_all({
         "status_sleep_seconds": 0,
         "statement_sleep_seconds": 2,
         "create_sql_context_timeout_seconds": 60
     })
     self._create_session()
     conf.override_all({})
开发者ID:prabhu1984,项目名称:sparkmagic,代码行数:8,代码来源:test_livysession.py

示例9: test_configuration_override_work_with_empty_password

def test_configuration_override_work_with_empty_password():
    kpc = { 'username': 'U', 'base64_password': '', 'password': '', 'url': '' }
    overrides = { conf.kernel_python_credentials.__name__: kpc }
    conf.override_all(overrides)
    conf.override(conf.status_sleep_seconds.__name__, 1)
    assert_equals(conf.d, { conf.kernel_python_credentials.__name__: kpc,
                                     conf.status_sleep_seconds.__name__: 1 })
    assert_equals(conf.status_sleep_seconds(), 1)
    assert_equals(conf.base64_kernel_python_credentials(),  { 'username': 'U', 'password': '', 'url': '' })
开发者ID:ganeshraju,项目名称:sparkmagic,代码行数:9,代码来源:test_configuration.py

示例10: test_constructor_starts_with_no_session

    def test_constructor_starts_with_no_session(self):
        conf.override_all({
            "status_sleep_seconds": 4,
            "statement_sleep_seconds": 2
        })
        session = self._create_session()
        conf.override_all({})

        assert session.id == -1
开发者ID:linchan-ms,项目名称:sparkmagic,代码行数:9,代码来源:test_livysession.py

示例11: test_constructor_starts_with_no_session

    def test_constructor_starts_with_no_session(self):
        conf.override_all({
            "status_sleep_seconds": 4,
            "statement_sleep_seconds": 2,
            "create_sql_context_timeout_seconds": 60
        })
        session = self._create_session()
        conf.override_all({})

        assert session.id == -1
        assert not session.created_sql_context
开发者ID:prabhu1984,项目名称:sparkmagic,代码行数:11,代码来源:test_livysession.py

示例12: _setup

def _setup():
    global magic, spark_controller, shell, ipython_display, spark_events, conf

    conf.override_all({})
    spark_events = MagicMock()

    magic = TestKernelMagics(shell=None, spark_events=spark_events)
    magic.shell = shell = MagicMock()
    magic.ipython_display = ipython_display = MagicMock()
    magic.spark_controller = spark_controller = MagicMock()
    magic._generate_uuid = MagicMock(return_value='0000')
开发者ID:jupyter-incubator,项目名称:sparkmagic,代码行数:11,代码来源:test_kernel_magics.py

示例13: test_constructor_starts_with_existing_session

    def test_constructor_starts_with_existing_session(self):
        conf.override_all({
            "status_sleep_seconds": 4,
            "statement_sleep_seconds": 2
        })
        session_id = 1
        session = self._create_session(session_id=session_id, heartbeat_timeout=0)
        conf.override_all({})

        assert session.id == session_id
        assert session._heartbeat_thread is None
        assert constants.LIVY_HEARTBEAT_TIMEOUT_PARAM not in list(session.properties.keys())
开发者ID:linchan-ms,项目名称:sparkmagic,代码行数:12,代码来源:test_livysession.py

示例14: test_delete_session_when_not_started

    def test_delete_session_when_not_started(self):
        self.http_client.post_session.return_value = self.session_create_json
        conf.override_all({
            "status_sleep_seconds": 0.01,
            "statement_sleep_seconds": 0.01
        })
        session = self._create_session()
        conf.override_all({})

        session.delete()

        assert_equals(session.ipython_display.send_error.call_count, 1)
开发者ID:linchan-ms,项目名称:sparkmagic,代码行数:12,代码来源:test_livysession.py

示例15: test_sqlquery_loads_defaults

def test_sqlquery_loads_defaults():
    defaults = {
        conf.default_samplemethod.__name__: "sample",
        conf.default_maxrows.__name__: 419,
        conf.default_samplefraction.__name__: 0.99,
    }
    conf.override_all(defaults)
    query = "DROP TABLE USERS;"
    sqlquery = SQLQuery(query)
    assert_equals(sqlquery.query, query)
    assert_equals(sqlquery.samplemethod, defaults[conf.default_samplemethod.__name__])
    assert_equals(sqlquery.maxrows, defaults[conf.default_maxrows.__name__])
    assert_equals(sqlquery.samplefraction, defaults[conf.default_samplefraction.__name__])
开发者ID:jupyter-incubator,项目名称:sparkmagic,代码行数:13,代码来源:test_sqlquery.py


注:本文中的sparkmagic.utils.configuration.override_all函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。