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


Python MRJob.parse_counters方法代码示例

本文整理汇总了Python中mrjob.job.MRJob.parse_counters方法的典型用法代码示例。如果您正苦于以下问题:Python MRJob.parse_counters方法的具体用法?Python MRJob.parse_counters怎么用?Python MRJob.parse_counters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mrjob.job.MRJob的用法示例。


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

示例1: test_counters_and_status

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_counters_and_status(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter('Foo', 'Bar')
        mr_job.set_status('Initializing qux gradients...')
        mr_job.increment_counter('Foo', 'Bar')
        mr_job.increment_counter('Foo', 'Baz', 20)
        mr_job.set_status('Sorting metasyntactic variables...')

        parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())

        self.assertEqual(
            parsed_stderr, {
                'counters': {
                    'Foo': {
                        'Bar': 2,
                        'Baz': 20
                    }
                },
                'statuses': [
                    'Initializing qux gradients...',
                    'Sorting metasyntactic variables...'
                ],
                'other': []
            })

        # make sure parse_counters() works
        self.assertEqual(mr_job.parse_counters(), parsed_stderr['counters'])
开发者ID:bchess,项目名称:mrjob,代码行数:30,代码来源:test_job.py

示例2: test_commas_in_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_commas_in_counters(self):
        # commas should be replaced with semicolons
        mr_job = MRJob().sandbox()

        mr_job.increment_counter("Bad items", "a, b, c")
        mr_job.increment_counter("girl, interrupted", "movie")

        self.assertEqual(mr_job.parse_counters(), {"Bad items": {"a; b; c": 1}, "girl; interrupted": {"movie": 1}})
开发者ID:ndimiduk,项目名称:mrjob,代码行数:10,代码来源:test_job.py

示例3: test_parse_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_parse_counters(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter('Foo', 'Bar')
        mr_job.increment_counter('Foo', 'Bar')
        mr_job.increment_counter('Foo', 'Baz', 20)

        self.assertEqual(mr_job.parse_counters(),
                         {'Foo': {'Bar': 2, 'Baz': 20}})
开发者ID:Asana,项目名称:mrjob,代码行数:11,代码来源:test_job.py

示例4: test_negative_and_zero_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_negative_and_zero_counters(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter("Foo", "Bar", -1)
        mr_job.increment_counter("Foo", "Baz")
        mr_job.increment_counter("Foo", "Baz", -1)
        mr_job.increment_counter("Qux", "Quux", 0)

        self.assertEqual(mr_job.parse_counters(), {"Foo": {"Bar": -1, "Baz": 0}, "Qux": {"Quux": 0}})
开发者ID:ndimiduk,项目名称:mrjob,代码行数:11,代码来源:test_job.py

示例5: test_commas_in_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_commas_in_counters(self):
        # commas should be replaced with semicolons
        mr_job = MRJob().sandbox()

        mr_job.increment_counter('Bad items', 'a, b, c')
        mr_job.increment_counter('girl, interrupted', 'movie')

        assert_equal(mr_job.parse_counters(),
                     {'Bad items': {'a; b; c': 1},
                      'girl; interrupted': {'movie': 1}})
开发者ID:Jyrsa,项目名称:mrjob,代码行数:12,代码来源:job_test.py

示例6: test_negative_and_zero_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_negative_and_zero_counters(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter('Foo', 'Bar', -1)
        mr_job.increment_counter('Foo', 'Baz')
        mr_job.increment_counter('Foo', 'Baz', -1)
        mr_job.increment_counter('Qux', 'Quux', 0)

        assert_equal(mr_job.parse_counters(),
                     {'Foo': {'Bar': -1, 'Baz': 0}, 'Qux': {'Quux': 0}})
开发者ID:Jyrsa,项目名称:mrjob,代码行数:12,代码来源:job_test.py

示例7: test_parse_counters

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_parse_counters(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter('Foo', 'Bar')
        mr_job.increment_counter('Foo', 'Bar')
        mr_job.increment_counter('Foo', 'Baz', 20)

        with logger_disabled('mrjob.job'):
            self.assertEqual(mr_job.parse_counters(),
                             {'Foo': {'Bar': 2, 'Baz': 20}})
开发者ID:tempcyc,项目名称:mrjob,代码行数:12,代码来源:test_job.py

示例8: test_counters_and_status

# 需要导入模块: from mrjob.job import MRJob [as 别名]
# 或者: from mrjob.job.MRJob import parse_counters [as 别名]
    def test_counters_and_status(self):
        mr_job = MRJob().sandbox()

        mr_job.increment_counter("Foo", "Bar")
        mr_job.set_status("Initializing qux gradients...")
        mr_job.increment_counter("Foo", "Bar")
        mr_job.increment_counter("Foo", "Baz", 20)
        mr_job.set_status("Sorting metasyntactic variables...")

        parsed_stderr = parse_mr_job_stderr(mr_job.stderr.getvalue())

        self.assertEqual(
            parsed_stderr,
            {
                "counters": {"Foo": {"Bar": 2, "Baz": 20}},
                "statuses": ["Initializing qux gradients...", "Sorting metasyntactic variables..."],
                "other": [],
            },
        )

        # make sure parse_counters() works
        self.assertEqual(mr_job.parse_counters(), parsed_stderr["counters"])
开发者ID:ndimiduk,项目名称:mrjob,代码行数:24,代码来源:test_job.py


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