• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sandbox.mrjob_conf_patcher函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_loading_boostrapped_mrjob_library

    def test_loading_boostrapped_mrjob_library(self):
        # track the dir we're loading mrjob from rather than the full path
        # to deal with edge cases where we load from the .py file,
        # and the script loads from the .pyc compiled from that .py file.
        our_mrjob_dir = os.path.dirname(os.path.realpath(mrjob.__file__))

        with mrjob_conf_patcher():
            mr_job = MRJobWhereAreYou(['-r', 'local'])
            mr_job.sandbox()

            with mr_job.make_runner() as runner:
                # sanity check
                self.assertEqual(runner.get_opts()['bootstrap_mrjob'], True)
                local_tmp_dir = os.path.realpath(runner._get_local_tmp_dir())

                runner.run()

                output = list(runner.stream_output())
                self.assertEqual(len(output), 1)

                # script should load mrjob from its working dir
                _, script_mrjob_dir = mr_job.parse_output_line(output[0])

                self.assertNotEqual(our_mrjob_dir, script_mrjob_dir)
                assert script_mrjob_dir.startswith(local_tmp_dir)
开发者ID:eklitzke,项目名称:mrjob,代码行数:25,代码来源:test_local.py


示例2: test_can_turn_off_bootstrap_mrjob

    def test_can_turn_off_bootstrap_mrjob(self):
        with mrjob_conf_patcher(
                {'runners': {'local': {'bootstrap_mrjob': False}}}):

            mr_job = MRJobWhereAreYou(['-r', 'local'])
            mr_job.sandbox()

            with mr_job.make_runner() as runner:
                # sanity check
                self.assertEqual(runner._opts['bootstrap_mrjob'], False)
                local_tmp_dir = os.path.realpath(runner._get_local_tmp_dir())
                try:
                    runner.run()
                except StepFailedException:
                    # this is what happens when mrjob isn't installed elsewhere
                    return

                # however, if mrjob is installed, we need to verify that
                # we're using the installed version and not a bootstrapped copy
                output = list(mr_job.parse_output(runner.cat_output()))

                self.assertEqual(len(output), 1)

                # script should not load mrjob from local_tmp_dir
                _, script_mrjob_dir = output[0]
                self.assertFalse(script_mrjob_dir.startswith(local_tmp_dir))
开发者ID:Affirm,项目名称:mrjob,代码行数:26,代码来源:test_local.py


示例3: test_can_turn_off_bootstrap_mrjob

    def test_can_turn_off_bootstrap_mrjob(self):
        with mrjob_conf_patcher({"runners": {"local": {"bootstrap_mrjob": False}}}):

            mr_job = MRJobWhereAreYou(["-r", "local"])
            mr_job.sandbox()

            with mr_job.make_runner() as runner:
                # sanity check
                self.assertEqual(runner.get_opts()["bootstrap_mrjob"], False)
                local_tmp_dir = os.path.realpath(runner._get_local_tmp_dir())
                try:
                    with no_handlers_for_logger():
                        runner.run()
                except Exception as e:
                    # if mrjob is not installed, script won't be able to run
                    self.assertIn("ImportError", str(e))
                    return

                output = list(runner.stream_output())

                self.assertEqual(len(output), 1)

                # script should not load mrjob from local_tmp_dir
                _, script_mrjob_dir = mr_job.parse_output_line(output[0])
                self.assertFalse(script_mrjob_dir.startswith(local_tmp_dir))
开发者ID:alanhdu,项目名称:mrjob,代码行数:25,代码来源:test_local.py


示例4: test_command_line_can_blank_out_conf

    def test_command_line_can_blank_out_conf(self):
        self.start(mrjob_conf_patcher(
            dict(runners=dict(inline=dict(
                local_tmp_dir=self.tmp_dir)))))

        with self.make_runner('--local-tmp-dir', '') as runner:
            self.assert_local_tmp_in(runner, tempfile.gettempdir())
开发者ID:Affirm,项目名称:mrjob,代码行数:7,代码来源:test_runner.py


示例5: test_blank_local_tmp_dir_means_default

    def test_blank_local_tmp_dir_means_default(self):
        self.start(mrjob_conf_patcher(
            dict(runners=dict(inline=dict(
                local_tmp_dir='')))))

        with self.make_runner() as runner:
            self.assert_local_tmp_in(runner, tempfile.gettempdir())
开发者ID:Affirm,项目名称:mrjob,代码行数:7,代码来源:test_runner.py


示例6: test_mrjob_conf

    def test_mrjob_conf(self):
        self.start(mrjob_conf_patcher(
            dict(runners=dict(inline=dict(
                local_tmp_dir=self.tmp_dir)))))

        with self.make_runner() as runner:
            self.assert_local_tmp_in(runner, self.tmp_dir)
