mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
[format] Using Black (#7769)
This commit is contained in:
@@ -21,11 +21,8 @@ from sqlalchemy.orm.session import make_transient
|
||||
|
||||
|
||||
def import_datasource(
|
||||
session,
|
||||
i_datasource,
|
||||
lookup_database,
|
||||
lookup_datasource,
|
||||
import_time):
|
||||
session, i_datasource, lookup_database, lookup_datasource, import_time
|
||||
):
|
||||
"""Imports the datasource from the object to the database.
|
||||
|
||||
Metrics and columns and datasource will be overrided if exists.
|
||||
@@ -33,8 +30,7 @@ def import_datasource(
|
||||
superset instances. Audit metadata isn't copies over.
|
||||
"""
|
||||
make_transient(i_datasource)
|
||||
logging.info('Started import of the datasource: {}'.format(
|
||||
i_datasource.to_json()))
|
||||
logging.info("Started import of the datasource: {}".format(i_datasource.to_json()))
|
||||
|
||||
i_datasource.id = None
|
||||
i_datasource.database_id = lookup_database(i_datasource).id
|
||||
@@ -54,21 +50,25 @@ def import_datasource(
|
||||
for m in i_datasource.metrics:
|
||||
new_m = m.copy()
|
||||
new_m.table_id = datasource.id
|
||||
logging.info('Importing metric {} from the datasource: {}'.format(
|
||||
new_m.to_json(), i_datasource.full_name))
|
||||
logging.info(
|
||||
"Importing metric {} from the datasource: {}".format(
|
||||
new_m.to_json(), i_datasource.full_name
|
||||
)
|
||||
)
|
||||
imported_m = i_datasource.metric_class.import_obj(new_m)
|
||||
if (imported_m.metric_name not in
|
||||
[m.metric_name for m in datasource.metrics]):
|
||||
if imported_m.metric_name not in [m.metric_name for m in datasource.metrics]:
|
||||
datasource.metrics.append(imported_m)
|
||||
|
||||
for c in i_datasource.columns:
|
||||
new_c = c.copy()
|
||||
new_c.table_id = datasource.id
|
||||
logging.info('Importing column {} from the datasource: {}'.format(
|
||||
new_c.to_json(), i_datasource.full_name))
|
||||
logging.info(
|
||||
"Importing column {} from the datasource: {}".format(
|
||||
new_c.to_json(), i_datasource.full_name
|
||||
)
|
||||
)
|
||||
imported_c = i_datasource.column_class.import_obj(new_c)
|
||||
if (imported_c.column_name not in
|
||||
[c.column_name for c in datasource.columns]):
|
||||
if imported_c.column_name not in [c.column_name for c in datasource.columns]:
|
||||
datasource.columns.append(imported_c)
|
||||
session.flush()
|
||||
return datasource.id
|
||||
|
||||
Reference in New Issue
Block a user