Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): rest emitter should override config and env variables #4622

Merged
merged 5 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions metadata-ingestion/src/datahub/cli/cli_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import os
import os.path
import sys
import typing
Expand Down Expand Up @@ -76,6 +77,14 @@ class DatahubConfig(BaseModel):
gms: GmsConfig


def set_env_variables_override_config(host: str, token: Optional[str]) -> None:
"""Should be used to override the config when using rest emitter"""
os.environ[ENV_SKIP_CONFIG] = "true"
os.environ[ENV_METADATA_HOST] = host
if token is not None:
os.environ[ENV_METADATA_TOKEN] = token


def write_datahub_config(host: str, token: Optional[str]) -> None:
config = {
"gms": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dataclasses import dataclass
from typing import Union, cast

from datahub.cli.cli_utils import set_env_variables_override_config
from datahub.configuration.common import OperationalError
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.emitter.rest_emitter import DatahubRestEmitter
Expand Down Expand Up @@ -57,7 +58,9 @@ def __init__(self, ctx: PipelineContext, config: DatahubRestSinkConfig):
.get("linkedin/datahub", {})
.get("version", "")
)
logger.info("Setting gms config")
logger.debug("Setting env variables to override config")
set_env_variables_override_config(self.config.server, self.config.token)
logger.debug("Setting gms config")
set_gms_config(gms_config)
self.executor = concurrent.futures.ThreadPoolExecutor(
max_workers=self.config.max_threads
Expand Down