[flake8] Resolving F5?? errors (#3846)
This commit is contained in:
parent
1a3a8daf49
commit
1b4f128f55
|
|
@ -348,7 +348,9 @@ try:
|
|||
print('Loaded your LOCAL configuration at [{}]'.format(
|
||||
os.environ[CONFIG_PATH_ENV_VAR]))
|
||||
module = sys.modules[__name__]
|
||||
override_conf = imp.load_source('superset_config', os.environ[CONFIG_PATH_ENV_VAR])
|
||||
override_conf = imp.load_source(
|
||||
'superset_config',
|
||||
os.environ[CONFIG_PATH_ENV_VAR])
|
||||
for key in dir(override_conf):
|
||||
if key.isupper():
|
||||
setattr(module, key, getattr(override_conf, key))
|
||||
|
|
|
|||
|
|
@ -612,7 +612,10 @@ class Database(Model, AuditMixinNullable):
|
|||
effective_username = url.username
|
||||
if user_name:
|
||||
effective_username = user_name
|
||||
elif hasattr(g, 'user') and hasattr(g.user, 'username') and g.user.username is not None:
|
||||
elif (
|
||||
hasattr(g, 'user') and hasattr(g.user, 'username') and
|
||||
g.user.username is not None
|
||||
):
|
||||
effective_username = g.user.username
|
||||
return effective_username
|
||||
|
||||
|
|
@ -622,8 +625,12 @@ class Database(Model, AuditMixinNullable):
|
|||
url = self.db_engine_spec.adjust_database_uri(url, schema)
|
||||
effective_username = self.get_effective_user(url, user_name)
|
||||
# If using MySQL or Presto for example, will set url.username
|
||||
# If using Hive, will not do anything yet since that relies on a configuration parameter instead.
|
||||
self.db_engine_spec.modify_url_for_impersonation(url, self.impersonate_user, effective_username)
|
||||
# If using Hive, will not do anything yet since that relies on a
|
||||
# configuration parameter instead.
|
||||
self.db_engine_spec.modify_url_for_impersonation(
|
||||
url,
|
||||
self.impersonate_user,
|
||||
effective_username)
|
||||
|
||||
masked_url = self.get_password_masked_url(url)
|
||||
logging.info("Database.get_sqla_engine(). Masked URL: {0}".format(masked_url))
|
||||
|
|
@ -635,9 +642,10 @@ class Database(Model, AuditMixinNullable):
|
|||
# If using Hive, this will set hive.server2.proxy.user=$effective_username
|
||||
configuration = {}
|
||||
configuration.update(
|
||||
self.db_engine_spec.get_configuration_for_impersonation(str(url),
|
||||
self.impersonate_user,
|
||||
effective_username))
|
||||
self.db_engine_spec.get_configuration_for_impersonation(
|
||||
str(url),
|
||||
self.impersonate_user,
|
||||
effective_username))
|
||||
if configuration:
|
||||
params["connect_args"] = {"configuration": configuration}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,10 @@ def execute_sql(
|
|||
conn = None
|
||||
try:
|
||||
engine = database.get_sqla_engine(
|
||||
schema=query.schema, nullpool=not ctask.request.called_directly, user_name=user_name)
|
||||
schema=query.schema,
|
||||
nullpool=not ctask.request.called_directly,
|
||||
user_name=user_name,
|
||||
)
|
||||
conn = engine.raw_connection()
|
||||
cursor = conn.cursor()
|
||||
logging.info("Running query: \n{}".format(executed_sql))
|
||||
|
|
|
|||
|
|
@ -238,10 +238,11 @@ class DatabaseView(SupersetModelView, DeleteMixin): # noqa
|
|||
"(http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html"
|
||||
"#sqlalchemy.schema.MetaData) call. ", True),
|
||||
'impersonate_user': _(
|
||||
"If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user "
|
||||
"who must have permission to run them.<br/>"
|
||||
"If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, "
|
||||
"but impersonate the currently logged on user via hive.server2.proxy.user property."),
|
||||
"If Presto, all the queries in SQL Lab are going to be executed as the "
|
||||
"currently logged on user who must have permission to run them.<br/>"
|
||||
"If Hive and hive.server2.enable.doAs is enabled, will run the queries as "
|
||||
"service account, but impersonate the currently logged on user "
|
||||
"via hive.server2.proxy.user property."),
|
||||
}
|
||||
label_columns = {
|
||||
'expose_in_sqllab': _("Expose in SQL Lab"),
|
||||
|
|
@ -1102,7 +1103,9 @@ class Superset(BaseSupersetView):
|
|||
action = request.args.get('action')
|
||||
|
||||
if action == 'overwrite' and not slice_overwrite_perm:
|
||||
return json_error_response("You don't have the rights to alter this slice", status=400)
|
||||
return json_error_response(
|
||||
"You don't have the rights to alter this slice",
|
||||
status=400)
|
||||
|
||||
if action in ('saveas', 'overwrite'):
|
||||
return self.save_or_overwrite_slice(
|
||||
|
|
@ -1462,7 +1465,8 @@ class Superset(BaseSupersetView):
|
|||
|
||||
if database and uri:
|
||||
url = make_url(uri)
|
||||
db_engine = models.Database.get_db_engine_spec_for_backend(url.get_backend_name())
|
||||
db_engine = models.Database.get_db_engine_spec_for_backend(
|
||||
url.get_backend_name())
|
||||
db_engine.patch()
|
||||
|
||||
masked_url = database.get_password_masked_url_from_uri(uri)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ BASE_DIR = app.config.get('BASE_DIR')
|
|||
class CeleryConfig(object):
|
||||
BROKER_URL = 'sqla+sqlite:///' + app.config.get('SQL_CELERY_DB_FILE_PATH')
|
||||
CELERY_IMPORTS = ('superset.sql_lab', )
|
||||
CELERY_RESULT_BACKEND = 'db+sqlite:///' + app.config.get('SQL_CELERY_RESULTS_DB_FILE_PATH')
|
||||
CELERY_RESULT_BACKEND = (
|
||||
'db+sqlite:///' + app.config.get('SQL_CELERY_RESULTS_DB_FILE_PATH'))
|
||||
CELERY_ANNOTATIONS = {'sql_lab.add': {'rate_limit': '10/s'}}
|
||||
CONCURRENCY = 1
|
||||
|
||||
|
|
|
|||
|
|
@ -283,7 +283,10 @@ class CoreTests(SupersetTestCase):
|
|||
'name': 'main',
|
||||
'impersonate_user': False,
|
||||
})
|
||||
response = self.client.post('/superset/testconn', data=data, content_type='application/json')
|
||||
response = self.client.post(
|
||||
'/superset/testconn',
|
||||
data=data,
|
||||
content_type='application/json')
|
||||
assert response.status_code == 200
|
||||
assert response.headers['Content-Type'] == 'application/json'
|
||||
|
||||
|
|
@ -293,7 +296,10 @@ class CoreTests(SupersetTestCase):
|
|||
'name': 'main',
|
||||
'impersonate_user': False,
|
||||
})
|
||||
response = self.client.post('/superset/testconn', data=data, content_type='application/json')
|
||||
response = self.client.post(
|
||||
'/superset/testconn',
|
||||
data=data,
|
||||
content_type='application/json')
|
||||
assert response.status_code == 200
|
||||
assert response.headers['Content-Type'] == 'application/json'
|
||||
|
||||
|
|
@ -311,7 +317,8 @@ class CoreTests(SupersetTestCase):
|
|||
assert conn.password != conn_pre.password
|
||||
|
||||
def test_databaseview_edit(self, username='admin'):
|
||||
# validate that sending a password-masked uri does not over-write the decrypted uri
|
||||
# validate that sending a password-masked uri does not over-write the decrypted
|
||||
# uri
|
||||
self.login(username=username)
|
||||
database = self.get_main_database(db.session)
|
||||
sqlalchemy_uri_decrypted = database.sqlalchemy_uri_decrypted
|
||||
|
|
@ -740,7 +747,8 @@ class CoreTests(SupersetTestCase):
|
|||
self.assertNotIn('message', data)
|
||||
data = self.get_json_resp('/superset/fave_dashboards/{}/'.format(userid))
|
||||
self.assertNotIn('message', data)
|
||||
data = self.get_json_resp('/superset/fave_dashboards_by_username/{}/'.format(username))
|
||||
data = self.get_json_resp(
|
||||
'/superset/fave_dashboards_by_username/{}/'.format(username))
|
||||
self.assertNotIn('message', data)
|
||||
|
||||
def test_slice_id_is_always_logged_correctly_on_web_request(self):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
log = """
|
||||
17/02/07 18:26:27 INFO log.PerfLogger: <PERFLOG method=compile from=org.apache.hadoop.hive.ql.Driver>
|
||||
17/02/07 18:26:27 INFO log.PerfLogger: <PERFLOG method=parse from=org.apache.hadoop.hive.ql.Driver>
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(
|
||||
0, HiveEngineSpec.progress(log))
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
17/02/07 19:15:55 INFO ql.Driver: Total jobs = 2
|
||||
17/02/07 19:15:55 INFO ql.Driver: Launching Job 1 out of 2
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, reduce = 0%
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(0, HiveEngineSpec.progress(log))
|
||||
|
||||
def test_job_1_launched_stage_1_map_40_progress(self):
|
||||
|
|
@ -44,7 +44,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
17/02/07 19:15:55 INFO ql.Driver: Launching Job 1 out of 2
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, reduce = 0%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%, reduce = 0%
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(10, HiveEngineSpec.progress(log))
|
||||
|
||||
def test_job_1_launched_stage_1_map_80_reduce_40_progress(self):
|
||||
|
|
@ -54,7 +54,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, reduce = 0%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%, reduce = 0%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 80%, reduce = 40%
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(30, HiveEngineSpec.progress(log))
|
||||
|
||||
def test_job_1_launched_stage_2_stages_progress(self):
|
||||
|
|
@ -66,7 +66,7 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 80%, reduce = 40%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-2 map = 0%, reduce = 0%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 100%, reduce = 0%
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(12, HiveEngineSpec.progress(log))
|
||||
|
||||
def test_job_2_launched_stage_2_stages_progress(self):
|
||||
|
|
@ -77,5 +77,5 @@ class DbEngineSpecsTestCase(unittest.TestCase):
|
|||
17/02/07 19:15:55 INFO ql.Driver: Launching Job 2 out of 2
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 0%, reduce = 0%
|
||||
17/02/07 19:16:09 INFO exec.Task: 2017-02-07 19:16:09,173 Stage-1 map = 40%, reduce = 0%
|
||||
""".split('\n')
|
||||
""".split('\n') # noqa ignore: E501
|
||||
self.assertEquals(60, HiveEngineSpec.progress(log))
|
||||
|
|
|
|||
Loading…
Reference in New Issue