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


Python loader.PyFileConfigLoader方法代码示例

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


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

示例1: load_jupytext_configuration_file

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import PyFileConfigLoader [as 别名]
def load_jupytext_configuration_file(jupytext_config_file):
    """Read a Jupytext config file, and return a JupytextConfig object"""

    if jupytext_config_file.endswith((".toml", "jupytext")):
        import toml

        config = toml.load(jupytext_config_file)
        return JupytextConfiguration(**config)

    if jupytext_config_file.endswith((".yml", ".yaml")):
        with open(jupytext_config_file) as stream:
            config = yaml.safe_load(stream)
        return JupytextConfiguration(**config)

    if jupytext_config_file.endswith(".py"):
        return JupytextConfiguration(
            **PyFileConfigLoader(jupytext_config_file).load_config()
        )

    return JupytextConfiguration(
        **JSONFileConfigLoader(jupytext_config_file).load_config()
    ) 
开发者ID:mwouts,项目名称:jupytext,代码行数:24,代码来源:config.py

示例2: get_config_from_file

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import PyFileConfigLoader [as 别名]
def get_config_from_file(path, content):
    # Write config file
    filename = 'config.py'
    config_file = path / filename
    config_file.write_text(content)

    # Load written file.
    loader = PyFileConfigLoader(filename, path=str(path))
    cfg = loader.load_config()
    return cfg 
开发者ID:jupyter,项目名称:telemetry,代码行数:12,代码来源:test_eventlog.py

示例3: _binderhub_config

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import PyFileConfigLoader [as 别名]
def _binderhub_config():
    """Load the binderhub configuration

    Currently separate from the app fixture
    so that it can have a different scope (only once per session).
    """
    cfg = PyFileConfigLoader(minikube_testing_config).load_config()
    cfg.BinderHub.build_namespace = TEST_NAMESPACE
    global KUBERNETES_AVAILABLE
    try:
        kubernetes.config.load_kube_config()
    except Exception:
        cfg.BinderHub.builder_required = False
        KUBERNETES_AVAILABLE = False
        if ON_TRAVIS:
            pytest.fail("Kubernetes should be available on Travis")
    else:
        KUBERNETES_AVAILABLE = True
    if REMOTE_BINDER:
        return

    # check if Hub is running and ready
    try:
        requests.get(cfg.BinderHub.hub_url, timeout=5, allow_redirects=False)
    except Exception as e:
        print(f"JupyterHub not available at {cfg.BinderHub.hub_url}: {e}")
        if ON_TRAVIS:
            pytest.fail("JupyterHub should be available on Travis")
        cfg.BinderHub.hub_url = ''
    else:
        print(f"JupyterHub available at {cfg.BinderHub.hub_url}")
    return cfg 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:34,代码来源:conftest.py

示例4: app

# 需要导入模块: from traitlets.config import loader [as 别名]
# 或者: from traitlets.config.loader import PyFileConfigLoader [as 别名]
def app(request, io_loop, _binderhub_config):
    """Launch the BinderHub app

    Currently reads minikube test config from the repo.
    TODO: support input of test config files.

    Detects whether kubernetes is available, and if not disables build.
    Detects whether jupyterhub is available, and if not disables launch.

    app.url will contain the base URL of binderhub.
    """
    if REMOTE_BINDER:
        app = RemoteBinderHub()
        # wait for the remote binder to be up
        remaining = 30
        deadline = time.monotonic() + remaining
        success = False
        last_error = None
        while remaining:
            try:
                requests.get(BINDER_URL, timeout=remaining)
            except Exception as e:
                print(f"Waiting for binder: {e}")
                last_error = e
                time.sleep(1)
                remaining = deadline - time.monotonic()
            else:
                success = True
                break
        if not success:
            raise last_error
        app.url = BINDER_URL
        app._configured_bhub = BinderHub(config=_binderhub_config)
        return app

    if hasattr(request, 'param') and request.param is True:
        # load conf for auth test
        cfg = PyFileConfigLoader(minikube_testing_auth_config).load_config()
        _binderhub_config.merge(cfg)
    bhub = BinderHub.instance(config=_binderhub_config)
    bhub.initialize([])
    bhub.start(run_loop=False)
    # instantiating binderhub configures this
    # override again
    AsyncHTTPClient.configure(MockAsyncHTTPClient)

    def cleanup():
        bhub.stop()
        BinderHub.clear_instance()

    request.addfinalizer(cleanup)
    # convenience for accessing binder in tests
    bhub.url = f'http://127.0.0.1:{bhub.port}{bhub.base_url}'.rstrip('/')
    return bhub 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:56,代码来源:conftest.py


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