Skip to content

Commit

Permalink
Fix tpe error and oauth row
Browse files Browse the repository at this point in the history
  • Loading branch information
vallbull committed Dec 21, 2023
1 parent 5602037 commit fdb9994
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from dl_configs.connectors_settings import ConnectorSettingsBase

from dl_connector_ydb.api.ydb.connection_info import YDBConnectionInfoProvider
from dl_connector_ydb.api.ydb.i18n.localizer import Translatable
from dl_connector_ydb.core.ydb.settings import YDBConnectorSettings


Expand All @@ -53,7 +54,7 @@ def _get_default_db_section(self, rc: RowConstructor, connector_settings: YDBCon
if connector_settings.MANAGED_OAUTH_ROW
else C.CustomizableRow(
items=[
C.LabelRowItem(text="OAuth"),
C.LabelRowItem(text=self._localizer.translate(Translatable("field_oauth_row"))),
C.InputRowItem(
name=CommonFieldName.token,
width="l",
Expand Down Expand Up @@ -131,7 +132,7 @@ def get_form_config(
common_api_schema_items.append(
FormFieldApiSchema(
name=CommonFieldName.token,
required=self.mode == ConnectionFormMode.create,
required=self.mode == ConnectionFormMode.create and connector_settings.MANAGED_OAUTH_ROW,
)
)
edit_api_schema.items.extend(common_api_schema_items)
Expand Down
32 changes: 28 additions & 4 deletions lib/dl_connector_ydb/dl_connector_ydb/core/ydb/settings.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
from typing import Optional
from typing import (
ClassVar,
Optional,
)

import attr

from dl_configs.connectors_data import ConnectorsDataBase
from dl_configs.connectors_settings import (
ConnectorsConfigType,
ConnectorSettingsBase,
)
from dl_configs.settings_loaders.meta_definition import s_attrib
from dl_core.connectors.settings.primitives import ConnectorSettingsDefinition
from dl_core.connectors.settings.primitives import (
ConnectorSettingsDefinition,
get_connectors_settings_config,
)


@attr.s(frozen=True)
class YDBConnectorSettings(ConnectorSettingsBase):
MANAGED_OAUTH_ROW: Optional[str] = False
MANAGED_OAUTH_ROW: Optional[bool] = s_attrib("MANAGED_OAUTH_ROW", missing=True)
DEFAULT_HOST_VALUE: Optional[str] = s_attrib("DEFAULT_HOST_VALUE", missing=None) # type: ignore


class ConnectorsDataYDBBase(ConnectorsDataBase):
MANAGED_OAUTH_ROW: ClassVar[Optional[bool]] = True

@classmethod
def connector_name(cls) -> str:
return "YDB"


def ydb_settings_fallback(full_cfg: ConnectorsConfigType) -> dict[str, ConnectorSettingsBase]:
return dict(YDB=YDBConnectorSettings())
# return dict(YDB=YDBConnectorSettings())

cfg = get_connectors_settings_config(
full_cfg,
object_like_config_key="YDB",
connector_data_class=ConnectorsDataYDBBase,
)
if cfg is None:
return {}
return dict(YDB=YDBConnectorSettings(MANAGED_OAUTH_ROW=cfg.MANAGED_OAUTH_ROW)) # type: ignore


class YDBSettingDefinition(ConnectorSettingsDefinition):
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ msgstr ""
msgid "label_connector-ydb"
msgstr "YDB"

msgid "field_oauth_row"
msgstr "OAuth token"

msgid "source_templates-tab_title-table"
msgstr "Table"

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ msgstr ""
msgid "label_connector-ydb"
msgstr "YDB"

msgid "field_oauth_row"
msgstr "OAuth-токен"

msgid "source_templates-tab_title-table"
msgstr "Таблица"

Expand Down
3 changes: 2 additions & 1 deletion lib/dl_core/dl_core/services_registry/sr_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from dl_core.us_manager.mutation_cache.usentry_mutation_cache_factory import USEntryMutationCacheFactory
from dl_core.utils import FutureRef
from dl_task_processor.processor import ARQTaskProcessorFactory
from dl_utils.aio import ContextVarExecutor


if TYPE_CHECKING:
Expand Down Expand Up @@ -116,7 +117,7 @@ def make_conn_executor_factory(
LOGGER.info("ATTENTION! It's bleeding edge user")
return DefaultConnExecutorFactory(
async_env=self.async_env,
tpe=None,
tpe=ContextVarExecutor(),
conn_sec_mgr=self.env_manager_factory.make_security_manager(),
rqe_config=self.rqe_config,
services_registry_ref=sr_ref, # type: ignore # TODO: fix
Expand Down

0 comments on commit fdb9994

Please sign in to comment.