-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
chore: switching out ConnectorRegistry references for DatasourceDAO #20380
Conversation
…uperset into connreg-to-datadao_2
…reg-to-datadao_2
@@ -82,7 +82,6 @@ def _create_energy_table(): | |||
table.metrics.append( | |||
SqlMetric(metric_name="sum__value", expression=f"SUM({col})") | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could keep this in here.
# todo(hughhhh): fully remove the datasource config register | ||
for module_name, class_names in module_datasource_map.items(): | ||
class_names = [str(s) for s in class_names] | ||
__import__(module_name, fromlist=class_names) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that we wouldn't have to init anything to make this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove the DEFAULT_MODULE_DS_MAP and ADDITIONAL_MODULE_DS_MAP for SIP68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason the app won't without this code being here, can we put that into another ticket?
@@ -407,16 +408,18 @@ def export_dashboards( # pylint: disable=too-many-locals | |||
id_ = target.get("datasetId") | |||
if id_ is None: | |||
continue | |||
datasource = ConnectorRegistry.get_datasource_by_id(session, id_) | |||
datasource = DatasourceDAO.get_datasource( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.. I don't think we need to use the DatasourceDAO if there's only one type that will be used.
superset/examples/helpers.py
Outdated
|
||
BASE_URL = "https://github.com/apache-superset/examples-data/blob/master/" | ||
|
||
misc_dash_slices: Set[str] = set() # slices assembled in a 'Misc Chart' dashboard | ||
|
||
|
||
def get_table_connector_registry() -> Any: | ||
return ConnectorRegistry.sources["table"] | ||
return DatasourceDAO.sources[DatasourceType.TABLE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use sqlatable lookup directly instead of the DatasourceDAO since it's only one type?
@@ -35,7 +36,7 @@ def get_table( | |||
schema: Optional[str] = None, | |||
): | |||
schema = schema or get_example_default_schema() | |||
table_source = ConnectorRegistry.sources["table"] | |||
table_source = DatasourceDAO.sources[DatasourceType.TABLE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just import SQLATable here directly?
@@ -54,7 +55,7 @@ def create_table_metadata( | |||
|
|||
table = get_table(table_name, database, schema) | |||
if not table: | |||
table_source = ConnectorRegistry.sources["table"] | |||
table_source = DatasourceDAO.sources[DatasourceType.TABLE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -256,8 +258,8 @@ def test_external_metadata_error_return_400(self, mock_get_datasource): | |||
|
|||
pytest.raises( | |||
SupersetGenericDBErrorException, | |||
lambda: ConnectorRegistry.get_datasource( | |||
"table", tbl.id, db.session | |||
lambda: DatasourceDAO.get_datasource( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we query just sqlatable here?
Codecov Report
@@ Coverage Diff @@
## master #20380 +/- ##
==========================================
- Coverage 66.64% 66.53% -0.11%
==========================================
Files 1729 1738 +9
Lines 64904 65062 +158
Branches 6842 6897 +55
==========================================
+ Hits 43257 43292 +35
- Misses 19897 20017 +120
- Partials 1750 1753 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
d4c13be
to
fe33b5f
Compare
fe33b5f
to
64ecbfe
Compare
…uperset into connreg-to-datadao_2
DatasetNotFoundError, | ||
lambda: ConnectorRegistry.get_datasource("table", 9999999, db.session), | ||
DatasourceNotFound, | ||
lambda: DatasourceDAO.get_datasource(db.session, "table", 9999999), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are testing the actual function calls inside the views/datasource.py
files which call DatasourceDAO
now
…pache#20380) * rename and move dao file * Update dao.py * add cachekey * Update __init__.py * change reference in query context test * add utils ref * more ref changes * add helpers * add todo in dashboard.py * add cachekey * circular import error in dar.py * push rest of refs * fix linting * fix more linting * update enum * remove references for connector registry * big reafctor * take value * fix * test to see if removing value works * delete connectregistry * address concerns * address comments * fix merge conflicts * address concern II * address concern II * fix test Co-authored-by: Phillip Kelley-Dotson <pkelleydotson@yahoo.com>
SUMMARY
Switching out all references of
ConnectorRegistry
toDatasourceDAO
. In the PR, we are focusing on just removing the references and moving towards allowing other Datasources to power charts.One issue is the circular dependencies that are blocking us from fully removing the logic to allow the app to run. So i've moved that code out the
ConnectorRegistry
for now and will prioritize a bigger refactor to stop the import issues in superset moving forward.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION