Skip to content

Commit

Permalink
- Added feature as a resource type
Browse files Browse the repository at this point in the history
- Code cleanup

Signed-off-by: Daniel Won <dwon@lyft.com>
  • Loading branch information
Daniel Won committed Jun 4, 2021
1 parent 5e16b53 commit 03fe676
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 11 deletions.
41 changes: 41 additions & 0 deletions frontend/amundsen_application/static/js/config/config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,47 @@ const configDefault: AppConfig = {
],
notices: {},
},
[ResourceType.feature]: {
displayName: 'ML Features',
supportedSources: {
bigquery: {
displayName: 'BigQuery',
iconClass: 'icon-bigquery',
},
delta: {
displayName: 'Delta',
iconClass: 'icon-delta',
},
dremio: {
displayName: 'Dremio',
iconClass: 'icon-dremio',
},
druid: {
displayName: 'Druid',
iconClass: 'icon-druid',
},
hive: {
displayName: 'Hive',
iconClass: 'icon-hive',
},
presto: {
displayName: 'Presto',
iconClass: 'icon-presto',
},
postgres: {
displayName: 'Postgres',
iconClass: 'icon-postgres',
},
redshift: {
displayName: 'Redshift',
iconClass: 'icon-redshift',
},
snowflake: {
displayName: 'Snowflake',
iconClass: 'icon-snowflake',
},
},
},
[ResourceType.table]: {
displayName: 'Datasets',
supportedSources: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ interface ResourceConfig {
[ResourceType.dashboard]: BaseResourceConfig;
[ResourceType.table]: TableResourceConfig;
[ResourceType.user]: BaseResourceConfig;
[ResourceType.feature]: BaseResourceConfig;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FeatureMetadata } from 'interfaces/Feature';

export type GetFeatureAPI = {
msg: string;
feature: FeatureMetadata;
featureData: FeatureMetadata;
};

const FEATURE_BASE = '/api/metadata/v0';
Expand All @@ -17,7 +17,7 @@ export function getFeature(key: string, index?: string, source?: string) {
.then((response: AxiosResponse<GetFeatureAPI>) => {
const { data, status } = response;
return {
feature: data.feature,
feature: data.featureData,
statusCode: status,
};
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { GetFeature } from './types';

export function* getFeatureWorker(action): SagaIterator {
try {
const { uri, searchIndex, source } = action.payload;
const response = yield call(API.getFeature, uri, searchIndex, source);
const { key, searchIndex, source } = action.payload;
const response = yield call(API.getFeature, key, searchIndex, source);

yield put(getFeatureSuccess(response));
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface FeatureMetadata {
partition_column?: TableColumn;
}

// TODO - duplicated with FeatureResource in Resources.ts. Might delete this.
export interface FeatureSummary {
key: string;
name: string;
Expand Down
11 changes: 11 additions & 0 deletions frontend/amundsen_application/static/js/interfaces/Resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ResourceType {
user = 'user',
dashboard = 'dashboard',
query = 'query',
feature = 'feature',
}

export const DEFAULT_RESOURCE_TYPE = ResourceType.table;
Expand All @@ -30,6 +31,16 @@ export interface DashboardResource extends Resource {
badges?: Badge[];
}

export interface FeatureResource extends Resource {
type: ResourceType.feature;
key: string;
name: string;
version: string;
availability: string[];
entity?: string[];
description: string;
}

export interface TableResource extends Resource {
type: ResourceType.table;
cluster: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { GetFeatureRequest } from 'ducks/feature/types';
import Breadcrumb from 'components/Breadcrumb';
import { getLoggingParams } from 'utils/logUtils';
import { formatDateTimeShort } from 'utils/dateUtils';
import { getSourceDisplayName } from 'config/config-utils';
import { ResourceType } from 'interfaces/Resources';

interface StateFromProps {
isLoading: boolean;
Expand Down Expand Up @@ -67,14 +69,25 @@ const FeaturePage: React.FC<FeaturePageProps> = ({
if (isLoading) {
return null;
}
// @ts-ignore
const sourcesWithDisplay = feature.availability.map((source) =>
getSourceDisplayName(source, ResourceType.feature)
);
return (
<div className="resource-detail-layout dashboard-page">
<header className="resource-header">
<div className="header-section">
<section className="header-section">
<Breadcrumb />
<span className="icon icon-header icon-database" />
</div>
</section>
<section className="header-section">
<h1 className="header-title-text truncated" title={feature.name}>
{feature.name}
</h1>
<div className="text-body-w3">
Feature &bull;&nbsp;
{sourcesWithDisplay.join(', ')}
</div>
</section>
</header>
<article className="column-layout-1">
<aside className="left-panel">
Expand Down Expand Up @@ -108,10 +121,12 @@ const FeaturePage: React.FC<FeaturePageProps> = ({
</section>
</section>
<section className="right-panel">
<section className="metadata-section">
<h3 className="section-title text-title-w3">Partition Key</h3>
{feature.partition_column}
</section>
{feature.partition_column !== null && (
<section className="metadata-section">
<h3 className="section-title text-title-w3">Partition Key</h3>
{feature.partition_column}
</section>
)}
<section className="metadata-section">
<h3 className="section-title text-title-w3">version</h3>
{feature.version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ describe('render SourceLink', () => {
[ResourceType.dashboard]: {
displayName: 'Dashboards',
},
[ResourceType.feature]: {
displayName: 'ML Features',
},
[ResourceType.user]: {
displayName: 'Users',
},
Expand Down

0 comments on commit 03fe676

Please sign in to comment.