partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
check_ownership
Meant to be used in `pre_update` hooks on models to enforce ownership Admin have all access, and other users need to be referenced on either the created_by field that comes with the ``AuditMixin``, or in a field named ``owners`` which is expected to be a one-to-many with the User model. It is meant to ...
superset/views/base.py
def check_ownership(obj, raise_if_false=True): """Meant to be used in `pre_update` hooks on models to enforce ownership Admin have all access, and other users need to be referenced on either the created_by field that comes with the ``AuditMixin``, or in a field named ``owners`` which is expected to be ...
def check_ownership(obj, raise_if_false=True): """Meant to be used in `pre_update` hooks on models to enforce ownership Admin have all access, and other users need to be referenced on either the created_by field that comes with the ``AuditMixin``, or in a field named ``owners`` which is expected to be ...
[ "Meant", "to", "be", "used", "in", "pre_update", "hooks", "on", "models", "to", "enforce", "ownership" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L331-L374
[ "def", "check_ownership", "(", "obj", ",", "raise_if_false", "=", "True", ")", ":", "if", "not", "obj", ":", "return", "False", "security_exception", "=", "SupersetSecurityException", "(", "\"You don't have the rights to alter [{}]\"", ".", "format", "(", "obj", ")"...
ca2996c78f679260eb79c6008e276733df5fb653
train
bind_field
Customize how fields are bound by stripping all whitespace. :param form: The form :param unbound_field: The unbound field :param options: The field options :returns: The bound field
superset/views/base.py
def bind_field( self, form: DynamicForm, unbound_field: UnboundField, options: Dict[Any, Any], ) -> Field: """ Customize how fields are bound by stripping all whitespace. :param form: The form :param unbound_field: The unbound field :param options: The field opti...
def bind_field( self, form: DynamicForm, unbound_field: UnboundField, options: Dict[Any, Any], ) -> Field: """ Customize how fields are bound by stripping all whitespace. :param form: The form :param unbound_field: The unbound field :param options: The field opti...
[ "Customize", "how", "fields", "are", "bound", "by", "stripping", "all", "whitespace", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L377-L394
[ "def", "bind_field", "(", "self", ",", "form", ":", "DynamicForm", ",", "unbound_field", ":", "UnboundField", ",", "options", ":", "Dict", "[", "Any", ",", "Any", "]", ",", ")", "->", "Field", ":", "filters", "=", "unbound_field", ".", "kwargs", ".", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
BaseSupersetView.common_bootsrap_payload
Common data always sent to the client
superset/views/base.py
def common_bootsrap_payload(self): """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { 'flash_messages': messages, 'conf': {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, '...
def common_bootsrap_payload(self): """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { 'flash_messages': messages, 'conf': {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, '...
[ "Common", "data", "always", "sent", "to", "the", "client" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L156-L166
[ "def", "common_bootsrap_payload", "(", "self", ")", ":", "messages", "=", "get_flashed_messages", "(", "with_categories", "=", "True", ")", "locale", "=", "str", "(", "get_locale", "(", ")", ")", "return", "{", "'flash_messages'", ":", "messages", ",", "'conf'...
ca2996c78f679260eb79c6008e276733df5fb653
train
DeleteMixin._delete
Delete function logic, override to implement diferent logic deletes the record with primary_key = pk :param pk: record primary key to delete
superset/views/base.py
def _delete(self, pk): """ Delete function logic, override to implement diferent logic deletes the record with primary_key = pk :param pk: record primary key to delete """ item = self.datamodel.get(pk, self._base_filters) if not item: ...
def _delete(self, pk): """ Delete function logic, override to implement diferent logic deletes the record with primary_key = pk :param pk: record primary key to delete """ item = self.datamodel.get(pk, self._base_filters) if not item: ...
[ "Delete", "function", "logic", "override", "to", "implement", "diferent", "logic", "deletes", "the", "record", "with", "primary_key", "=", "pk" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L207-L251
[ "def", "_delete", "(", "self", ",", "pk", ")", ":", "item", "=", "self", ".", "datamodel", ".", "get", "(", "pk", ",", "self", ".", "_base_filters", ")", "if", "not", "item", ":", "abort", "(", "404", ")", "try", ":", "self", ".", "pre_delete", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetFilter.get_all_permissions
Returns a set of tuples with the perm name and view menu name
superset/views/base.py
def get_all_permissions(self): """Returns a set of tuples with the perm name and view menu name""" perms = set() for role in self.get_user_roles(): for perm_view in role.permissions: t = (perm_view.permission.name, perm_view.view_menu.name) perms.add(t...
def get_all_permissions(self): """Returns a set of tuples with the perm name and view menu name""" perms = set() for role in self.get_user_roles(): for perm_view in role.permissions: t = (perm_view.permission.name, perm_view.view_menu.name) perms.add(t...
[ "Returns", "a", "set", "of", "tuples", "with", "the", "perm", "name", "and", "view", "menu", "name" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L286-L293
[ "def", "get_all_permissions", "(", "self", ")", ":", "perms", "=", "set", "(", ")", "for", "role", "in", "self", ".", "get_user_roles", "(", ")", ":", "for", "perm_view", "in", "role", ".", "permissions", ":", "t", "=", "(", "perm_view", ".", "permissi...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetFilter.get_view_menus
Returns the details of view_menus for a perm name
superset/views/base.py
def get_view_menus(self, permission_name): """Returns the details of view_menus for a perm name""" vm = set() for perm_name, vm_name in self.get_all_permissions(): if perm_name == permission_name: vm.add(vm_name) return vm
def get_view_menus(self, permission_name): """Returns the details of view_menus for a perm name""" vm = set() for perm_name, vm_name in self.get_all_permissions(): if perm_name == permission_name: vm.add(vm_name) return vm
[ "Returns", "the", "details", "of", "view_menus", "for", "a", "perm", "name" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/base.py#L306-L312
[ "def", "get_view_menus", "(", "self", ",", "permission_name", ")", ":", "vm", "=", "set", "(", ")", "for", "perm_name", ",", "vm_name", "in", "self", ".", "get_all_permissions", "(", ")", ":", "if", "perm_name", "==", "permission_name", ":", "vm", ".", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
destroy_webdriver
Destroy a driver
superset/tasks/schedules.py
def destroy_webdriver(driver): """ Destroy a driver """ # This is some very flaky code in selenium. Hence the retries # and catch-all exceptions try: retry_call(driver.close, tries=2) except Exception: pass try: driver.quit() except Exception: pass
def destroy_webdriver(driver): """ Destroy a driver """ # This is some very flaky code in selenium. Hence the retries # and catch-all exceptions try: retry_call(driver.close, tries=2) except Exception: pass try: driver.quit() except Exception: pass
[ "Destroy", "a", "driver" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/schedules.py#L190-L204
[ "def", "destroy_webdriver", "(", "driver", ")", ":", "# This is some very flaky code in selenium. Hence the retries", "# and catch-all exceptions", "try", ":", "retry_call", "(", "driver", ".", "close", ",", "tries", "=", "2", ")", "except", "Exception", ":", "pass", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
deliver_dashboard
Given a schedule, delivery the dashboard as an email report
superset/tasks/schedules.py
def deliver_dashboard(schedule): """ Given a schedule, delivery the dashboard as an email report """ dashboard = schedule.dashboard dashboard_url = _get_url_path( 'Superset.dashboard', dashboard_id=dashboard.id, ) # Create a driver, fetch the page, wait for the page to rend...
def deliver_dashboard(schedule): """ Given a schedule, delivery the dashboard as an email report """ dashboard = schedule.dashboard dashboard_url = _get_url_path( 'Superset.dashboard', dashboard_id=dashboard.id, ) # Create a driver, fetch the page, wait for the page to rend...
[ "Given", "a", "schedule", "delivery", "the", "dashboard", "as", "an", "email", "report" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/schedules.py#L207-L258
[ "def", "deliver_dashboard", "(", "schedule", ")", ":", "dashboard", "=", "schedule", ".", "dashboard", "dashboard_url", "=", "_get_url_path", "(", "'Superset.dashboard'", ",", "dashboard_id", "=", "dashboard", ".", "id", ",", ")", "# Create a driver, fetch the page, w...
ca2996c78f679260eb79c6008e276733df5fb653
train
deliver_slice
Given a schedule, delivery the slice as an email report
superset/tasks/schedules.py
def deliver_slice(schedule): """ Given a schedule, delivery the slice as an email report """ if schedule.email_format == SliceEmailReportFormat.data: email = _get_slice_data(schedule) elif schedule.email_format == SliceEmailReportFormat.visualization: email = _get_slice_visualization...
def deliver_slice(schedule): """ Given a schedule, delivery the slice as an email report """ if schedule.email_format == SliceEmailReportFormat.data: email = _get_slice_data(schedule) elif schedule.email_format == SliceEmailReportFormat.visualization: email = _get_slice_visualization...
[ "Given", "a", "schedule", "delivery", "the", "slice", "as", "an", "email", "report" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/schedules.py#L356-L373
[ "def", "deliver_slice", "(", "schedule", ")", ":", "if", "schedule", ".", "email_format", "==", "SliceEmailReportFormat", ".", "data", ":", "email", "=", "_get_slice_data", "(", "schedule", ")", "elif", "schedule", ".", "email_format", "==", "SliceEmailReportForma...
ca2996c78f679260eb79c6008e276733df5fb653
train
schedule_window
Find all active schedules and schedule celery tasks for each of them with a specific ETA (determined by parsing the cron schedule for the schedule)
superset/tasks/schedules.py
def schedule_window(report_type, start_at, stop_at, resolution): """ Find all active schedules and schedule celery tasks for each of them with a specific ETA (determined by parsing the cron schedule for the schedule) """ model_cls = get_scheduler_model(report_type) dbsession = db.create_scop...
def schedule_window(report_type, start_at, stop_at, resolution): """ Find all active schedules and schedule celery tasks for each of them with a specific ETA (determined by parsing the cron schedule for the schedule) """ model_cls = get_scheduler_model(report_type) dbsession = db.create_scop...
[ "Find", "all", "active", "schedules", "and", "schedule", "celery", "tasks", "for", "each", "of", "them", "with", "a", "specific", "ETA", "(", "determined", "by", "parsing", "the", "cron", "schedule", "for", "the", "schedule", ")" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/schedules.py#L419-L440
[ "def", "schedule_window", "(", "report_type", ",", "start_at", ",", "stop_at", ",", "resolution", ")", ":", "model_cls", "=", "get_scheduler_model", "(", "report_type", ")", "dbsession", "=", "db", ".", "create_scoped_session", "(", ")", "schedules", "=", "dbses...
ca2996c78f679260eb79c6008e276733df5fb653
train
schedule_hourly
Celery beat job meant to be invoked hourly
superset/tasks/schedules.py
def schedule_hourly(): """ Celery beat job meant to be invoked hourly """ if not config.get('ENABLE_SCHEDULED_EMAIL_REPORTS'): logging.info('Scheduled email reports not enabled in config') return resolution = config.get('EMAIL_REPORTS_CRON_RESOLUTION', 0) * 60 # Get the top of the hou...
def schedule_hourly(): """ Celery beat job meant to be invoked hourly """ if not config.get('ENABLE_SCHEDULED_EMAIL_REPORTS'): logging.info('Scheduled email reports not enabled in config') return resolution = config.get('EMAIL_REPORTS_CRON_RESOLUTION', 0) * 60 # Get the top of the hou...
[ "Celery", "beat", "job", "meant", "to", "be", "invoked", "hourly" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/schedules.py#L444-L457
[ "def", "schedule_hourly", "(", ")", ":", "if", "not", "config", ".", "get", "(", "'ENABLE_SCHEDULED_EMAIL_REPORTS'", ")", ":", "logging", ".", "info", "(", "'Scheduled email reports not enabled in config'", ")", "return", "resolution", "=", "config", ".", "get", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
dedup
De-duplicates a list of string by suffixing a counter Always returns the same number of entries as provided, and always returns unique values. Case sensitive comparison by default. >>> print(','.join(dedup(['foo', 'bar', 'bar', 'bar', 'Bar']))) foo,bar,bar__1,bar__2,Bar >>> print(','.join(dedup(['...
superset/dataframe.py
def dedup(l, suffix='__', case_sensitive=True): """De-duplicates a list of string by suffixing a counter Always returns the same number of entries as provided, and always returns unique values. Case sensitive comparison by default. >>> print(','.join(dedup(['foo', 'bar', 'bar', 'bar', 'Bar']))) fo...
def dedup(l, suffix='__', case_sensitive=True): """De-duplicates a list of string by suffixing a counter Always returns the same number of entries as provided, and always returns unique values. Case sensitive comparison by default. >>> print(','.join(dedup(['foo', 'bar', 'bar', 'bar', 'Bar']))) fo...
[ "De", "-", "duplicates", "a", "list", "of", "string", "by", "suffixing", "a", "counter" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/dataframe.py#L39-L60
[ "def", "dedup", "(", "l", ",", "suffix", "=", "'__'", ",", "case_sensitive", "=", "True", ")", ":", "new_l", "=", "[", "]", "seen", "=", "{", "}", "for", "s", "in", "l", ":", "s_fixed_case", "=", "s", "if", "case_sensitive", "else", "s", ".", "lo...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetDataFrame.db_type
Given a numpy dtype, Returns a generic database type
superset/dataframe.py
def db_type(cls, dtype): """Given a numpy dtype, Returns a generic database type""" if isinstance(dtype, ExtensionDtype): return cls.type_map.get(dtype.kind) elif hasattr(dtype, 'char'): return cls.type_map.get(dtype.char)
def db_type(cls, dtype): """Given a numpy dtype, Returns a generic database type""" if isinstance(dtype, ExtensionDtype): return cls.type_map.get(dtype.kind) elif hasattr(dtype, 'char'): return cls.type_map.get(dtype.char)
[ "Given", "a", "numpy", "dtype", "Returns", "a", "generic", "database", "type" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/dataframe.py#L122-L127
[ "def", "db_type", "(", "cls", ",", "dtype", ")", ":", "if", "isinstance", "(", "dtype", ",", "ExtensionDtype", ")", ":", "return", "cls", ".", "type_map", ".", "get", "(", "dtype", ".", "kind", ")", "elif", "hasattr", "(", "dtype", ",", "'char'", ")"...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetDataFrame.columns
Provides metadata about columns for data visualization. :return: dict, with the fields name, type, is_date, is_dim and agg.
superset/dataframe.py
def columns(self): """Provides metadata about columns for data visualization. :return: dict, with the fields name, type, is_date, is_dim and agg. """ if self.df.empty: return None columns = [] sample_size = min(INFER_COL_TYPES_SAMPLE_SIZE, len(self.df.index)...
def columns(self): """Provides metadata about columns for data visualization. :return: dict, with the fields name, type, is_date, is_dim and agg. """ if self.df.empty: return None columns = [] sample_size = min(INFER_COL_TYPES_SAMPLE_SIZE, len(self.df.index)...
[ "Provides", "metadata", "about", "columns", "for", "data", "visualization", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/dataframe.py#L177-L229
[ "def", "columns", "(", "self", ")", ":", "if", "self", ".", "df", ".", "empty", ":", "return", "None", "columns", "=", "[", "]", "sample_size", "=", "min", "(", "INFER_COL_TYPES_SAMPLE_SIZE", ",", "len", "(", "self", ".", "df", ".", "index", ")", ")"...
ca2996c78f679260eb79c6008e276733df5fb653
train
TableColumn.get_timestamp_expression
Getting the time component of the query
superset/connectors/sqla/models.py
def get_timestamp_expression(self, time_grain): """Getting the time component of the query""" label = utils.DTTM_ALIAS db = self.table.database pdf = self.python_date_format is_epoch = pdf in ('epoch_s', 'epoch_ms') if not self.expression and not time_grain and not is_ep...
def get_timestamp_expression(self, time_grain): """Getting the time component of the query""" label = utils.DTTM_ALIAS db = self.table.database pdf = self.python_date_format is_epoch = pdf in ('epoch_s', 'epoch_ms') if not self.expression and not time_grain and not is_ep...
[ "Getting", "the", "time", "component", "of", "the", "query" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L143-L162
[ "def", "get_timestamp_expression", "(", "self", ",", "time_grain", ")", ":", "label", "=", "utils", ".", "DTTM_ALIAS", "db", "=", "self", ".", "table", ".", "database", "pdf", "=", "self", ".", "python_date_format", "is_epoch", "=", "pdf", "in", "(", "'epo...
ca2996c78f679260eb79c6008e276733df5fb653
train
TableColumn.dttm_sql_literal
Convert datetime object to a SQL expression string If database_expression is empty, the internal dttm will be parsed as the string with the pattern that the user inputted (python_date_format) If database_expression is not empty, the internal dttm will be parsed as the sql senten...
superset/connectors/sqla/models.py
def dttm_sql_literal(self, dttm, is_epoch_in_utc): """Convert datetime object to a SQL expression string If database_expression is empty, the internal dttm will be parsed as the string with the pattern that the user inputted (python_date_format) If database_expression is not emp...
def dttm_sql_literal(self, dttm, is_epoch_in_utc): """Convert datetime object to a SQL expression string If database_expression is empty, the internal dttm will be parsed as the string with the pattern that the user inputted (python_date_format) If database_expression is not emp...
[ "Convert", "datetime", "object", "to", "a", "SQL", "expression", "string" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L172-L198
[ "def", "dttm_sql_literal", "(", "self", ",", "dttm", ",", "is_epoch_in_utc", ")", ":", "tf", "=", "self", ".", "python_date_format", "if", "self", ".", "database_expression", ":", "return", "self", ".", "database_expression", ".", "format", "(", "dttm", ".", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.make_sqla_column_compatible
Takes a sql alchemy column object and adds label info if supported by engine. :param sqla_col: sql alchemy column instance :param label: alias/label that column is expected to have :return: either a sql alchemy column or label instance if supported by engine
superset/connectors/sqla/models.py
def make_sqla_column_compatible(self, sqla_col, label=None): """Takes a sql alchemy column object and adds label info if supported by engine. :param sqla_col: sql alchemy column instance :param label: alias/label that column is expected to have :return: either a sql alchemy column or lab...
def make_sqla_column_compatible(self, sqla_col, label=None): """Takes a sql alchemy column object and adds label info if supported by engine. :param sqla_col: sql alchemy column instance :param label: alias/label that column is expected to have :return: either a sql alchemy column or lab...
[ "Takes", "a", "sql", "alchemy", "column", "object", "and", "adds", "label", "info", "if", "supported", "by", "engine", ".", ":", "param", "sqla_col", ":", "sql", "alchemy", "column", "instance", ":", "param", "label", ":", "alias", "/", "label", "that", ...
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L302-L314
[ "def", "make_sqla_column_compatible", "(", "self", ",", "sqla_col", ",", "label", "=", "None", ")", ":", "label_expected", "=", "label", "or", "sqla_col", ".", "name", "db_engine_spec", "=", "self", ".", "database", ".", "db_engine_spec", "if", "db_engine_spec",...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.values_for_column
Runs query against sqla to retrieve some sample values for the given column.
superset/connectors/sqla/models.py
def values_for_column(self, column_name, limit=10000): """Runs query against sqla to retrieve some sample values for the given column. """ cols = {col.column_name: col for col in self.columns} target_col = cols[column_name] tp = self.get_template_processor() qry ...
def values_for_column(self, column_name, limit=10000): """Runs query against sqla to retrieve some sample values for the given column. """ cols = {col.column_name: col for col in self.columns} target_col = cols[column_name] tp = self.get_template_processor() qry ...
[ "Runs", "query", "against", "sqla", "to", "retrieve", "some", "sample", "values", "for", "the", "given", "column", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L437-L464
[ "def", "values_for_column", "(", "self", ",", "column_name", ",", "limit", "=", "10000", ")", ":", "cols", "=", "{", "col", ".", "column_name", ":", "col", "for", "col", "in", "self", ".", "columns", "}", "target_col", "=", "cols", "[", "column_name", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.mutate_query_from_config
Apply config's SQL_QUERY_MUTATOR Typically adds comments to the query with context
superset/connectors/sqla/models.py
def mutate_query_from_config(self, sql): """Apply config's SQL_QUERY_MUTATOR Typically adds comments to the query with context""" SQL_QUERY_MUTATOR = config.get('SQL_QUERY_MUTATOR') if SQL_QUERY_MUTATOR: username = utils.get_username() sql = SQL_QUERY_MUTATOR(sql...
def mutate_query_from_config(self, sql): """Apply config's SQL_QUERY_MUTATOR Typically adds comments to the query with context""" SQL_QUERY_MUTATOR = config.get('SQL_QUERY_MUTATOR') if SQL_QUERY_MUTATOR: username = utils.get_username() sql = SQL_QUERY_MUTATOR(sql...
[ "Apply", "config", "s", "SQL_QUERY_MUTATOR" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L466-L474
[ "def", "mutate_query_from_config", "(", "self", ",", "sql", ")", ":", "SQL_QUERY_MUTATOR", "=", "config", ".", "get", "(", "'SQL_QUERY_MUTATOR'", ")", "if", "SQL_QUERY_MUTATOR", ":", "username", "=", "utils", ".", "get_username", "(", ")", "sql", "=", "SQL_QUE...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.adhoc_metric_to_sqla
Turn an adhoc metric into a sqlalchemy column. :param dict metric: Adhoc metric definition :param dict cols: Columns for the current table :returns: The metric defined as a sqlalchemy column :rtype: sqlalchemy.sql.column
superset/connectors/sqla/models.py
def adhoc_metric_to_sqla(self, metric, cols): """ Turn an adhoc metric into a sqlalchemy column. :param dict metric: Adhoc metric definition :param dict cols: Columns for the current table :returns: The metric defined as a sqlalchemy column :rtype: sqlalchemy.sql.column ...
def adhoc_metric_to_sqla(self, metric, cols): """ Turn an adhoc metric into a sqlalchemy column. :param dict metric: Adhoc metric definition :param dict cols: Columns for the current table :returns: The metric defined as a sqlalchemy column :rtype: sqlalchemy.sql.column ...
[ "Turn", "an", "adhoc", "metric", "into", "a", "sqlalchemy", "column", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L509-L534
[ "def", "adhoc_metric_to_sqla", "(", "self", ",", "metric", ",", "cols", ")", ":", "expression_type", "=", "metric", ".", "get", "(", "'expressionType'", ")", "label", "=", "utils", ".", "get_metric_name", "(", "metric", ")", "if", "expression_type", "==", "u...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.get_sqla_query
Querying any sqla table from this common interface
superset/connectors/sqla/models.py
def get_sqla_query( # sqla self, groupby, metrics, granularity, from_dttm, to_dttm, filter=None, # noqa is_timeseries=True, timeseries_limit=15, timeseries_limit_metric=None, row_limit=None, inner_f...
def get_sqla_query( # sqla self, groupby, metrics, granularity, from_dttm, to_dttm, filter=None, # noqa is_timeseries=True, timeseries_limit=15, timeseries_limit_metric=None, row_limit=None, inner_f...
[ "Querying", "any", "sqla", "table", "from", "this", "common", "interface" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L536-L808
[ "def", "get_sqla_query", "(", "# sqla", "self", ",", "groupby", ",", "metrics", ",", "granularity", ",", "from_dttm", ",", "to_dttm", ",", "filter", "=", "None", ",", "# noqa", "is_timeseries", "=", "True", ",", "timeseries_limit", "=", "15", ",", "timeserie...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.fetch_metadata
Fetches the metadata for the table and merges it in
superset/connectors/sqla/models.py
def fetch_metadata(self): """Fetches the metadata for the table and merges it in""" try: table = self.get_sqla_table_object() except Exception as e: logging.exception(e) raise Exception(_( "Table [{}] doesn't seem to exist in the specified data...
def fetch_metadata(self): """Fetches the metadata for the table and merges it in""" try: table = self.get_sqla_table_object() except Exception as e: logging.exception(e) raise Exception(_( "Table [{}] doesn't seem to exist in the specified data...
[ "Fetches", "the", "metadata", "for", "the", "table", "and", "merges", "it", "in" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L875-L930
[ "def", "fetch_metadata", "(", "self", ")", ":", "try", ":", "table", "=", "self", ".", "get_sqla_table_object", "(", ")", "except", "Exception", "as", "e", ":", "logging", ".", "exception", "(", "e", ")", "raise", "Exception", "(", "_", "(", "\"Table [{}...
ca2996c78f679260eb79c6008e276733df5fb653
train
SqlaTable.import_obj
Imports the datasource from the object to the database. Metrics and columns and datasource will be overrided if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata isn't copies over.
superset/connectors/sqla/models.py
def import_obj(cls, i_datasource, import_time=None): """Imports the datasource from the object to the database. Metrics and columns and datasource will be overrided if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata is...
def import_obj(cls, i_datasource, import_time=None): """Imports the datasource from the object to the database. Metrics and columns and datasource will be overrided if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata is...
[ "Imports", "the", "datasource", "from", "the", "object", "to", "the", "database", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/models.py#L933-L952
[ "def", "import_obj", "(", "cls", ",", "i_datasource", ",", "import_time", "=", "None", ")", ":", "def", "lookup_sqlatable", "(", "table", ")", ":", "return", "db", ".", "session", ".", "query", "(", "SqlaTable", ")", ".", "join", "(", "Database", ")", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
load_long_lat_data
Loading lat/long data from a csv file in the repo
superset/data/long_lat.py
def load_long_lat_data(): """Loading lat/long data from a csv file in the repo""" data = get_example_data('san_francisco.csv.gz', make_bytes=True) pdf = pd.read_csv(data, encoding='utf-8') start = datetime.datetime.now().replace( hour=0, minute=0, second=0, microsecond=0) pdf['datetime'] = [...
def load_long_lat_data(): """Loading lat/long data from a csv file in the repo""" data = get_example_data('san_francisco.csv.gz', make_bytes=True) pdf = pd.read_csv(data, encoding='utf-8') start = datetime.datetime.now().replace( hour=0, minute=0, second=0, microsecond=0) pdf['datetime'] = [...
[ "Loading", "lat", "/", "long", "data", "from", "a", "csv", "file", "in", "the", "repo" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/data/long_lat.py#L36-L110
[ "def", "load_long_lat_data", "(", ")", ":", "data", "=", "get_example_data", "(", "'san_francisco.csv.gz'", ",", "make_bytes", "=", "True", ")", "pdf", "=", "pd", ".", "read_csv", "(", "data", ",", "encoding", "=", "'utf-8'", ")", "start", "=", "datetime", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Datasource.external_metadata
Gets column info from the source system
superset/views/datasource.py
def external_metadata(self, datasource_type=None, datasource_id=None): """Gets column info from the source system""" if datasource_type == 'druid': datasource = ConnectorRegistry.get_datasource( datasource_type, datasource_id, db.session) elif datasource_type == 'tabl...
def external_metadata(self, datasource_type=None, datasource_id=None): """Gets column info from the source system""" if datasource_type == 'druid': datasource = ConnectorRegistry.get_datasource( datasource_type, datasource_id, db.session) elif datasource_type == 'tabl...
[ "Gets", "column", "info", "from", "the", "source", "system" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/datasource.py#L70-L89
[ "def", "external_metadata", "(", "self", ",", "datasource_type", "=", "None", ",", "datasource_id", "=", "None", ")", ":", "if", "datasource_type", "==", "'druid'", ":", "datasource", "=", "ConnectorRegistry", ".", "get_datasource", "(", "datasource_type", ",", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
filter_not_empty_values
Returns a list of non empty values or None
superset/forms.py
def filter_not_empty_values(value): """Returns a list of non empty values or None""" if not value: return None data = [x for x in value if x] if not data: return None return data
def filter_not_empty_values(value): """Returns a list of non empty values or None""" if not value: return None data = [x for x in value if x] if not data: return None return data
[ "Returns", "a", "list", "of", "non", "empty", "values", "or", "None" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/forms.py#L50-L57
[ "def", "filter_not_empty_values", "(", "value", ")", ":", "if", "not", "value", ":", "return", "None", "data", "=", "[", "x", "for", "x", "in", "value", "if", "x", "]", "if", "not", "data", ":", "return", "None", "return", "data" ]
ca2996c78f679260eb79c6008e276733df5fb653
train
CsvToDatabaseForm.at_least_one_schema_is_allowed
If the user has access to the database or all datasource 1. if schemas_allowed_for_csv_upload is empty a) if database does not support schema user is able to upload csv without specifying schema name b) if database supports schema user ...
superset/forms.py
def at_least_one_schema_is_allowed(database): """ If the user has access to the database or all datasource 1. if schemas_allowed_for_csv_upload is empty a) if database does not support schema user is able to upload csv without specifying schema name ...
def at_least_one_schema_is_allowed(database): """ If the user has access to the database or all datasource 1. if schemas_allowed_for_csv_upload is empty a) if database does not support schema user is able to upload csv without specifying schema name ...
[ "If", "the", "user", "has", "access", "to", "the", "database", "or", "all", "datasource", "1", ".", "if", "schemas_allowed_for_csv_upload", "is", "empty", "a", ")", "if", "database", "does", "not", "support", "schema", "user", "is", "able", "to", "upload", ...
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/forms.py#L73-L106
[ "def", "at_least_one_schema_is_allowed", "(", "database", ")", ":", "if", "(", "security_manager", ".", "database_access", "(", "database", ")", "or", "security_manager", ".", "all_datasource_access", "(", ")", ")", ":", "return", "True", "schemas", "=", "database...
ca2996c78f679260eb79c6008e276733df5fb653
train
QueryFilter.apply
Filter queries to only those owned by current user if can_only_access_owned_queries permission is set. :returns: query
superset/views/sql_lab.py
def apply( self, query: BaseQuery, func: Callable) -> BaseQuery: """ Filter queries to only those owned by current user if can_only_access_owned_queries permission is set. :returns: query """ if security_manager.can_only_access_owned_q...
def apply( self, query: BaseQuery, func: Callable) -> BaseQuery: """ Filter queries to only those owned by current user if can_only_access_owned_queries permission is set. :returns: query """ if security_manager.can_only_access_owned_q...
[ "Filter", "queries", "to", "only", "those", "owned", "by", "current", "user", "if", "can_only_access_owned_queries", "permission", "is", "set", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/sql_lab.py#L34-L49
[ "def", "apply", "(", "self", ",", "query", ":", "BaseQuery", ",", "func", ":", "Callable", ")", "->", "BaseQuery", ":", "if", "security_manager", ".", "can_only_access_owned_queries", "(", ")", ":", "query", "=", "(", "query", ".", "filter", "(", "Query", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
TableModelView.edit
Simple hack to redirect to explore view after saving
superset/connectors/sqla/views.py
def edit(self, pk): """Simple hack to redirect to explore view after saving""" resp = super(TableModelView, self).edit(pk) if isinstance(resp, str): return resp return redirect('/superset/explore/table/{}/'.format(pk))
def edit(self, pk): """Simple hack to redirect to explore view after saving""" resp = super(TableModelView, self).edit(pk) if isinstance(resp, str): return resp return redirect('/superset/explore/table/{}/'.format(pk))
[ "Simple", "hack", "to", "redirect", "to", "explore", "view", "after", "saving" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/sqla/views.py#L305-L310
[ "def", "edit", "(", "self", ",", "pk", ")", ":", "resp", "=", "super", "(", "TableModelView", ",", "self", ")", ".", "edit", "(", "pk", ")", "if", "isinstance", "(", "resp", ",", "str", ")", ":", "return", "resp", "return", "redirect", "(", "'/supe...
ca2996c78f679260eb79c6008e276733df5fb653
train
get_language_pack
Get/cache a language pack Returns the langugage pack from cache if it exists, caches otherwise >>> get_language_pack('fr')['Dashboards'] "Tableaux de bords"
superset/translations/utils.py
def get_language_pack(locale): """Get/cache a language pack Returns the langugage pack from cache if it exists, caches otherwise >>> get_language_pack('fr')['Dashboards'] "Tableaux de bords" """ pack = ALL_LANGUAGE_PACKS.get(locale) if not pack: filename = DIR + '/{}/LC_MESSAGES/me...
def get_language_pack(locale): """Get/cache a language pack Returns the langugage pack from cache if it exists, caches otherwise >>> get_language_pack('fr')['Dashboards'] "Tableaux de bords" """ pack = ALL_LANGUAGE_PACKS.get(locale) if not pack: filename = DIR + '/{}/LC_MESSAGES/me...
[ "Get", "/", "cache", "a", "language", "pack" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/translations/utils.py#L27-L45
[ "def", "get_language_pack", "(", "locale", ")", ":", "pack", "=", "ALL_LANGUAGE_PACKS", ".", "get", "(", "locale", ")", "if", "not", "pack", ":", "filename", "=", "DIR", "+", "'/{}/LC_MESSAGES/messages.json'", ".", "format", "(", "locale", ")", "try", ":", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
get_form_data
Build `form_data` for chart GET request from dashboard's `default_filters`. When a dashboard has `default_filters` they need to be added as extra filters in the GET request for charts.
superset/tasks/cache.py
def get_form_data(chart_id, dashboard=None): """ Build `form_data` for chart GET request from dashboard's `default_filters`. When a dashboard has `default_filters` they need to be added as extra filters in the GET request for charts. """ form_data = {'slice_id': chart_id} if dashboard is...
def get_form_data(chart_id, dashboard=None): """ Build `form_data` for chart GET request from dashboard's `default_filters`. When a dashboard has `default_filters` they need to be added as extra filters in the GET request for charts. """ form_data = {'slice_id': chart_id} if dashboard is...
[ "Build", "form_data", "for", "chart", "GET", "request", "from", "dashboard", "s", "default_filters", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/cache.py#L40-L75
[ "def", "get_form_data", "(", "chart_id", ",", "dashboard", "=", "None", ")", ":", "form_data", "=", "{", "'slice_id'", ":", "chart_id", "}", "if", "dashboard", "is", "None", "or", "not", "dashboard", ".", "json_metadata", ":", "return", "form_data", "json_me...
ca2996c78f679260eb79c6008e276733df5fb653
train
get_url
Return external URL for warming up a given chart/table cache.
superset/tasks/cache.py
def get_url(params): """Return external URL for warming up a given chart/table cache.""" baseurl = 'http://{SUPERSET_WEBSERVER_ADDRESS}:{SUPERSET_WEBSERVER_PORT}/'.format( **app.config) with app.test_request_context(): return urllib.parse.urljoin( baseurl, url_for('Su...
def get_url(params): """Return external URL for warming up a given chart/table cache.""" baseurl = 'http://{SUPERSET_WEBSERVER_ADDRESS}:{SUPERSET_WEBSERVER_PORT}/'.format( **app.config) with app.test_request_context(): return urllib.parse.urljoin( baseurl, url_for('Su...
[ "Return", "external", "URL", "for", "warming", "up", "a", "given", "chart", "/", "table", "cache", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/cache.py#L78-L86
[ "def", "get_url", "(", "params", ")", ":", "baseurl", "=", "'http://{SUPERSET_WEBSERVER_ADDRESS}:{SUPERSET_WEBSERVER_PORT}/'", ".", "format", "(", "*", "*", "app", ".", "config", ")", "with", "app", ".", "test_request_context", "(", ")", ":", "return", "urllib", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
cache_warmup
Warm up cache. This task periodically hits charts to warm up the cache.
superset/tasks/cache.py
def cache_warmup(strategy_name, *args, **kwargs): """ Warm up cache. This task periodically hits charts to warm up the cache. """ logger.info('Loading strategy') class_ = None for class_ in strategies: if class_.name == strategy_name: break else: message = f...
def cache_warmup(strategy_name, *args, **kwargs): """ Warm up cache. This task periodically hits charts to warm up the cache. """ logger.info('Loading strategy') class_ = None for class_ in strategies: if class_.name == strategy_name: break else: message = f...
[ "Warm", "up", "cache", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/cache.py#L280-L316
[ "def", "cache_warmup", "(", "strategy_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'Loading strategy'", ")", "class_", "=", "None", "for", "class_", "in", "strategies", ":", "if", "class_", ".", "name", "==", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
fetch_logs
Mocked. Retrieve the logs produced by the execution of the query. Can be called multiple times to fetch the logs produced after the previous call. :returns: list<str> :raises: ``ProgrammingError`` when no query has been started .. note:: This is not a part of DB-API.
superset/db_engines/hive.py
def fetch_logs(self, max_rows=1024, orientation=None): """Mocked. Retrieve the logs produced by the execution of the query. Can be called multiple times to fetch the logs produced after the previous call. :returns: list<str> :raises: ``ProgrammingError`` when no query has been started...
def fetch_logs(self, max_rows=1024, orientation=None): """Mocked. Retrieve the logs produced by the execution of the query. Can be called multiple times to fetch the logs produced after the previous call. :returns: list<str> :raises: ``ProgrammingError`` when no query has been started...
[ "Mocked", ".", "Retrieve", "the", "logs", "produced", "by", "the", "execution", "of", "the", "query", ".", "Can", "be", "called", "multiple", "times", "to", "fetch", "the", "logs", "produced", "after", "the", "previous", "call", ".", ":", "returns", ":", ...
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/db_engines/hive.py#L21-L61
[ "def", "fetch_logs", "(", "self", ",", "max_rows", "=", "1024", ",", "orientation", "=", "None", ")", ":", "from", "pyhive", "import", "hive", "from", "TCLIService", "import", "ttypes", "from", "thrift", "import", "Thrift", "orientation", "=", "orientation", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidCluster.refresh_datasources
Refresh metadata of all datasources in the cluster If ``datasource_name`` is specified, only that datasource is updated
superset/connectors/druid/models.py
def refresh_datasources( self, datasource_name=None, merge_flag=True, refreshAll=True): """Refresh metadata of all datasources in the cluster If ``datasource_name`` is specified, only that datasource is updated """ ds_list = self.get_dataso...
def refresh_datasources( self, datasource_name=None, merge_flag=True, refreshAll=True): """Refresh metadata of all datasources in the cluster If ``datasource_name`` is specified, only that datasource is updated """ ds_list = self.get_dataso...
[ "Refresh", "metadata", "of", "all", "datasources", "in", "the", "cluster", "If", "datasource_name", "is", "specified", "only", "that", "datasource", "is", "updated" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L165-L182
[ "def", "refresh_datasources", "(", "self", ",", "datasource_name", "=", "None", ",", "merge_flag", "=", "True", ",", "refreshAll", "=", "True", ")", ":", "ds_list", "=", "self", ".", "get_datasources", "(", ")", "blacklist", "=", "conf", ".", "get", "(", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidCluster.refresh
Fetches metadata for the specified datasources and merges to the Superset database
superset/connectors/druid/models.py
def refresh(self, datasource_names, merge_flag, refreshAll): """ Fetches metadata for the specified datasources and merges to the Superset database """ session = db.session ds_list = ( session.query(DruidDatasource) .filter(DruidDatasource.cluster_...
def refresh(self, datasource_names, merge_flag, refreshAll): """ Fetches metadata for the specified datasources and merges to the Superset database """ session = db.session ds_list = ( session.query(DruidDatasource) .filter(DruidDatasource.cluster_...
[ "Fetches", "metadata", "for", "the", "specified", "datasources", "and", "merges", "to", "the", "Superset", "database" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L184-L248
[ "def", "refresh", "(", "self", ",", "datasource_names", ",", "merge_flag", ",", "refreshAll", ")", ":", "session", "=", "db", ".", "session", "ds_list", "=", "(", "session", ".", "query", "(", "DruidDatasource", ")", ".", "filter", "(", "DruidDatasource", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidColumn.refresh_metrics
Refresh metrics based on the column metadata
superset/connectors/druid/models.py
def refresh_metrics(self): """Refresh metrics based on the column metadata""" metrics = self.get_metrics() dbmetrics = ( db.session.query(DruidMetric) .filter(DruidMetric.datasource_id == self.datasource_id) .filter(DruidMetric.metric_name.in_(metrics.keys()))...
def refresh_metrics(self): """Refresh metrics based on the column metadata""" metrics = self.get_metrics() dbmetrics = ( db.session.query(DruidMetric) .filter(DruidMetric.datasource_id == self.datasource_id) .filter(DruidMetric.metric_name.in_(metrics.keys()))...
[ "Refresh", "metrics", "based", "on", "the", "column", "metadata" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L309-L326
[ "def", "refresh_metrics", "(", "self", ")", ":", "metrics", "=", "self", ".", "get_metrics", "(", ")", "dbmetrics", "=", "(", "db", ".", "session", ".", "query", "(", "DruidMetric", ")", ".", "filter", "(", "DruidMetric", ".", "datasource_id", "==", "sel...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.import_obj
Imports the datasource from the object to the database. Metrics and columns and datasource will be overridden if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata isn't copies over.
superset/connectors/druid/models.py
def import_obj(cls, i_datasource, import_time=None): """Imports the datasource from the object to the database. Metrics and columns and datasource will be overridden if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata i...
def import_obj(cls, i_datasource, import_time=None): """Imports the datasource from the object to the database. Metrics and columns and datasource will be overridden if exists. This function can be used to import/export dashboards between multiple superset instances. Audit metadata i...
[ "Imports", "the", "datasource", "from", "the", "object", "to", "the", "database", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L514-L532
[ "def", "import_obj", "(", "cls", ",", "i_datasource", ",", "import_time", "=", "None", ")", ":", "def", "lookup_datasource", "(", "d", ")", ":", "return", "db", ".", "session", ".", "query", "(", "DruidDatasource", ")", ".", "filter", "(", "DruidDatasource...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.sync_to_db_from_config
Merges the ds config from druid_config into one stored in the db.
superset/connectors/druid/models.py
def sync_to_db_from_config( cls, druid_config, user, cluster, refresh=True): """Merges the ds config from druid_config into one stored in the db.""" session = db.session datasource = ( session.query(cls) .filter_...
def sync_to_db_from_config( cls, druid_config, user, cluster, refresh=True): """Merges the ds config from druid_config into one stored in the db.""" session = db.session datasource = ( session.query(cls) .filter_...
[ "Merges", "the", "ds", "config", "from", "druid_config", "into", "one", "stored", "in", "the", "db", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L590-L671
[ "def", "sync_to_db_from_config", "(", "cls", ",", "druid_config", ",", "user", ",", "cluster", ",", "refresh", "=", "True", ")", ":", "session", "=", "db", ".", "session", "datasource", "=", "(", "session", ".", "query", "(", "cls", ")", ".", "filter_by"...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.get_post_agg
For a metric specified as `postagg` returns the kind of post aggregation for pydruid.
superset/connectors/druid/models.py
def get_post_agg(mconf): """ For a metric specified as `postagg` returns the kind of post aggregation for pydruid. """ if mconf.get('type') == 'javascript': return JavascriptPostAggregator( name=mconf.get('name', ''), field_names=mconf....
def get_post_agg(mconf): """ For a metric specified as `postagg` returns the kind of post aggregation for pydruid. """ if mconf.get('type') == 'javascript': return JavascriptPostAggregator( name=mconf.get('name', ''), field_names=mconf....
[ "For", "a", "metric", "specified", "as", "postagg", "returns", "the", "kind", "of", "post", "aggregation", "for", "pydruid", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L731-L770
[ "def", "get_post_agg", "(", "mconf", ")", ":", "if", "mconf", ".", "get", "(", "'type'", ")", "==", "'javascript'", ":", "return", "JavascriptPostAggregator", "(", "name", "=", "mconf", ".", "get", "(", "'name'", ",", "''", ")", ",", "field_names", "=", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.find_postaggs_for
Return a list of metrics that are post aggregations
superset/connectors/druid/models.py
def find_postaggs_for(postagg_names, metrics_dict): """Return a list of metrics that are post aggregations""" postagg_metrics = [ metrics_dict[name] for name in postagg_names if metrics_dict[name].metric_type == POST_AGG_TYPE ] # Remove post aggregations that were...
def find_postaggs_for(postagg_names, metrics_dict): """Return a list of metrics that are post aggregations""" postagg_metrics = [ metrics_dict[name] for name in postagg_names if metrics_dict[name].metric_type == POST_AGG_TYPE ] # Remove post aggregations that were...
[ "Return", "a", "list", "of", "metrics", "that", "are", "post", "aggregations" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L773-L782
[ "def", "find_postaggs_for", "(", "postagg_names", ",", "metrics_dict", ")", ":", "postagg_metrics", "=", "[", "metrics_dict", "[", "name", "]", "for", "name", "in", "postagg_names", "if", "metrics_dict", "[", "name", "]", ".", "metric_type", "==", "POST_AGG_TYPE...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.values_for_column
Retrieve some values for the given column
superset/connectors/druid/models.py
def values_for_column(self, column_name, limit=10000): """Retrieve some values for the given column""" logging.info( 'Getting values for columns [{}] limited to [{}]' .format(column_name, limit)) # TODO: Use Lexicographi...
def values_for_column(self, column_name, limit=10000): """Retrieve some values for the given column""" logging.info( 'Getting values for columns [{}] limited to [{}]' .format(column_name, limit)) # TODO: Use Lexicographi...
[ "Retrieve", "some", "values", "for", "the", "given", "column" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L857-L883
[ "def", "values_for_column", "(", "self", ",", "column_name", ",", "limit", "=", "10000", ")", ":", "logging", ".", "info", "(", "'Getting values for columns [{}] limited to [{}]'", ".", "format", "(", "column_name", ",", "limit", ")", ")", "# TODO: Use Lexicographic...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.get_aggregations
Returns a dictionary of aggregation metric names to aggregation json objects :param metrics_dict: dictionary of all the metrics :param saved_metrics: list of saved metric names :param adhoc_metrics: list of adhoc metric names :raise SupersetException: if one or more metr...
superset/connectors/druid/models.py
def get_aggregations(metrics_dict, saved_metrics, adhoc_metrics=[]): """ Returns a dictionary of aggregation metric names to aggregation json objects :param metrics_dict: dictionary of all the metrics :param saved_metrics: list of saved metric names :param adhoc_...
def get_aggregations(metrics_dict, saved_metrics, adhoc_metrics=[]): """ Returns a dictionary of aggregation metric names to aggregation json objects :param metrics_dict: dictionary of all the metrics :param saved_metrics: list of saved metric names :param adhoc_...
[ "Returns", "a", "dictionary", "of", "aggregation", "metric", "names", "to", "aggregation", "json", "objects" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L940-L970
[ "def", "get_aggregations", "(", "metrics_dict", ",", "saved_metrics", ",", "adhoc_metrics", "=", "[", "]", ")", ":", "aggregations", "=", "OrderedDict", "(", ")", "invalid_metric_names", "=", "[", "]", "for", "metric_name", "in", "saved_metrics", ":", "if", "m...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource._dimensions_to_values
Replace dimensions specs with their `dimension` values, and ignore those without
superset/connectors/druid/models.py
def _dimensions_to_values(dimensions): """ Replace dimensions specs with their `dimension` values, and ignore those without """ values = [] for dimension in dimensions: if isinstance(dimension, dict): if 'extractionFn' in dimension: ...
def _dimensions_to_values(dimensions): """ Replace dimensions specs with their `dimension` values, and ignore those without """ values = [] for dimension in dimensions: if isinstance(dimension, dict): if 'extractionFn' in dimension: ...
[ "Replace", "dimensions", "specs", "with", "their", "dimension", "values", "and", "ignore", "those", "without" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L1010-L1025
[ "def", "_dimensions_to_values", "(", "dimensions", ")", ":", "values", "=", "[", "]", "for", "dimension", "in", "dimensions", ":", "if", "isinstance", "(", "dimension", ",", "dict", ")", ":", "if", "'extractionFn'", "in", "dimension", ":", "values", ".", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.run_query
Runs a query against Druid and returns a dataframe.
superset/connectors/druid/models.py
def run_query( # noqa / druid self, groupby, metrics, granularity, from_dttm, to_dttm, filter=None, # noqa is_timeseries=True, timeseries_limit=None, timeseries_limit_metric=None, row_limit=None, in...
def run_query( # noqa / druid self, groupby, metrics, granularity, from_dttm, to_dttm, filter=None, # noqa is_timeseries=True, timeseries_limit=None, timeseries_limit_metric=None, row_limit=None, in...
[ "Runs", "a", "query", "against", "Druid", "and", "returns", "a", "dataframe", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L1039-L1268
[ "def", "run_query", "(", "# noqa / druid", "self", ",", "groupby", ",", "metrics", ",", "granularity", ",", "from_dttm", ",", "to_dttm", ",", "filter", "=", "None", ",", "# noqa", "is_timeseries", "=", "True", ",", "timeseries_limit", "=", "None", ",", "time...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.homogenize_types
Converting all GROUPBY columns to strings When grouping by a numeric (say FLOAT) column, pydruid returns strings in the dataframe. This creates issues downstream related to having mixed types in the dataframe Here we replace None with <NULL> and make the whole series a str inst...
superset/connectors/druid/models.py
def homogenize_types(df, groupby_cols): """Converting all GROUPBY columns to strings When grouping by a numeric (say FLOAT) column, pydruid returns strings in the dataframe. This creates issues downstream related to having mixed types in the dataframe Here we replace None with ...
def homogenize_types(df, groupby_cols): """Converting all GROUPBY columns to strings When grouping by a numeric (say FLOAT) column, pydruid returns strings in the dataframe. This creates issues downstream related to having mixed types in the dataframe Here we replace None with ...
[ "Converting", "all", "GROUPBY", "columns", "to", "strings" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L1271-L1283
[ "def", "homogenize_types", "(", "df", ",", "groupby_cols", ")", ":", "for", "col", "in", "groupby_cols", ":", "df", "[", "col", "]", "=", "df", "[", "col", "]", ".", "fillna", "(", "'<NULL>'", ")", ".", "astype", "(", "'unicode'", ")", "return", "df"...
ca2996c78f679260eb79c6008e276733df5fb653
train
DruidDatasource.get_filters
Given Superset filter data structure, returns pydruid Filter(s)
superset/connectors/druid/models.py
def get_filters(cls, raw_filters, num_cols, columns_dict): # noqa """Given Superset filter data structure, returns pydruid Filter(s)""" filters = None for flt in raw_filters: col = flt.get('col') op = flt.get('op') eq = flt.get('val') if ( ...
def get_filters(cls, raw_filters, num_cols, columns_dict): # noqa """Given Superset filter data structure, returns pydruid Filter(s)""" filters = None for flt in raw_filters: col = flt.get('col') op = flt.get('op') eq = flt.get('val') if ( ...
[ "Given", "Superset", "filter", "data", "structure", "returns", "pydruid", "Filter", "(", "s", ")" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/druid/models.py#L1361-L1484
[ "def", "get_filters", "(", "cls", ",", "raw_filters", ",", "num_cols", ",", "columns_dict", ")", ":", "# noqa", "filters", "=", "None", "for", "flt", "in", "raw_filters", ":", "col", "=", "flt", ".", "get", "(", "'col'", ")", "op", "=", "flt", ".", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
get_env_variable
Get the environment variable or raise exception.
contrib/docker/superset_config.py
def get_env_variable(var_name, default=None): """Get the environment variable or raise exception.""" try: return os.environ[var_name] except KeyError: if default is not None: return default else: error_msg = 'The environment variable {} was missing, abort...'\...
def get_env_variable(var_name, default=None): """Get the environment variable or raise exception.""" try: return os.environ[var_name] except KeyError: if default is not None: return default else: error_msg = 'The environment variable {} was missing, abort...'\...
[ "Get", "the", "environment", "variable", "or", "raise", "exception", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/contrib/docker/superset_config.py#L20-L30
[ "def", "get_env_variable", "(", "var_name", ",", "default", "=", "None", ")", ":", "try", ":", "return", "os", ".", "environ", "[", "var_name", "]", "except", "KeyError", ":", "if", "default", "is", "not", "None", ":", "return", "default", "else", ":", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
ConnectorRegistry.get_eager_datasource
Returns datasource with columns and metrics.
superset/connectors/connector_registry.py
def get_eager_datasource(cls, session, datasource_type, datasource_id): """Returns datasource with columns and metrics.""" datasource_class = ConnectorRegistry.sources[datasource_type] return ( session.query(datasource_class) .options( subqueryload(datasou...
def get_eager_datasource(cls, session, datasource_type, datasource_id): """Returns datasource with columns and metrics.""" datasource_class = ConnectorRegistry.sources[datasource_type] return ( session.query(datasource_class) .options( subqueryload(datasou...
[ "Returns", "datasource", "with", "columns", "and", "metrics", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/connectors/connector_registry.py#L76-L87
[ "def", "get_eager_datasource", "(", "cls", ",", "session", ",", "datasource_type", ",", "datasource_id", ")", ":", "datasource_class", "=", "ConnectorRegistry", ".", "sources", "[", "datasource_type", "]", "return", "(", "session", ".", "query", "(", "datasource_c...
ca2996c78f679260eb79c6008e276733df5fb653
train
load_misc_dashboard
Loading a dashboard featuring misc charts
superset/data/misc_dashboard.py
def load_misc_dashboard(): """Loading a dashboard featuring misc charts""" print('Creating the dashboard') db.session.expunge_all() dash = db.session.query(Dash).filter_by(slug=DASH_SLUG).first() if not dash: dash = Dash() js = textwrap.dedent("""\ { "CHART-BkeVbh8ANQ": { "...
def load_misc_dashboard(): """Loading a dashboard featuring misc charts""" print('Creating the dashboard') db.session.expunge_all() dash = db.session.query(Dash).filter_by(slug=DASH_SLUG).first() if not dash: dash = Dash() js = textwrap.dedent("""\ { "CHART-BkeVbh8ANQ": { "...
[ "Loading", "a", "dashboard", "featuring", "misc", "charts" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/data/misc_dashboard.py#L32-L228
[ "def", "load_misc_dashboard", "(", ")", ":", "print", "(", "'Creating the dashboard'", ")", "db", ".", "session", ".", "expunge_all", "(", ")", "dash", "=", "db", ".", "session", ".", "query", "(", "Dash", ")", ".", "filter_by", "(", "slug", "=", "DASH_S...
ca2996c78f679260eb79c6008e276733df5fb653
train
load_world_bank_health_n_pop
Loads the world bank health dataset, slices and a dashboard
superset/data/world_bank.py
def load_world_bank_health_n_pop(): """Loads the world bank health dataset, slices and a dashboard""" tbl_name = 'wb_health_population' data = get_example_data('countries.json.gz') pdf = pd.read_json(data) pdf.columns = [col.replace('.', '_') for col in pdf.columns] pdf.year = pd.to_datetime(pdf...
def load_world_bank_health_n_pop(): """Loads the world bank health dataset, slices and a dashboard""" tbl_name = 'wb_health_population' data = get_example_data('countries.json.gz') pdf = pd.read_json(data) pdf.columns = [col.replace('.', '_') for col in pdf.columns] pdf.year = pd.to_datetime(pdf...
[ "Loads", "the", "world", "bank", "health", "dataset", "slices", "and", "a", "dashboard" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/data/world_bank.py#L43-L507
[ "def", "load_world_bank_health_n_pop", "(", ")", ":", "tbl_name", "=", "'wb_health_population'", "data", "=", "get_example_data", "(", "'countries.json.gz'", ")", "pdf", "=", "pd", ".", "read_json", "(", "data", ")", "pdf", ".", "columns", "=", "[", "col", "."...
ca2996c78f679260eb79c6008e276733df5fb653
train
load_country_map_data
Loading data for map with country map
superset/data/country_map.py
def load_country_map_data(): """Loading data for map with country map""" csv_bytes = get_example_data( 'birth_france_data_for_country_map.csv', is_gzip=False, make_bytes=True) data = pd.read_csv(csv_bytes, encoding='utf-8') data['dttm'] = datetime.datetime.now().date() data.to_sql( # pylint...
def load_country_map_data(): """Loading data for map with country map""" csv_bytes = get_example_data( 'birth_france_data_for_country_map.csv', is_gzip=False, make_bytes=True) data = pd.read_csv(csv_bytes, encoding='utf-8') data['dttm'] = datetime.datetime.now().date() data.to_sql( # pylint...
[ "Loading", "data", "for", "map", "with", "country", "map" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/data/country_map.py#L35-L110
[ "def", "load_country_map_data", "(", ")", ":", "csv_bytes", "=", "get_example_data", "(", "'birth_france_data_for_country_map.csv'", ",", "is_gzip", "=", "False", ",", "make_bytes", "=", "True", ")", "data", "=", "pd", ".", "read_csv", "(", "csv_bytes", ",", "en...
ca2996c78f679260eb79c6008e276733df5fb653
train
ParsedQuery.get_statements
Returns a list of SQL statements as strings, stripped
superset/sql_parse.py
def get_statements(self): """Returns a list of SQL statements as strings, stripped""" statements = [] for statement in self._parsed: if statement: sql = str(statement).strip(' \n;\t') if sql: statements.append(sql) return st...
def get_statements(self): """Returns a list of SQL statements as strings, stripped""" statements = [] for statement in self._parsed: if statement: sql = str(statement).strip(' \n;\t') if sql: statements.append(sql) return st...
[ "Returns", "a", "list", "of", "SQL", "statements", "as", "strings", "stripped" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/sql_parse.py#L67-L75
[ "def", "get_statements", "(", "self", ")", ":", "statements", "=", "[", "]", "for", "statement", "in", "self", ".", "_parsed", ":", "if", "statement", ":", "sql", "=", "str", "(", "statement", ")", ".", "strip", "(", "' \\n;\\t'", ")", "if", "sql", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
ParsedQuery.as_create_table
Reformats the query into the create table as query. Works only for the single select SQL statements, in all other cases the sql query is not modified. :param superset_query: string, sql query that will be executed :param table_name: string, will contain the results of the qu...
superset/sql_parse.py
def as_create_table(self, table_name, overwrite=False): """Reformats the query into the create table as query. Works only for the single select SQL statements, in all other cases the sql query is not modified. :param superset_query: string, sql query that will be executed :param...
def as_create_table(self, table_name, overwrite=False): """Reformats the query into the create table as query. Works only for the single select SQL statements, in all other cases the sql query is not modified. :param superset_query: string, sql query that will be executed :param...
[ "Reformats", "the", "query", "into", "the", "create", "table", "as", "query", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/sql_parse.py#L105-L121
[ "def", "as_create_table", "(", "self", ",", "table_name", ",", "overwrite", "=", "False", ")", ":", "exec_sql", "=", "''", "sql", "=", "self", ".", "stripped", "(", ")", "if", "overwrite", ":", "exec_sql", "=", "f'DROP TABLE IF EXISTS {table_name};\\n'", "exec...
ca2996c78f679260eb79c6008e276733df5fb653
train
ParsedQuery.get_query_with_new_limit
returns the query with the specified limit
superset/sql_parse.py
def get_query_with_new_limit(self, new_limit): """returns the query with the specified limit""" """does not change the underlying query""" if not self._limit: return self.sql + ' LIMIT ' + str(new_limit) limit_pos = None tokens = self._parsed[0].tokens # Add a...
def get_query_with_new_limit(self, new_limit): """returns the query with the specified limit""" """does not change the underlying query""" if not self._limit: return self.sql + ' LIMIT ' + str(new_limit) limit_pos = None tokens = self._parsed[0].tokens # Add a...
[ "returns", "the", "query", "with", "the", "specified", "limit" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/sql_parse.py#L166-L189
[ "def", "get_query_with_new_limit", "(", "self", ",", "new_limit", ")", ":", "\"\"\"does not change the underlying query\"\"\"", "if", "not", "self", ".", "_limit", ":", "return", "self", ".", "sql", "+", "' LIMIT '", "+", "str", "(", "new_limit", ")", "limit_pos",...
ca2996c78f679260eb79c6008e276733df5fb653
train
url_param
Read a url or post parameter and use it in your SQL Lab query When in SQL Lab, it's possible to add arbitrary URL "query string" parameters, and use those in your SQL code. For instance you can alter your url and add `?foo=bar`, as in `{domain}/superset/sqllab?foo=bar`. Then if your query is something ...
superset/jinja_context.py
def url_param(param, default=None): """Read a url or post parameter and use it in your SQL Lab query When in SQL Lab, it's possible to add arbitrary URL "query string" parameters, and use those in your SQL code. For instance you can alter your url and add `?foo=bar`, as in `{domain}/superset/sqllab...
def url_param(param, default=None): """Read a url or post parameter and use it in your SQL Lab query When in SQL Lab, it's possible to add arbitrary URL "query string" parameters, and use those in your SQL code. For instance you can alter your url and add `?foo=bar`, as in `{domain}/superset/sqllab...
[ "Read", "a", "url", "or", "post", "parameter", "and", "use", "it", "in", "your", "SQL", "Lab", "query" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/jinja_context.py#L44-L70
[ "def", "url_param", "(", "param", ",", "default", "=", "None", ")", ":", "if", "request", ".", "args", ".", "get", "(", "param", ")", ":", "return", "request", ".", "args", ".", "get", "(", "param", ",", "default", ")", "# Supporting POST as well as get"...
ca2996c78f679260eb79c6008e276733df5fb653
train
filter_values
Gets a values for a particular filter as a list This is useful if: - you want to use a filter box to filter a query where the name of filter box column doesn't match the one in the select statement - you want to have the ability for filter inside the main query for speed purposes Thi...
superset/jinja_context.py
def filter_values(column, default=None): """ Gets a values for a particular filter as a list This is useful if: - you want to use a filter box to filter a query where the name of filter box column doesn't match the one in the select statement - you want to have the ability for filter ...
def filter_values(column, default=None): """ Gets a values for a particular filter as a list This is useful if: - you want to use a filter box to filter a query where the name of filter box column doesn't match the one in the select statement - you want to have the ability for filter ...
[ "Gets", "a", "values", "for", "a", "particular", "filter", "as", "a", "list" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/jinja_context.py#L85-L125
[ "def", "filter_values", "(", "column", ",", "default", "=", "None", ")", ":", "form_data", "=", "json", ".", "loads", "(", "request", ".", "form", ".", "get", "(", "'form_data'", ",", "'{}'", ")", ")", "return_val", "=", "[", "]", "for", "filter_type",...
ca2996c78f679260eb79c6008e276733df5fb653
train
BaseTemplateProcessor.process_template
Processes a sql template >>> sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'" >>> process_template(sql) "SELECT '2017-01-01T00:00:00'"
superset/jinja_context.py
def process_template(self, sql, **kwargs): """Processes a sql template >>> sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'" >>> process_template(sql) "SELECT '2017-01-01T00:00:00'" """ template = self.env.from_string(sql) kwargs.update(self.context) ...
def process_template(self, sql, **kwargs): """Processes a sql template >>> sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'" >>> process_template(sql) "SELECT '2017-01-01T00:00:00'" """ template = self.env.from_string(sql) kwargs.update(self.context) ...
[ "Processes", "a", "sql", "template" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/jinja_context.py#L165-L174
[ "def", "process_template", "(", "self", ",", "sql", ",", "*", "*", "kwargs", ")", ":", "template", "=", "self", ".", "env", ".", "from_string", "(", "sql", ")", "kwargs", ".", "update", "(", "self", ".", "context", ")", "return", "template", ".", "re...
ca2996c78f679260eb79c6008e276733df5fb653
train
get_datasource_info
Compatibility layer for handling of datasource info datasource_id & datasource_type used to be passed in the URL directory, now they should come as part of the form_data, This function allows supporting both without duplicating code
superset/views/utils.py
def get_datasource_info(datasource_id, datasource_type, form_data): """Compatibility layer for handling of datasource info datasource_id & datasource_type used to be passed in the URL directory, now they should come as part of the form_data, This function allows supporting both without duplicating code...
def get_datasource_info(datasource_id, datasource_type, form_data): """Compatibility layer for handling of datasource info datasource_id & datasource_type used to be passed in the URL directory, now they should come as part of the form_data, This function allows supporting both without duplicating code...
[ "Compatibility", "layer", "for", "handling", "of", "datasource", "info" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/utils.py#L170-L186
[ "def", "get_datasource_info", "(", "datasource_id", ",", "datasource_type", ",", "form_data", ")", ":", "datasource", "=", "form_data", ".", "get", "(", "'datasource'", ",", "''", ")", "if", "'__'", "in", "datasource", ":", "datasource_id", ",", "datasource_type...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetSecurityManager.can_access
Protecting from has_access failing from missing perms/view
superset/security.py
def can_access(self, permission_name, view_name): """Protecting from has_access failing from missing perms/view""" user = g.user if user.is_anonymous: return self.is_item_public(permission_name, view_name) return self._has_view_access(user, permission_name, view_name)
def can_access(self, permission_name, view_name): """Protecting from has_access failing from missing perms/view""" user = g.user if user.is_anonymous: return self.is_item_public(permission_name, view_name) return self._has_view_access(user, permission_name, view_name)
[ "Protecting", "from", "has_access", "failing", "from", "missing", "perms", "/", "view" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/security.py#L106-L111
[ "def", "can_access", "(", "self", ",", "permission_name", ",", "view_name", ")", ":", "user", "=", "g", ".", "user", "if", "user", ".", "is_anonymous", ":", "return", "self", ".", "is_item_public", "(", "permission_name", ",", "view_name", ")", "return", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetSecurityManager.create_missing_perms
Creates missing perms for datasources, schemas and metrics
superset/security.py
def create_missing_perms(self): """Creates missing perms for datasources, schemas and metrics""" from superset import db from superset.models import core as models logging.info( 'Fetching a set of all perms to lookup which ones are missing') all_pvs = set() f...
def create_missing_perms(self): """Creates missing perms for datasources, schemas and metrics""" from superset import db from superset.models import core as models logging.info( 'Fetching a set of all perms to lookup which ones are missing') all_pvs = set() f...
[ "Creates", "missing", "perms", "for", "datasources", "schemas", "and", "metrics" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/security.py#L287-L322
[ "def", "create_missing_perms", "(", "self", ")", ":", "from", "superset", "import", "db", "from", "superset", ".", "models", "import", "core", "as", "models", "logging", ".", "info", "(", "'Fetching a set of all perms to lookup which ones are missing'", ")", "all_pvs"...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetSecurityManager.clean_perms
FAB leaves faulty permissions that need to be cleaned up
superset/security.py
def clean_perms(self): """FAB leaves faulty permissions that need to be cleaned up""" logging.info('Cleaning faulty perms') sesh = self.get_session pvms = ( sesh.query(ab_models.PermissionView) .filter(or_( ab_models.PermissionView.permission == No...
def clean_perms(self): """FAB leaves faulty permissions that need to be cleaned up""" logging.info('Cleaning faulty perms') sesh = self.get_session pvms = ( sesh.query(ab_models.PermissionView) .filter(or_( ab_models.PermissionView.permission == No...
[ "FAB", "leaves", "faulty", "permissions", "that", "need", "to", "be", "cleaned", "up" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/security.py#L324-L338
[ "def", "clean_perms", "(", "self", ")", ":", "logging", ".", "info", "(", "'Cleaning faulty perms'", ")", "sesh", "=", "self", ".", "get_session", "pvms", "=", "(", "sesh", ".", "query", "(", "ab_models", ".", "PermissionView", ")", ".", "filter", "(", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
SupersetSecurityManager.sync_role_definitions
Inits the Superset application with security roles and such
superset/security.py
def sync_role_definitions(self): """Inits the Superset application with security roles and such""" from superset import conf logging.info('Syncing role definition') self.create_custom_permissions() # Creating default roles self.set_role('Admin', self.is_admin_pvm) ...
def sync_role_definitions(self): """Inits the Superset application with security roles and such""" from superset import conf logging.info('Syncing role definition') self.create_custom_permissions() # Creating default roles self.set_role('Admin', self.is_admin_pvm) ...
[ "Inits", "the", "Superset", "application", "with", "security", "roles", "and", "such" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/security.py#L340-L361
[ "def", "sync_role_definitions", "(", "self", ")", ":", "from", "superset", "import", "conf", "logging", ".", "info", "(", "'Syncing role definition'", ")", "self", ".", "create_custom_permissions", "(", ")", "# Creating default roles", "self", ".", "set_role", "(", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
export_schema_to_dict
Exports the supported import/export schema to a dictionary
superset/utils/dict_import_export.py
def export_schema_to_dict(back_references): """Exports the supported import/export schema to a dictionary""" databases = [Database.export_schema(recursive=True, include_parent_ref=back_references)] clusters = [DruidCluster.export_schema(recursive=True, include_parent_ref=bac...
def export_schema_to_dict(back_references): """Exports the supported import/export schema to a dictionary""" databases = [Database.export_schema(recursive=True, include_parent_ref=back_references)] clusters = [DruidCluster.export_schema(recursive=True, include_parent_ref=bac...
[ "Exports", "the", "supported", "import", "/", "export", "schema", "to", "a", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/dict_import_export.py#L28-L39
[ "def", "export_schema_to_dict", "(", "back_references", ")", ":", "databases", "=", "[", "Database", ".", "export_schema", "(", "recursive", "=", "True", ",", "include_parent_ref", "=", "back_references", ")", "]", "clusters", "=", "[", "DruidCluster", ".", "exp...
ca2996c78f679260eb79c6008e276733df5fb653
train
export_to_dict
Exports databases and druid clusters to a dictionary
superset/utils/dict_import_export.py
def export_to_dict(session, recursive, back_references, include_defaults): """Exports databases and druid clusters to a dictionary""" logging.info('Starting export') dbs = session.query(Database) databases = [database.export_to_dict(recursive=recu...
def export_to_dict(session, recursive, back_references, include_defaults): """Exports databases and druid clusters to a dictionary""" logging.info('Starting export') dbs = session.query(Database) databases = [database.export_to_dict(recursive=recu...
[ "Exports", "databases", "and", "druid", "clusters", "to", "a", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/dict_import_export.py#L42-L63
[ "def", "export_to_dict", "(", "session", ",", "recursive", ",", "back_references", ",", "include_defaults", ")", ":", "logging", ".", "info", "(", "'Starting export'", ")", "dbs", "=", "session", ".", "query", "(", "Database", ")", "databases", "=", "[", "da...
ca2996c78f679260eb79c6008e276733df5fb653
train
import_from_dict
Imports databases and druid clusters from dictionary
superset/utils/dict_import_export.py
def import_from_dict(session, data, sync=[]): """Imports databases and druid clusters from dictionary""" if isinstance(data, dict): logging.info('Importing %d %s', len(data.get(DATABASES_KEY, [])), DATABASES_KEY) for database in data.get(DATABASES_KEY, [...
def import_from_dict(session, data, sync=[]): """Imports databases and druid clusters from dictionary""" if isinstance(data, dict): logging.info('Importing %d %s', len(data.get(DATABASES_KEY, [])), DATABASES_KEY) for database in data.get(DATABASES_KEY, [...
[ "Imports", "databases", "and", "druid", "clusters", "from", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/dict_import_export.py#L66-L82
[ "def", "import_from_dict", "(", "session", ",", "data", ",", "sync", "=", "[", "]", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "logging", ".", "info", "(", "'Importing %d %s'", ",", "len", "(", "data", ".", "get", "(", "DATABAS...
ca2996c78f679260eb79c6008e276733df5fb653
train
Api.query
Takes a query_obj constructed in the client and returns payload data response for the given query_obj. params: query_context: json_blob
superset/views/api.py
def query(self): """ Takes a query_obj constructed in the client and returns payload data response for the given query_obj. params: query_context: json_blob """ query_context = QueryContext(**json.loads(request.form.get('query_context'))) security_manager.assert_d...
def query(self): """ Takes a query_obj constructed in the client and returns payload data response for the given query_obj. params: query_context: json_blob """ query_context = QueryContext(**json.loads(request.form.get('query_context'))) security_manager.assert_d...
[ "Takes", "a", "query_obj", "constructed", "in", "the", "client", "and", "returns", "payload", "data", "response", "for", "the", "given", "query_obj", ".", "params", ":", "query_context", ":", "json_blob" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/api.py#L38-L51
[ "def", "query", "(", "self", ")", ":", "query_context", "=", "QueryContext", "(", "*", "*", "json", ".", "loads", "(", "request", ".", "form", ".", "get", "(", "'query_context'", ")", ")", ")", "security_manager", ".", "assert_datasource_permission", "(", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Api.query_form_data
Get the formdata stored in the database for existing slice. params: slice_id: integer
superset/views/api.py
def query_form_data(self): """ Get the formdata stored in the database for existing slice. params: slice_id: integer """ form_data = {} slice_id = request.args.get('slice_id') if slice_id: slc = db.session.query(models.Slice).filter_by(id=slice_id).one...
def query_form_data(self): """ Get the formdata stored in the database for existing slice. params: slice_id: integer """ form_data = {} slice_id = request.args.get('slice_id') if slice_id: slc = db.session.query(models.Slice).filter_by(id=slice_id).one...
[ "Get", "the", "formdata", "stored", "in", "the", "database", "for", "existing", "slice", ".", "params", ":", "slice_id", ":", "integer" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/api.py#L58-L72
[ "def", "query_form_data", "(", "self", ")", ":", "form_data", "=", "{", "}", "slice_id", "=", "request", ".", "args", ".", "get", "(", "'slice_id'", ")", "if", "slice_id", ":", "slc", "=", "db", ".", "session", ".", "query", "(", "models", ".", "Slic...
ca2996c78f679260eb79c6008e276733df5fb653
train
load_css_templates
Loads 2 css templates to demonstrate the feature
superset/data/css_templates.py
def load_css_templates(): """Loads 2 css templates to demonstrate the feature""" print('Creating default CSS templates') obj = db.session.query(CssTemplate).filter_by(template_name='Flat').first() if not obj: obj = CssTemplate(template_name='Flat') css = textwrap.dedent("""\ .gridster d...
def load_css_templates(): """Loads 2 css templates to demonstrate the feature""" print('Creating default CSS templates') obj = db.session.query(CssTemplate).filter_by(template_name='Flat').first() if not obj: obj = CssTemplate(template_name='Flat') css = textwrap.dedent("""\ .gridster d...
[ "Loads", "2", "css", "templates", "to", "demonstrate", "the", "feature" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/data/css_templates.py#L23-L119
[ "def", "load_css_templates", "(", ")", ":", "print", "(", "'Creating default CSS templates'", ")", "obj", "=", "db", ".", "session", ".", "query", "(", "CssTemplate", ")", ".", "filter_by", "(", "template_name", "=", "'Flat'", ")", ".", "first", "(", ")", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin._parent_foreign_key_mappings
Get a mapping of foreign name to the local name of foreign keys
superset/models/helpers.py
def _parent_foreign_key_mappings(cls): """Get a mapping of foreign name to the local name of foreign keys""" parent_rel = cls.__mapper__.relationships.get(cls.export_parent) if parent_rel: return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs} return {}
def _parent_foreign_key_mappings(cls): """Get a mapping of foreign name to the local name of foreign keys""" parent_rel = cls.__mapper__.relationships.get(cls.export_parent) if parent_rel: return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs} return {}
[ "Get", "a", "mapping", "of", "foreign", "name", "to", "the", "local", "name", "of", "foreign", "keys" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L60-L65
[ "def", "_parent_foreign_key_mappings", "(", "cls", ")", ":", "parent_rel", "=", "cls", ".", "__mapper__", ".", "relationships", ".", "get", "(", "cls", ".", "export_parent", ")", "if", "parent_rel", ":", "return", "{", "l", ".", "name", ":", "r", ".", "n...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin._unique_constrains
Get all (single column and multi column) unique constraints
superset/models/helpers.py
def _unique_constrains(cls): """Get all (single column and multi column) unique constraints""" unique = [{c.name for c in u.columns} for u in cls.__table_args__ if isinstance(u, UniqueConstraint)] unique.extend({c.name} for c in cls.__table__.columns if c.unique) return...
def _unique_constrains(cls): """Get all (single column and multi column) unique constraints""" unique = [{c.name for c in u.columns} for u in cls.__table_args__ if isinstance(u, UniqueConstraint)] unique.extend({c.name} for c in cls.__table__.columns if c.unique) return...
[ "Get", "all", "(", "single", "column", "and", "multi", "column", ")", "unique", "constraints" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L68-L73
[ "def", "_unique_constrains", "(", "cls", ")", ":", "unique", "=", "[", "{", "c", ".", "name", "for", "c", "in", "u", ".", "columns", "}", "for", "u", "in", "cls", ".", "__table_args__", "if", "isinstance", "(", "u", ",", "UniqueConstraint", ")", "]",...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin.export_schema
Export schema as a dictionary
superset/models/helpers.py
def export_schema(cls, recursive=True, include_parent_ref=False): """Export schema as a dictionary""" parent_excludes = {} if not include_parent_ref: parent_ref = cls.__mapper__.relationships.get(cls.export_parent) if parent_ref: parent_excludes = {c.name ...
def export_schema(cls, recursive=True, include_parent_ref=False): """Export schema as a dictionary""" parent_excludes = {} if not include_parent_ref: parent_ref = cls.__mapper__.relationships.get(cls.export_parent) if parent_ref: parent_excludes = {c.name ...
[ "Export", "schema", "as", "a", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L76-L96
[ "def", "export_schema", "(", "cls", ",", "recursive", "=", "True", ",", "include_parent_ref", "=", "False", ")", ":", "parent_excludes", "=", "{", "}", "if", "not", "include_parent_ref", ":", "parent_ref", "=", "cls", ".", "__mapper__", ".", "relationships", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin.import_from_dict
Import obj from a dictionary
superset/models/helpers.py
def import_from_dict(cls, session, dict_rep, parent=None, recursive=True, sync=[]): """Import obj from a dictionary""" parent_refs = cls._parent_foreign_key_mappings() export_fields = set(cls.export_fields) | set(parent_refs.keys()) new_children = {c: dict_rep.ge...
def import_from_dict(cls, session, dict_rep, parent=None, recursive=True, sync=[]): """Import obj from a dictionary""" parent_refs = cls._parent_foreign_key_mappings() export_fields = set(cls.export_fields) | set(parent_refs.keys()) new_children = {c: dict_rep.ge...
[ "Import", "obj", "from", "a", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L99-L184
[ "def", "import_from_dict", "(", "cls", ",", "session", ",", "dict_rep", ",", "parent", "=", "None", ",", "recursive", "=", "True", ",", "sync", "=", "[", "]", ")", ":", "parent_refs", "=", "cls", ".", "_parent_foreign_key_mappings", "(", ")", "export_field...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin.export_to_dict
Export obj to dictionary
superset/models/helpers.py
def export_to_dict(self, recursive=True, include_parent_ref=False, include_defaults=False): """Export obj to dictionary""" cls = self.__class__ parent_excludes = {} if recursive and not include_parent_ref: parent_ref = cls.__mapper__.relationships.get(c...
def export_to_dict(self, recursive=True, include_parent_ref=False, include_defaults=False): """Export obj to dictionary""" cls = self.__class__ parent_excludes = {} if recursive and not include_parent_ref: parent_ref = cls.__mapper__.relationships.get(c...
[ "Export", "obj", "to", "dictionary" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L186-L217
[ "def", "export_to_dict", "(", "self", ",", "recursive", "=", "True", ",", "include_parent_ref", "=", "False", ",", "include_defaults", "=", "False", ")", ":", "cls", "=", "self", ".", "__class__", "parent_excludes", "=", "{", "}", "if", "recursive", "and", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
ImportMixin.override
Overrides the plain fields of the dashboard.
superset/models/helpers.py
def override(self, obj): """Overrides the plain fields of the dashboard.""" for field in obj.__class__.export_fields: setattr(self, field, getattr(obj, field))
def override(self, obj): """Overrides the plain fields of the dashboard.""" for field in obj.__class__.export_fields: setattr(self, field, getattr(obj, field))
[ "Overrides", "the", "plain", "fields", "of", "the", "dashboard", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/helpers.py#L219-L222
[ "def", "override", "(", "self", ",", "obj", ")", ":", "for", "field", "in", "obj", ".", "__class__", ".", "export_fields", ":", "setattr", "(", "self", ",", "field", ",", "getattr", "(", "obj", ",", "field", ")", ")" ]
ca2996c78f679260eb79c6008e276733df5fb653
train
update_time_range
Move since and until to time_range.
superset/legacy.py
def update_time_range(form_data): """Move since and until to time_range.""" if 'since' in form_data or 'until' in form_data: form_data['time_range'] = '{} : {}'.format( form_data.pop('since', '') or '', form_data.pop('until', '') or '', )
def update_time_range(form_data): """Move since and until to time_range.""" if 'since' in form_data or 'until' in form_data: form_data['time_range'] = '{} : {}'.format( form_data.pop('since', '') or '', form_data.pop('until', '') or '', )
[ "Move", "since", "and", "until", "to", "time_range", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/legacy.py#L21-L27
[ "def", "update_time_range", "(", "form_data", ")", ":", "if", "'since'", "in", "form_data", "or", "'until'", "in", "form_data", ":", "form_data", "[", "'time_range'", "]", "=", "'{} : {}'", ".", "format", "(", "form_data", ".", "pop", "(", "'since'", ",", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
memoized_func
Use this decorator to cache functions that have predefined first arg. enable_cache is treated as True by default, except enable_cache = False is passed to the decorated function. force means whether to force refresh the cache and is treated as False by default, except force = True is passed to the dec...
superset/utils/cache.py
def memoized_func(key=view_cache_key, attribute_in_key=None): """Use this decorator to cache functions that have predefined first arg. enable_cache is treated as True by default, except enable_cache = False is passed to the decorated function. force means whether to force refresh the cache and is trea...
def memoized_func(key=view_cache_key, attribute_in_key=None): """Use this decorator to cache functions that have predefined first arg. enable_cache is treated as True by default, except enable_cache = False is passed to the decorated function. force means whether to force refresh the cache and is trea...
[ "Use", "this", "decorator", "to", "cache", "functions", "that", "have", "predefined", "first", "arg", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/utils/cache.py#L28-L67
[ "def", "memoized_func", "(", "key", "=", "view_cache_key", ",", "attribute_in_key", "=", "None", ")", ":", "def", "wrap", "(", "f", ")", ":", "if", "tables_cache", ":", "def", "wrapped_f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Query.name
Name property
superset/models/sql_lab.py
def name(self): """Name property""" ts = datetime.now().isoformat() ts = ts.replace('-', '').replace(':', '').split('.')[0] tab = (self.tab_name.replace(' ', '_').lower() if self.tab_name else 'notab') tab = re.sub(r'\W+', '', tab) return f'sqllab_{tab}_{ts...
def name(self): """Name property""" ts = datetime.now().isoformat() ts = ts.replace('-', '').replace(':', '').split('.')[0] tab = (self.tab_name.replace(' ', '_').lower() if self.tab_name else 'notab') tab = re.sub(r'\W+', '', tab) return f'sqllab_{tab}_{ts...
[ "Name", "property" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/models/sql_lab.py#L132-L139
[ "def", "name", "(", "self", ")", ":", "ts", "=", "datetime", ".", "now", "(", ")", ".", "isoformat", "(", ")", "ts", "=", "ts", ".", "replace", "(", "'-'", ",", "''", ")", ".", "replace", "(", "':'", ",", "''", ")", ".", "split", "(", "'.'", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
check_datasource_perms
Check if user can access a cached response from explore_json. This function takes `self` since it must have the same signature as the the decorated method.
superset/views/core.py
def check_datasource_perms(self, datasource_type=None, datasource_id=None): """ Check if user can access a cached response from explore_json. This function takes `self` since it must have the same signature as the the decorated method. """ form_data = get_form_data()[0] datasource_id, data...
def check_datasource_perms(self, datasource_type=None, datasource_id=None): """ Check if user can access a cached response from explore_json. This function takes `self` since it must have the same signature as the the decorated method. """ form_data = get_form_data()[0] datasource_id, data...
[ "Check", "if", "user", "can", "access", "a", "cached", "response", "from", "explore_json", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L106-L123
[ "def", "check_datasource_perms", "(", "self", ",", "datasource_type", "=", "None", ",", "datasource_id", "=", "None", ")", ":", "form_data", "=", "get_form_data", "(", ")", "[", "0", "]", "datasource_id", ",", "datasource_type", "=", "get_datasource_info", "(", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
check_slice_perms
Check if user can access a cached response from slice_json. This function takes `self` since it must have the same signature as the the decorated method.
superset/views/core.py
def check_slice_perms(self, slice_id): """ Check if user can access a cached response from slice_json. This function takes `self` since it must have the same signature as the the decorated method. """ form_data, slc = get_form_data(slice_id, use_slice_data=True) datasource_type = slc.datas...
def check_slice_perms(self, slice_id): """ Check if user can access a cached response from slice_json. This function takes `self` since it must have the same signature as the the decorated method. """ form_data, slc = get_form_data(slice_id, use_slice_data=True) datasource_type = slc.datas...
[ "Check", "if", "user", "can", "access", "a", "cached", "response", "from", "slice_json", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L126-L143
[ "def", "check_slice_perms", "(", "self", ",", "slice_id", ")", ":", "form_data", ",", "slc", "=", "get_form_data", "(", "slice_id", ",", "use_slice_data", "=", "True", ")", "datasource_type", "=", "slc", ".", "datasource", ".", "type", "datasource_id", "=", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
apply_caching
Applies the configuration's http headers to all responses
superset/views/core.py
def apply_caching(response): """Applies the configuration's http headers to all responses""" for k, v in config.get('HTTP_HEADERS').items(): response.headers[k] = v return response
def apply_caching(response): """Applies the configuration's http headers to all responses""" for k, v in config.get('HTTP_HEADERS').items(): response.headers[k] = v return response
[ "Applies", "the", "configuration", "s", "http", "headers", "to", "all", "responses" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L3017-L3021
[ "def", "apply_caching", "(", "response", ")", ":", "for", "k", ",", "v", "in", "config", ".", "get", "(", "'HTTP_HEADERS'", ")", ".", "items", "(", ")", ":", "response", ".", "headers", "[", "k", "]", "=", "v", "return", "response" ]
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.override_role_permissions
Updates the role with the give datasource permissions. Permissions not in the request will be revoked. This endpoint should be available to admins only. Expects JSON in the format: { 'role_name': '{role_name}', 'database': [{ 'datasource_type': '{t...
superset/views/core.py
def override_role_permissions(self): """Updates the role with the give datasource permissions. Permissions not in the request will be revoked. This endpoint should be available to admins only. Expects JSON in the format: { 'role_name': '{role_name}', 'data...
def override_role_permissions(self): """Updates the role with the give datasource permissions. Permissions not in the request will be revoked. This endpoint should be available to admins only. Expects JSON in the format: { 'role_name': '{role_name}', 'data...
[ "Updates", "the", "role", "with", "the", "give", "datasource", "permissions", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L862-L911
[ "def", "override_role_permissions", "(", "self", ")", ":", "data", "=", "request", ".", "get_json", "(", "force", "=", "True", ")", "role_name", "=", "data", "[", "'role_name'", "]", "databases", "=", "data", "[", "'database'", "]", "db_ds_names", "=", "se...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.explore_json
Serves all request that GET or POST form_data This endpoint evolved to be the entry point of many different requests that GETs or POSTs a form_data. `self.generate_json` receives this input and returns different payloads based on the request args in the first block TODO: break...
superset/views/core.py
def explore_json(self, datasource_type=None, datasource_id=None): """Serves all request that GET or POST form_data This endpoint evolved to be the entry point of many different requests that GETs or POSTs a form_data. `self.generate_json` receives this input and returns different ...
def explore_json(self, datasource_type=None, datasource_id=None): """Serves all request that GET or POST form_data This endpoint evolved to be the entry point of many different requests that GETs or POSTs a form_data. `self.generate_json` receives this input and returns different ...
[ "Serves", "all", "request", "that", "GET", "or", "POST", "form_data" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1233-L1265
[ "def", "explore_json", "(", "self", ",", "datasource_type", "=", "None", ",", "datasource_id", "=", "None", ")", ":", "csv", "=", "request", ".", "args", ".", "get", "(", "'csv'", ")", "==", "'true'", "query", "=", "request", ".", "args", ".", "get", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.import_dashboards
Overrides the dashboards using json instances from the file.
superset/views/core.py
def import_dashboards(self): """Overrides the dashboards using json instances from the file.""" f = request.files.get('file') if request.method == 'POST' and f: dashboard_import_export.import_dashboards(db.session, f.stream) return redirect('/dashboard/list/') ret...
def import_dashboards(self): """Overrides the dashboards using json instances from the file.""" f = request.files.get('file') if request.method == 'POST' and f: dashboard_import_export.import_dashboards(db.session, f.stream) return redirect('/dashboard/list/') ret...
[ "Overrides", "the", "dashboards", "using", "json", "instances", "from", "the", "file", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1270-L1276
[ "def", "import_dashboards", "(", "self", ")", ":", "f", "=", "request", ".", "files", ".", "get", "(", "'file'", ")", "if", "request", ".", "method", "==", "'POST'", "and", "f", ":", "dashboard_import_export", ".", "import_dashboards", "(", "db", ".", "s...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.explorev2
Deprecated endpoint, here for backward compatibility of urls
superset/views/core.py
def explorev2(self, datasource_type, datasource_id): """Deprecated endpoint, here for backward compatibility of urls""" return redirect(url_for( 'Superset.explore', datasource_type=datasource_type, datasource_id=datasource_id, **request.args))
def explorev2(self, datasource_type, datasource_id): """Deprecated endpoint, here for backward compatibility of urls""" return redirect(url_for( 'Superset.explore', datasource_type=datasource_type, datasource_id=datasource_id, **request.args))
[ "Deprecated", "endpoint", "here", "for", "backward", "compatibility", "of", "urls" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1281-L1287
[ "def", "explorev2", "(", "self", ",", "datasource_type", ",", "datasource_id", ")", ":", "return", "redirect", "(", "url_for", "(", "'Superset.explore'", ",", "datasource_type", "=", "datasource_type", ",", "datasource_id", "=", "datasource_id", ",", "*", "*", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.filter
Endpoint to retrieve values for specified column. :param datasource_type: Type of datasource e.g. table :param datasource_id: Datasource id :param column: Column name to retrieve values for :return:
superset/views/core.py
def filter(self, datasource_type, datasource_id, column): """ Endpoint to retrieve values for specified column. :param datasource_type: Type of datasource e.g. table :param datasource_id: Datasource id :param column: Column name to retrieve values for :return: ""...
def filter(self, datasource_type, datasource_id, column): """ Endpoint to retrieve values for specified column. :param datasource_type: Type of datasource e.g. table :param datasource_id: Datasource id :param column: Column name to retrieve values for :return: ""...
[ "Endpoint", "to", "retrieve", "values", "for", "specified", "column", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1394-L1415
[ "def", "filter", "(", "self", ",", "datasource_type", ",", "datasource_id", ",", "column", ")", ":", "# TODO: Cache endpoint by user, datasource and column", "datasource", "=", "ConnectorRegistry", ".", "get_datasource", "(", "datasource_type", ",", "datasource_id", ",", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.save_or_overwrite_slice
Save or overwrite a slice
superset/views/core.py
def save_or_overwrite_slice( self, args, slc, slice_add_perm, slice_overwrite_perm, slice_download_perm, datasource_id, datasource_type, datasource_name): """Save or overwrite a slice""" slice_name = args.get('slice_name') action = args.get('action') form_data = g...
def save_or_overwrite_slice( self, args, slc, slice_add_perm, slice_overwrite_perm, slice_download_perm, datasource_id, datasource_type, datasource_name): """Save or overwrite a slice""" slice_name = args.get('slice_name') action = args.get('action') form_data = g...
[ "Save", "or", "overwrite", "a", "slice" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1417-L1498
[ "def", "save_or_overwrite_slice", "(", "self", ",", "args", ",", "slc", ",", "slice_add_perm", ",", "slice_overwrite_perm", ",", "slice_download_perm", ",", "datasource_id", ",", "datasource_type", ",", "datasource_name", ")", ":", "slice_name", "=", "args", ".", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.checkbox
endpoint for checking/unchecking any boolean in a sqla model
superset/views/core.py
def checkbox(self, model_view, id_, attr, value): """endpoint for checking/unchecking any boolean in a sqla model""" modelview_to_model = { '{}ColumnInlineView'.format(name.capitalize()): source.column_class for name, source in ConnectorRegistry.sources.items() } ...
def checkbox(self, model_view, id_, attr, value): """endpoint for checking/unchecking any boolean in a sqla model""" modelview_to_model = { '{}ColumnInlineView'.format(name.capitalize()): source.column_class for name, source in ConnectorRegistry.sources.items() } ...
[ "endpoint", "for", "checking", "/", "unchecking", "any", "boolean", "in", "a", "sqla", "model" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1517-L1532
[ "def", "checkbox", "(", "self", ",", "model_view", ",", "id_", ",", "attr", ",", "value", ")", ":", "modelview_to_model", "=", "{", "'{}ColumnInlineView'", ".", "format", "(", "name", ".", "capitalize", "(", ")", ")", ":", "source", ".", "column_class", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.tables
Endpoint to fetch the list of tables for given database
superset/views/core.py
def tables(self, db_id, schema, substr, force_refresh='false'): """Endpoint to fetch the list of tables for given database""" db_id = int(db_id) force_refresh = force_refresh.lower() == 'true' schema = utils.js_string_to_python(schema) substr = utils.js_string_to_python(substr) ...
def tables(self, db_id, schema, substr, force_refresh='false'): """Endpoint to fetch the list of tables for given database""" db_id = int(db_id) force_refresh = force_refresh.lower() == 'true' schema = utils.js_string_to_python(schema) substr = utils.js_string_to_python(substr) ...
[ "Endpoint", "to", "fetch", "the", "list", "of", "tables", "for", "given", "database" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1564-L1619
[ "def", "tables", "(", "self", ",", "db_id", ",", "schema", ",", "substr", ",", "force_refresh", "=", "'false'", ")", ":", "db_id", "=", "int", "(", "db_id", ")", "force_refresh", "=", "force_refresh", ".", "lower", "(", ")", "==", "'true'", "schema", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.copy_dash
Copy dashboard
superset/views/core.py
def copy_dash(self, dashboard_id): """Copy dashboard""" session = db.session() data = json.loads(request.form.get('data')) dash = models.Dashboard() original_dash = ( session .query(models.Dashboard) .filter_by(id=dashboard_id).first()) ...
def copy_dash(self, dashboard_id): """Copy dashboard""" session = db.session() data = json.loads(request.form.get('data')) dash = models.Dashboard() original_dash = ( session .query(models.Dashboard) .filter_by(id=dashboard_id).first()) ...
[ "Copy", "dashboard" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1624-L1669
[ "def", "copy_dash", "(", "self", ",", "dashboard_id", ")", ":", "session", "=", "db", ".", "session", "(", ")", "data", "=", "json", ".", "loads", "(", "request", ".", "form", ".", "get", "(", "'data'", ")", ")", "dash", "=", "models", ".", "Dashbo...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.save_dash
Save a dashboard's metadata
superset/views/core.py
def save_dash(self, dashboard_id): """Save a dashboard's metadata""" session = db.session() dash = (session .query(models.Dashboard) .filter_by(id=dashboard_id).first()) check_ownership(dash, raise_if_false=True) data = json.loads(request.form.get(...
def save_dash(self, dashboard_id): """Save a dashboard's metadata""" session = db.session() dash = (session .query(models.Dashboard) .filter_by(id=dashboard_id).first()) check_ownership(dash, raise_if_false=True) data = json.loads(request.form.get(...
[ "Save", "a", "dashboard", "s", "metadata" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1674-L1686
[ "def", "save_dash", "(", "self", ",", "dashboard_id", ")", ":", "session", "=", "db", ".", "session", "(", ")", "dash", "=", "(", "session", ".", "query", "(", "models", ".", "Dashboard", ")", ".", "filter_by", "(", "id", "=", "dashboard_id", ")", "....
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.add_slices
Add and save slices to a dashboard
superset/views/core.py
def add_slices(self, dashboard_id): """Add and save slices to a dashboard""" data = json.loads(request.form.get('data')) session = db.session() Slice = models.Slice # noqa dash = ( session.query(models.Dashboard).filter_by(id=dashboard_id).first()) check_owne...
def add_slices(self, dashboard_id): """Add and save slices to a dashboard""" data = json.loads(request.form.get('data')) session = db.session() Slice = models.Slice # noqa dash = ( session.query(models.Dashboard).filter_by(id=dashboard_id).first()) check_owne...
[ "Add", "and", "save", "slices", "to", "a", "dashboard" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1749-L1763
[ "def", "add_slices", "(", "self", ",", "dashboard_id", ")", ":", "data", "=", "json", ".", "loads", "(", "request", ".", "form", ".", "get", "(", "'data'", ")", ")", "session", "=", "db", ".", "session", "(", ")", "Slice", "=", "models", ".", "Slic...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.recent_activity
Recent activity (actions) for a given user
superset/views/core.py
def recent_activity(self, user_id): """Recent activity (actions) for a given user""" M = models # noqa if request.args.get('limit'): limit = int(request.args.get('limit')) else: limit = 1000 qry = ( db.session.query(M.Log, M.Dashboard, M.Sli...
def recent_activity(self, user_id): """Recent activity (actions) for a given user""" M = models # noqa if request.args.get('limit'): limit = int(request.args.get('limit')) else: limit = 1000 qry = ( db.session.query(M.Log, M.Dashboard, M.Sli...
[ "Recent", "activity", "(", "actions", ")", "for", "a", "given", "user" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1826-L1872
[ "def", "recent_activity", "(", "self", ",", "user_id", ")", ":", "M", "=", "models", "# noqa", "if", "request", ".", "args", ".", "get", "(", "'limit'", ")", ":", "limit", "=", "int", "(", "request", ".", "args", ".", "get", "(", "'limit'", ")", ")...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.fave_dashboards_by_username
This lets us use a user's username to pull favourite dashboards
superset/views/core.py
def fave_dashboards_by_username(self, username): """This lets us use a user's username to pull favourite dashboards""" user = security_manager.find_user(username=username) return self.fave_dashboards(user.get_id())
def fave_dashboards_by_username(self, username): """This lets us use a user's username to pull favourite dashboards""" user = security_manager.find_user(username=username) return self.fave_dashboards(user.get_id())
[ "This", "lets", "us", "use", "a", "user", "s", "username", "to", "pull", "favourite", "dashboards" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1900-L1903
[ "def", "fave_dashboards_by_username", "(", "self", ",", "username", ")", ":", "user", "=", "security_manager", ".", "find_user", "(", "username", "=", "username", ")", "return", "self", ".", "fave_dashboards", "(", "user", ".", "get_id", "(", ")", ")" ]
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.user_slices
List of slices a user created, or faved
superset/views/core.py
def user_slices(self, user_id=None): """List of slices a user created, or faved""" if not user_id: user_id = g.user.id Slice = models.Slice # noqa FavStar = models.FavStar # noqa qry = ( db.session.query(Slice, FavStar.dttm).j...
def user_slices(self, user_id=None): """List of slices a user created, or faved""" if not user_id: user_id = g.user.id Slice = models.Slice # noqa FavStar = models.FavStar # noqa qry = ( db.session.query(Slice, FavStar.dttm).j...
[ "List", "of", "slices", "a", "user", "created", "or", "faved" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L1977-L2010
[ "def", "user_slices", "(", "self", ",", "user_id", "=", "None", ")", ":", "if", "not", "user_id", ":", "user_id", "=", "g", ".", "user", ".", "id", "Slice", "=", "models", ".", "Slice", "# noqa", "FavStar", "=", "models", ".", "FavStar", "# noqa", "q...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.created_slices
List of slices created by this user
superset/views/core.py
def created_slices(self, user_id=None): """List of slices created by this user""" if not user_id: user_id = g.user.id Slice = models.Slice # noqa qry = ( db.session.query(Slice) .filter( sqla.or_( Slice.created_by_f...
def created_slices(self, user_id=None): """List of slices created by this user""" if not user_id: user_id = g.user.id Slice = models.Slice # noqa qry = ( db.session.query(Slice) .filter( sqla.or_( Slice.created_by_f...
[ "List", "of", "slices", "created", "by", "this", "user" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2016-L2039
[ "def", "created_slices", "(", "self", ",", "user_id", "=", "None", ")", ":", "if", "not", "user_id", ":", "user_id", "=", "g", ".", "user", ".", "id", "Slice", "=", "models", ".", "Slice", "# noqa", "qry", "=", "(", "db", ".", "session", ".", "quer...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.fave_slices
Favorite slices for a user
superset/views/core.py
def fave_slices(self, user_id=None): """Favorite slices for a user""" if not user_id: user_id = g.user.id qry = ( db.session.query( models.Slice, models.FavStar.dttm, ) .join( models.FavStar, ...
def fave_slices(self, user_id=None): """Favorite slices for a user""" if not user_id: user_id = g.user.id qry = ( db.session.query( models.Slice, models.FavStar.dttm, ) .join( models.FavStar, ...
[ "Favorite", "slices", "for", "a", "user" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2045-L2082
[ "def", "fave_slices", "(", "self", ",", "user_id", "=", "None", ")", ":", "if", "not", "user_id", ":", "user_id", "=", "g", ".", "user", ".", "id", "qry", "=", "(", "db", ".", "session", ".", "query", "(", "models", ".", "Slice", ",", "models", "...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.warm_up_cache
Warms up the cache for the slice or table. Note for slices a force refresh occurs.
superset/views/core.py
def warm_up_cache(self): """Warms up the cache for the slice or table. Note for slices a force refresh occurs. """ slices = None session = db.session() slice_id = request.args.get('slice_id') table_name = request.args.get('table_name') db_name = request.a...
def warm_up_cache(self): """Warms up the cache for the slice or table. Note for slices a force refresh occurs. """ slices = None session = db.session() slice_id = request.args.get('slice_id') table_name = request.args.get('table_name') db_name = request.a...
[ "Warms", "up", "the", "cache", "for", "the", "slice", "or", "table", "." ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2087-L2138
[ "def", "warm_up_cache", "(", "self", ")", ":", "slices", "=", "None", "session", "=", "db", ".", "session", "(", ")", "slice_id", "=", "request", ".", "args", ".", "get", "(", "'slice_id'", ")", "table_name", "=", "request", ".", "args", ".", "get", ...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.favstar
Toggle favorite stars on Slices and Dashboard
superset/views/core.py
def favstar(self, class_name, obj_id, action): """Toggle favorite stars on Slices and Dashboard""" session = db.session() FavStar = models.FavStar # noqa count = 0 favs = session.query(FavStar).filter_by( class_name=class_name, obj_id=obj_id, user_id=g.us...
def favstar(self, class_name, obj_id, action): """Toggle favorite stars on Slices and Dashboard""" session = db.session() FavStar = models.FavStar # noqa count = 0 favs = session.query(FavStar).filter_by( class_name=class_name, obj_id=obj_id, user_id=g.us...
[ "Toggle", "favorite", "stars", "on", "Slices", "and", "Dashboard" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2142-L2167
[ "def", "favstar", "(", "self", ",", "class_name", ",", "obj_id", ",", "action", ")", ":", "session", "=", "db", ".", "session", "(", ")", "FavStar", "=", "models", ".", "FavStar", "# noqa", "count", "=", "0", "favs", "=", "session", ".", "query", "("...
ca2996c78f679260eb79c6008e276733df5fb653
train
Superset.dashboard
Server side rendering for a dashboard
superset/views/core.py
def dashboard(self, dashboard_id): """Server side rendering for a dashboard""" session = db.session() qry = session.query(models.Dashboard) if dashboard_id.isdigit(): qry = qry.filter_by(id=int(dashboard_id)) else: qry = qry.filter_by(slug=dashboard_id) ...
def dashboard(self, dashboard_id): """Server side rendering for a dashboard""" session = db.session() qry = session.query(models.Dashboard) if dashboard_id.isdigit(): qry = qry.filter_by(id=int(dashboard_id)) else: qry = qry.filter_by(slug=dashboard_id) ...
[ "Server", "side", "rendering", "for", "a", "dashboard" ]
apache/incubator-superset
python
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/views/core.py#L2171-L2246
[ "def", "dashboard", "(", "self", ",", "dashboard_id", ")", ":", "session", "=", "db", ".", "session", "(", ")", "qry", "=", "session", ".", "query", "(", "models", ".", "Dashboard", ")", "if", "dashboard_id", ".", "isdigit", "(", ")", ":", "qry", "="...
ca2996c78f679260eb79c6008e276733df5fb653