开发者ID:Affirm,项目名称:mrjob,代码行数:7,代码来源:test_runner.py


示例7: test_max_output_files_is_cmd_line_only

    def test_max_output_files_is_cmd_line_only(self):
        self.start(mrjob_conf_patcher(
            dict(runners=dict(spark=dict(max_output_files=1)))))

        log = self.start(patch('mrjob.runner.log'))

        job = MRWordFreqCount(['-r', 'spark'])
        job.sandbox(stdin=BytesIO(b'one two one\n two three\n'))

        with job.make_runner() as runner:
            runner.run()

            # by default there should be at least 2 output files
            self.assertNotEqual(self._num_output_files(runner), 1)

        self.assertTrue(log.warning.called)
开发者ID:Yelp,项目名称:mrjob,代码行数:16,代码来源:test_runner.py


示例8: test_can_turn_off_bootstrap_mrjob

    def test_can_turn_off_bootstrap_mrjob(self):
        # track the dir we're loading mrjob from rather than the full path
        # to deal with edge cases where we load from the .py file,
        # and the script loads from the .pyc compiled from that .py file.
        our_mrjob_dir = os.path.dirname(os.path.realpath(mrjob.__file__))

        with mrjob_conf_patcher(
            {'runners': {'local': {'bootstrap_mrjob': False}}}):

            mr_job = MRJobWhereAreYou(['-r', 'local'])
            mr_job.sandbox()

            with mr_job.make_runner() as runner:
                # sanity check
                self.assertEqual(runner.get_opts()['bootstrap_mrjob'], False)
                runner.run()

                output = list(runner.stream_output())

                self.assertEqual(len(output), 1)

                # script should load mrjob from the same place our test does
                _, script_mrjob_dir = mr_job.parse_output_line(output[0])
                self.assertEqual(our_mrjob_dir, script_mrjob_dir)
开发者ID:eklitzke,项目名称:mrjob,代码行数:24,代码来源:test_local.py


示例9: test_can_disable_check_input_paths_in_config

 def test_can_disable_check_input_paths_in_config(self):
     job = MRWordCount()
     with mrjob_conf_patcher(
             {'runners': {'inline': {'check_input_paths': False}}}):
         with job.make_runner() as runner:
             self.assertFalse(runner._opts['check_input_paths'])
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:6,代码来源:test_runner.py


示例10: test_loose_mrjob_conf

 def test_loose_mrjob_conf(self):
     job = MRJob()
     with mrjob_conf_patcher(self.LOOSE_MRJOB_CONF):
         with job.make_runner() as runner:
             self.assertEqual(runner._opts['strict_protocols'], False)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:5,代码来源:test_runner.py


示例11: test_strict_mrjob_conf

 def test_strict_mrjob_conf(self):
     job = MRJob()
     with mrjob_conf_patcher(self.STRICT_MRJOB_CONF):
         with job.make_runner() as runner:
             self.assertEqual(runner._opts['strict_protocols'], True)
开发者ID:anirudhreddy92,项目名称:mrjob,代码行数:5,代码来源:test_runner.py


示例12: test_unencodable_output_no_strict_protocols

 def test_unencodable_output_no_strict_protocols(self):
     with mrjob_conf_patcher(self.STRICT_MRJOB_CONF):
         self.assertJobHandlesUnencodableOutput(
             job_args=['--no-strict-protocols'])
开发者ID:tempcyc,项目名称:mrjob,代码行数:4,代码来源:test_job.py


示例13: test_unencodable_output_strict_in_mrjob_conf

 def test_unencodable_output_strict_in_mrjob_conf(self):
     with mrjob_conf_patcher(self.STRICT_MRJOB_CONF):
         self.assertJobRaisesExceptionOnUnencodableOutput(
             job_args=['--strict-protocols'])
开发者ID:tempcyc,项目名称:mrjob,代码行数:4,代码来源:test_job.py


示例14: set_in_mrjob_conf

 def set_in_mrjob_conf(self, **kwargs):
     dataproc_opts = copy.deepcopy(self.MRJOB_CONF_CONTENTS)
     dataproc_opts['runners']['dataproc'].update(kwargs)
     patcher = mrjob_conf_patcher(dataproc_opts)
     patcher.start()
     self.addCleanup(patcher.stop)
开发者ID:Jeremyfanfan,项目名称:mrjob,代码行数:6,代码来源:test_dataproc.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python setup_cluster.kill_mongo_proc函数代码示例发布时间:2022-05-27
下一篇:
Python samples.SampleBase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap