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


Python AuroraConfigLoader.load方法代码示例

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


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

示例1: test_memoized_load

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_memoized_load():
  AuroraConfigLoader.CACHED_ENV = {}
  def check_env(env, config):
    assert 'jobs' in env and len(env['jobs']) == 1, (
      "Match expected jobs for config=%s" % config)
    assert env['jobs'][0].name().get() == 'hello_world'

  with temporary_dir() as d:
    with open(os.path.join(d, 'config.aurora'), 'w+') as fp:
      fp.write(MESOS_CONFIG)
      fp.flush()
      fp.seek(0)

      for config in (fp.name, fp):
        AuroraConfigLoader.CACHED_ENV = {}
        env = AuroraConfigLoader.load(config, is_memoized=False)
        check_env(env, config)
        assert MESOS_CONFIG_MD5 not in AuroraConfigLoader.CACHED_ENV.keys(), (
          "No key is cached when config=%s and is_memoized=False")

        fp.seek(0)  # previous load results in filepointer at eof
        env = AuroraConfigLoader.load(config, is_memoized=True)
        check_env(env, config)
        assert MESOS_CONFIG_MD5 in AuroraConfigLoader.CACHED_ENV.keys(), (
          "Key is cached when config=%s and is_memoized=True" % config)
开发者ID:apache,项目名称:aurora,代码行数:27,代码来源:test_loader.py

示例2: test_memoized_load_json_cache_hit

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_memoized_load_json_cache_hit(mock_gen_content_key):
  expected_env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG))
  expected_job_json = json.dumps(expected_env['jobs'][0].get())
  mock_gen_content_key.return_value = MESOS_CONFIG_MD5
  AuroraConfigLoader.CACHED_JSON = {MESOS_CONFIG_MD5: expected_job_json}
  loaded_job_json = AuroraConfigLoader.load_json('a/path', is_memoized=True)
  assert loaded_job_json == expected_job_json, "Test cache hit load_json"
开发者ID:apache,项目名称:aurora,代码行数:9,代码来源:test_loader.py

示例3: test_filter_schema

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_filter_schema():
  env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG))
  job_dict = env['jobs'][0].get()
  job_dict['unknown_attribute'] = 'foo bar baz'
  job_json_string = json.dumps(job_dict)
  with pytest.raises(AttributeError):
    AuroraConfigLoader.loads_json(job_json_string)
开发者ID:AltanAlpay,项目名称:aurora,代码行数:9,代码来源:test_loader.py

示例4: test_filter_schema

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_filter_schema():
  env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG))
  job_dict = env['jobs'][0].get()
  job_dict['unknown_attribute'] = 'foo bar baz'
  job_json_string = json.dumps(job_dict)
  # If this fails, will raise an InvalidConfigError or other exception and fail the test.
  AuroraConfigLoader.loads_json(job_json_string)
开发者ID:digideskio,项目名称:aurora,代码行数:9,代码来源:test_loader.py

示例5: test_pick

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_pick():
  env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG))

  hello_world = env['jobs'][0]
  assert AuroraConfig.pick(env, 'hello_world', None) == hello_world

  env['jobs'][0] = env['jobs'][0](name='something_{{else}}')
  assert str(AuroraConfig.pick(env, 'something_else', [{'else': 'else'}]).name()) == (
      'something_else')
开发者ID:AltanAlpay,项目名称:aurora,代码行数:11,代码来源:test_loader.py

示例6: test_load

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_load():
  with temporary_file() as fp:
    fp.write(MESOS_CONFIG)
    fp.flush()
    fp.seek(0)

    for config in (fp.name, fp):
      env = AuroraConfigLoader.load(config)
      assert 'jobs' in env and len(env['jobs']) == 1
      hello_world = env['jobs'][0]
      assert hello_world.name().get() == 'hello_world'
开发者ID:AltanAlpay,项目名称:aurora,代码行数:13,代码来源:test_loader.py

示例7: test_load_json

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_load_json():
  with temporary_file() as fp:
    fp.write(MESOS_CONFIG)
    fp.flush()
    env = AuroraConfigLoader.load(fp.name)
    job = env['jobs'][0]
  with temporary_file() as fp:
    fp.write(json.dumps(job.get()))
    fp.flush()
    new_job = AuroraConfigLoader.load_json(fp.name)
    assert new_job == job
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:13,代码来源:test_loader.py

示例8: test_pick

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_pick():
  with temporary_file() as fp:
    fp.write(MESOS_CONFIG)
    fp.flush()
    env = AuroraConfigLoader.load(fp.name)

  hello_world = env['jobs'][0]
  assert AuroraConfig.pick(env, 'hello_world', None) == hello_world

  env['jobs'][0] = env['jobs'][0](name='something_{{else}}')
  assert str(AuroraConfig.pick(env, 'something_else', [{'else': 'else'}]).name()) == (
      'something_else')
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:14,代码来源:test_loader.py

示例9: test_load_with_includes

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_load_with_includes():
  with temporary_dir() as tmp_dir:
    f1_name = 'f1.aurora'
    f2_name = 'f2.aurora'
    with open(os.path.join(tmp_dir, f1_name), 'w+') as f1:
      f1.write(MESOS_CONFIG)
      f1.flush()
      f1.seek(0)
      with open(os.path.join(tmp_dir, f2_name), 'w+') as f2:
        f2.write(MESOS_CONFIG_WITH_INCLUDE_TEMPLATE % f1_name)
        f2.flush()
        f2.seek(0)

        env = AuroraConfigLoader.load(f2.name, is_memoized=True)
        assert 'jobs' in env and len(env['jobs']) == 2
        hello_world = env['jobs'][0]
        assert hello_world.name().get() == 'hello_world'
        other_job = env['jobs'][1]
        assert other_job.name().get() == 'otherjob'
开发者ID:apache,项目名称:aurora,代码行数:21,代码来源:test_loader.py

示例10: test_load_json_memoized

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_load_json_memoized():
  AuroraConfigLoader.CACHED_JSON = {}
  env = AuroraConfigLoader.load(BytesIO(MESOS_CONFIG_MULTI))
  jobs = env['jobs']
  content = json.dumps(jobs[0].get())
  expected_md5 = hashlib.md5(content).hexdigest()
  with temporary_dir() as d:
    filename = os.path.join(d, 'config.json')
    with open(filename, 'w+') as fp:
      fp.write(json.dumps(jobs[0].get()))
      fp.close()
      loaded_job = AuroraConfigLoader.load_json(fp.name, is_memoized=False)['jobs'][0]
      assert loaded_job == jobs[0]
      assert expected_md5 not in AuroraConfigLoader.CACHED_JSON, (
        "No key is cached when is_memoized=False")

      loaded_job = AuroraConfigLoader.load_json(fp.name, is_memoized=True)['jobs'][0]
      assert loaded_job == jobs[0]
      assert expected_md5 in AuroraConfigLoader.CACHED_JSON, (
        "Key is cached when is_memoized=True")
开发者ID:apache,项目名称:aurora,代码行数:22,代码来源:test_loader.py

示例11: execute

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
    def execute(self, context):
        def maybe_bind(j):
            return j.bind(*bindings) if bindings else j

        def get_jobkey(job):
            return "/".join([job.cluster().get(), job.role().get(), job.environment().get(), job.name().get()])

        try:
            env = AuroraConfigLoader.load(context.options.config_file)
        except (AuroraConfig.Error, AuroraConfigLoader.Error, ValueError) as e:
            context.print_err("Error loading configuration file: %s" % e)
            return EXIT_COMMAND_FAILURE
        bindings = context.options.bindings
        job_list = env.get("jobs", [])
        if not job_list:
            context.print_out("jobs=[]")
        else:
            bound_jobs = map(maybe_bind, job_list)
            job_names = map(get_jobkey, bound_jobs)
            context.print_out("jobs=[%s]" % (", ".join(job_names)))
        return EXIT_OK
开发者ID:kevinburg,项目名称:incubator-aurora,代码行数:23,代码来源:config.py

示例12: test_empty_config

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_empty_config():
  AuroraConfigLoader.load(BytesIO())
开发者ID:AltanAlpay,项目名称:aurora,代码行数:4,代码来源:test_loader.py

示例13: test_bad_config

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_bad_config():
  with temporary_file() as fp:
    fp.write(BAD_MESOS_CONFIG)
    fp.flush()
    with pytest.raises(AuroraConfigLoader.InvalidConfigError):
      AuroraConfigLoader.load(fp.name)
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:8,代码来源:test_loader.py

示例14: test_bad_config

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_bad_config():
  with pytest.raises(AuroraConfigLoader.InvalidConfigError):
    AuroraConfigLoader.load(BytesIO(BAD_MESOS_CONFIG))
开发者ID:AltanAlpay,项目名称:aurora,代码行数:5,代码来源:test_loader.py

示例15: test_enoent

# 需要导入模块: from apache.aurora.config.loader import AuroraConfigLoader [as 别名]
# 或者: from apache.aurora.config.loader.AuroraConfigLoader import load [as 别名]
def test_enoent():
  nonexistent_file = tempfile.mktemp()
  with pytest.raises(AuroraConfigLoader.NotFound):
    AuroraConfigLoader.load(nonexistent_file)
开发者ID:AltanAlpay,项目名称:aurora,代码行数:6,代码来源:test_loader.py


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