Exemplo n.º 1
0
def test_env_config():
    cfg = EnvironmentConfiguration(
        f"_test_{rand_str()}",
        metadata_storage_url="sqlite://",
        settings=SnapflowSettings(add_core_module=False),
    )
    env = Environment.from_config(cfg)
    env_init(env)
Exemplo n.º 2
0
 def from_config(cfg: ExecutionConfiguration) -> ExecutionContext:
     env = Environment.from_config(cfg.env_config)
     return ExecutionContext(
         env=env,
         local_storage=ensure_storage(cfg.local_storage_url),
         target_storage=ensure_storage(cfg.target_storage_url),
         target_format=None,  # TODO: from config
         storages=[ensure_storage(s) for s in cfg.storage_urls],
         # logger=ExecutionLogger(),  # TODO: from config
         execution_timelimit_seconds=cfg.execution_timelimit_seconds,
         abort_on_snap_error=env.settings.abort_on_snap_error,
         execution_config=cfg,
     )
Exemplo n.º 3
0
def test_multi_env():
    db_url = get_tmp_sqlite_db_url()
    cfg = EnvironmentConfiguration(
        key=f"_test_{rand_str()}",
        metadata_storage_url=db_url,
        settings=SnapflowSettings(add_core_module=False),
    )
    env1 = Environment.from_config(cfg)
    with env1.md_api.begin():
        env1.md_api.add(DataBlockMetadata(realized_schema_key="Any"))
        env1.md_api.flush()
        assert env1.md_api.count(select(DataBlockMetadata)) == 1
    cfg = EnvironmentConfiguration(
        key=f"_test_{rand_str()}",
        metadata_storage_url=db_url,
        settings=SnapflowSettings(add_core_module=False),
    )
    env2 = Environment.from_config(cfg)
    with env2.md_api.begin():
        assert env2.md_api.count(select(DataBlockMetadata)) == 0
        env2.md_api.add(DataBlockMetadata(realized_schema_key="Any"))
        env2.md_api.flush()
        assert env2.md_api.count(select(DataBlockMetadata)) == 1