Skip to content

Commit

Permalink
[Gh 1570] feature flag for table metrics (#1574)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
- Feature


### Detail

Using existing functions like is_feature_enabled to enabled / disable
use of metrics and associated profiling jobs.

### Relates

- #1570

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)? N/A
  - Is the input sanitized? 
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization? N/A
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features? No
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users? No
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: trajopadhye <tejas.rajopadhye@yahooinc.com>
  • Loading branch information
TejasRGitHub and trajopadhye authored Sep 25, 2024
1 parent 2005863 commit 6500916
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json

from dataall.base.feature_toggle_checker import is_feature_enabled
from dataall.core.permissions.services.resource_policy_service import ResourcePolicyService
from dataall.core.tasks.service_handlers import Worker
from dataall.base.context import get_context
Expand All @@ -22,6 +23,7 @@
class DatasetProfilingService:
@staticmethod
@ResourcePolicyService.has_resource_permission(PROFILE_DATASET_TABLE)
@is_feature_enabled('modules.s3_datasets.features.metrics_data')
def start_profiling_run(uri, table_uri, glue_table_name):
context = get_context()
with context.db_engine.scoped_session() as session:
Expand Down Expand Up @@ -55,6 +57,7 @@ def start_profiling_run(uri, table_uri, glue_table_name):
return run

@staticmethod
@is_feature_enabled('modules.s3_datasets.features.metrics_data')
def resolve_profiling_run_status(run_uri):
context = get_context()
with context.db_engine.scoped_session() as session:
Expand All @@ -64,11 +67,13 @@ def resolve_profiling_run_status(run_uri):

@staticmethod
@ResourcePolicyService.has_resource_permission(GET_DATASET)
@is_feature_enabled('modules.s3_datasets.features.metrics_data')
def list_profiling_runs(uri):
with get_context().db_engine.scoped_session() as session:
return DatasetProfilingRepository.list_profiling_runs(session, uri)

@classmethod
@is_feature_enabled('modules.s3_datasets.features.metrics_data')
def get_dataset_table_profiling_run(cls, uri: str):
with get_context().db_engine.scoped_session() as session:
cls._check_preview_permissions_if_needed(session, table_uri=uri)
Expand All @@ -94,6 +99,7 @@ def get_dataset_table_profiling_run(cls, uri: str):
return run

@classmethod
@is_feature_enabled('modules.s3_datasets.features.metrics_data')
def list_table_profiling_runs(cls, uri: str):
with get_context().db_engine.scoped_session() as session:
cls._check_preview_permissions_if_needed(session=session, table_uri=uri)
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"aws_actions": true,
"preview_data": true,
"glue_crawler": true,
"metrics_data": true,
"show_stack_logs": "enabled"
}
},
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/modules/Tables/views/TableView.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { isFeatureEnabled } from 'utils';
import config from '../../../generated/config.json';

const previewDataEnabled = isFeatureEnabled('s3_datasets', 'preview_data');
const metricsEnabled = isFeatureEnabled('s3_datasets', 'metrics_data');

const confidentialityOptionsDict =
config.modules.datasets_base.features.confidentiality_dropdown === true &&
Expand Down Expand Up @@ -195,7 +196,7 @@ const TableView = () => {
if (!tabs.find((t) => t.value === 'columns')) {
tabs.push({ label: 'Columns', value: 'columns' });
}
if (!tabs.find((t) => t.value === 'metrics')) {
if (metricsEnabled && !tabs.find((t) => t.value === 'metrics')) {
tabs.push({ label: 'Metrics', value: 'metrics' });
}
if (
Expand Down Expand Up @@ -310,7 +311,7 @@ const TableView = () => {
{currentTab === 'columns' && (
<TableColumns table={table} isAdmin={isAdmin} />
)}
{currentTab === 'metrics' && (
{metricsEnabled && currentTab === 'metrics' && (
<TableMetrics table={table} isAdmin={isAdmin} />
)}
{currentTab === 'datafilters' && isAdmin && (
Expand Down

0 comments on commit 6500916

Please sign in to comment.