forked from amundsen-io/amundsen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
175 lines (129 loc) · 6.25 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0
import distutils.util
import logging
import os
from typing import Any, Callable, Dict, List, Optional, Set # noqa: F401
import boto3
from flask import Flask # noqa: F401
from metadata_service.entity.badge import Badge
# PROXY configuration keys
PROXY_HOST = 'PROXY_HOST'
PROXY_PORT = 'PROXY_PORT'
PROXY_USER = 'PROXY_USER'
PROXY_PASSWORD = 'PROXY_PASSWORD'
PROXY_ENCRYPTED = 'PROXY_ENCRYPTED'
PROXY_VALIDATE_SSL = 'PROXY_VALIDATE_SSL'
PROXY_DATABASE_NAME = 'PROXY_DATABASE_NAME'
PROXY_CLIENT = 'PROXY_CLIENT'
PROXY_CLIENT_KWARGS = 'PROXY_CLIENT_KWARGS'
PROXY_CLIENTS = {
'NEO4J': 'metadata_service.proxy.neo4j_proxy.Neo4jProxy',
'ATLAS': 'metadata_service.proxy.atlas_proxy.AtlasProxy',
'NEPTUNE': 'metadata_service.proxy.neptune_proxy.NeptuneGremlinProxy',
'MYSQL': 'metadata_service.proxy.mysql_proxy.MySQLProxy'
}
PROXY_CLIS = {
'MYSQL': 'metadata_service.cli.rds_command.rds_cli'
}
IS_STATSD_ON = 'IS_STATSD_ON'
USER_OTHER_KEYS = 'USER_OTHER_KEYS'
class Config:
LOG_FORMAT = '%(asctime)s.%(msecs)03d [%(levelname)s] %(module)s.%(funcName)s:%(lineno)d (%(process)d:' \
'%(threadName)s) - %(message)s'
LOG_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S%z'
LOG_LEVEL = 'INFO'
# Path to the logging configuration file to be used by `fileConfig()` method
# https://docs.python.org/3.7/library/logging.config.html#logging.config.fileConfig
# LOG_CONFIG_FILE = 'metadata_service/logging.conf'
LOG_CONFIG_FILE = None
PROXY_USER = os.environ.get('CREDENTIALS_PROXY_USER', 'neo4j')
PROXY_PASSWORD = os.environ.get('CREDENTIALS_PROXY_PASSWORD', 'test')
PROXY_ENCRYPTED = True
"""Whether the connection to the proxy should use SSL/TLS encryption."""
# Prior to enable PROXY_VALIDATE_SSL, you need to configure SSL.
# https://neo4j.com/docs/operations-manual/current/security/ssl-framework/
PROXY_VALIDATE_SSL = False
"""Whether the SSL/TLS certificate presented by the user should be validated against the system's trusted CAs."""
PROXY_DATABASE_NAME = None
IS_STATSD_ON = False
# Configurable dictionary to influence format of column statistics displayed in UI
STATISTICS_FORMAT_SPEC: Dict[str, Dict] = {}
# whitelist badges
WHITELIST_BADGES: List[Badge] = []
SWAGGER_ENABLED = os.environ.get('SWAGGER_ENABLED', False)
USER_DETAIL_METHOD = None # type: Optional[function]
RESOURCE_REPORT_CLIENT = None # type: Optional[function]
# On User detail method, these keys will be added into amundsen_common.models.user.User.other_key_values
USER_OTHER_KEYS = {'mode_user_id'} # type: Set[str]
# DEPRECATED (since version 3.6.0): Please use `POPULAR_RESOURCES_MINIMUM_READER_COUNT`
# Number of minimum reader count to qualify for popular resources
POPULAR_TABLE_MINIMUM_READER_COUNT = None
POPULAR_RESOURCES_MINIMUM_READER_COUNT = 10 # type: int
# List of regexes which will exclude certain parameters from appearing as Programmatic Descriptions
PROGRAMMATIC_DESCRIPTIONS_EXCLUDE_FILTERS = [] # type: list
# Custom kwargs that will be passed to proxy client. Can be used to fine-tune parameters like timeout
# or num of retries
PROXY_CLIENT_KWARGS: Dict = dict()
# Initialize custom flask extensions and routes
INIT_CUSTOM_EXT_AND_ROUTES = None # type: Callable[[Flask], None]
SWAGGER_TEMPLATE_PATH = os.path.join('api', 'swagger_doc', 'template.yml')
SWAGGER = {
'openapi': '3.0.2',
'title': 'Metadata Service',
'uiversion': 3
}
class LocalConfig(Config):
DEBUG = True
TESTING = False
LOG_LEVEL = 'DEBUG'
LOCAL_HOST = '0.0.0.0'
PROXY_HOST = os.environ.get('PROXY_HOST', f'bolt://{LOCAL_HOST}')
PROXY_PORT = os.environ.get('PROXY_PORT', 7687)
PROXY_CLIENT = PROXY_CLIENTS[os.environ.get('PROXY_CLIENT', 'NEO4J')]
PROXY_ENCRYPTED = bool(distutils.util.strtobool(os.environ.get(PROXY_ENCRYPTED, 'True')))
PROXY_VALIDATE_SSL = bool(distutils.util.strtobool(os.environ.get(PROXY_VALIDATE_SSL, 'False')))
IS_STATSD_ON = bool(distutils.util.strtobool(os.environ.get(IS_STATSD_ON, 'False')))
SWAGGER_ENABLED = True
class AtlasConfig(LocalConfig):
PROXY_HOST = os.environ.get('PROXY_HOST', 'localhost')
PROXY_PORT = os.environ.get('PROXY_PORT', '21000')
PROXY_CLIENT = PROXY_CLIENTS['ATLAS']
# List of accepted date formats for AtlasProxy Watermarks. With this we allow more than one datetime partition
# format to be used in tables
WATERMARK_DATE_FORMATS = ['%Y%m%d']
class MySQLConfig(LocalConfig):
PROXY_CLIENT = PROXY_CLIENTS['MYSQL']
PROXY_CLI = PROXY_CLIS['MYSQL']
PROXY_HOST = None # type: ignore
PROXY_PORT = None # type: ignore
PROXY_USER = None # type: ignore
PROXY_PASSWORD = None # type: ignore
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI', 'mysql://user:[email protected]:3306/amundsen')
PROXY_CLIENT_KWARGS: Dict[str, Any] = {
'echo': bool(distutils.util.strtobool(os.environ.get('ECHO', 'False'))),
'pool_size': os.environ.get('POOL_SIZE', 5),
'max_overflow': os.environ.get('MAX_OVERFLOW', 10),
'connect_args': dict()
}
try:
from amundsen_gremlin.config import LocalGremlinConfig
class GremlinConfig(LocalGremlinConfig, LocalConfig):
JANUS_GRAPH_URL = None
class NeptuneConfig(LocalGremlinConfig, LocalConfig):
DEBUG = False
LOG_LEVEL = 'INFO'
# PROXY_HOST FORMAT: wss://<NEPTUNE_URL>:<NEPTUNE_PORT>/gremlin
PROXY_HOST = os.environ.get('PROXY_HOST', 'localhost')
PROXY_PORT = None # type: ignore
PROXY_CLIENT = PROXY_CLIENTS['NEPTUNE']
PROXY_PASSWORD = boto3.session.Session(region_name=os.environ.get('AWS_REGION', 'us-east-1'))
PROXY_CLIENT_KWARGS = {
'neptune_bulk_loader_s3_bucket_name': os.environ.get('S3_BUCKET_NAME'),
'ignore_neptune_shard': distutils.util.strtobool(os.environ.get('IGNORE_NEPTUNE_SHARD', 'True'))
}
JANUS_GRAPH_URL = None
except ImportError:
logging.warning("""amundsen_gremlin not installed. GremlinConfig and NeptuneConfig classes won't be available!
Please install amundsen-metadata[gremlin] if you desire to use those classes.
""")