Пример #1
0
 def _determine_datasource_key(
         self, datasource_name: str) -> DataContextVariableKey:
     datasource_key: DataContextVariableKey = DataContextVariableKey(
         resource_type=DataContextVariableSchema.DATASOURCES,
         resource_name=datasource_name,
     )
     return datasource_key
Пример #2
0
    def _get_key(self,
                 attr: DataContextVariableSchema) -> DataContextVariableKey:
        # Chetan - 20220607 - As it stands, DataContextVariables can only perform CRUD on entire objects.
        # The DataContextVariablesKey, when used with an appropriate Store and StoreBackend, gives the ability to modify
        # individual elements of nested config objects.

        key: DataContextVariableKey = DataContextVariableKey(
            resource_type=attr.value)
        return key
def datasource_store_with_single_datasource(
    datasource_name: str,
    datasource_config: DatasourceConfig,
    empty_datasource_store: DatasourceStore,
) -> DatasourceStore:
    key: DataContextVariableKey = DataContextVariableKey(
        resource_type=DataContextVariableSchema.DATASOURCES,
        resource_name=datasource_name,
    )
    empty_datasource_store.set(key=key, value=datasource_config)
    return empty_datasource_store
Пример #4
0
def test_datasource_store_retrieval(
        empty_datasource_store: DatasourceStore,
        datasource_config: DatasourceConfig) -> None:
    store: DatasourceStore = empty_datasource_store

    key: DataContextVariableKey = DataContextVariableKey(
        resource_type=DataContextVariableSchema.DATASOURCES,
        resource_name="my_datasource",
    )
    store.set(key=key, value=datasource_config)
    res: DatasourceConfig = store.get(key=key)

    assert isinstance(res, DatasourceConfig)
    assert res.to_json_dict() == datasource_config.to_json_dict()
def test_datasource_store_update_by_name(
    datasource_name: str,
    datasource_config: DatasourceConfig,
    datasource_store_with_single_datasource: DatasourceStore,
) -> None:
    updated_base_directory: str = "foo/bar/baz"

    updated_datasource_config = copy.deepcopy(datasource_config)
    updated_datasource_config.data_connectors["tripdata_monthly_configured"][
        "base_directory"] = updated_base_directory

    datasource_store_with_single_datasource.update_by_name(
        datasource_name=datasource_name,
        datasource_config=updated_datasource_config)

    key = DataContextVariableKey(
        resource_type=DataContextVariableSchema.DATASOURCES,
        resource_name=datasource_name,
    )
    actual_config = cast(DatasourceConfig,
                         datasource_store_with_single_datasource.get(key=key))

    assert actual_config.to_dict() == updated_datasource_config.to_dict()
Пример #6
0
def test_datasource_store_with_inline_store_backend(
        datasource_config: DatasourceConfig,
        empty_data_context: DataContext) -> None:
    inline_store_backend_config: dict = {
        "class_name": "InlineStoreBackend",
        "data_context": empty_data_context,
        "suppress_store_backend_id": True,
    }

    store: DatasourceStore = DatasourceStore(
        store_name="my_datasource_store",
        store_backend=inline_store_backend_config,
    )

    key: DataContextVariableKey = DataContextVariableKey(
        resource_type=DataContextVariableSchema.DATASOURCES,
        resource_name="my_datasource",
    )

    store.set(key=key, value=datasource_config)
    res: DatasourceConfig = store.get(key=key)

    assert isinstance(res, DatasourceConfig)
    assert res.to_json_dict() == datasource_config.to_json_dict()
Пример #7
0
 def remove_key(self, key: DataContextVariableKey) -> None:
     """
     See parent `Store.remove_key()` for more information
     """
     return self._store_backend.remove_key(key.to_tuple())