Skip to content

Commit

Permalink
types and shiz
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Jan 10, 2024
1 parent 965587b commit ce75e38
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 1,928 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const AssetSidebarActivitySummary = ({
flex={{direction: 'row', gap: 4, alignItems: 'center'}}
>
<Link to={assetDetailsPathForKey(asset.assetKey, {view: 'automation'})}>
View auto-materialize history
View automation history
</Link>
<Icon name="open_in_new" color={colorLinkDefault()} />
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Box, colorTextLight} from '@dagster-io/ui-components';
import {Box, Spinner, colorTextLight} from '@dagster-io/ui-components';
import * as React from 'react';
import styled from 'styled-components';

Expand Down Expand Up @@ -60,6 +60,17 @@ export const AssetAutomaterializePolicyPage = ({
return evaluations.find((evaluation) => evaluation.evaluationId === selectedEvaluationId);
}, [selectedEvaluationId, isFirstPage, evaluations]);

if (!queryResult.data && queryResult.loading) {
return (
<Box
style={{height: 390}}
flex={{direction: 'row', justifyContent: 'center', alignItems: 'center'}}
>
<Spinner purpose="page" />
</Box>
);
}

return (
<AutomaterializePage
style={{flex: 1, minHeight: 0, color: colorTextLight(), overflow: 'hidden'}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import {DocumentNode} from 'graphql';

import {
AutoMaterializeDecisionType,
buildAssetConditionEvaluation,
buildAssetConditionEvaluationRecord,
buildAssetConditionEvaluationRecords,
buildAssetKey,
buildAssetNode,
buildAutoMaterializeAssetEvaluationRecord,
buildAutoMaterializeAssetEvaluationRecords,
buildAutoMaterializePolicy,
buildAutoMaterializeRule,
buildAutoMaterializeRuleEvaluation,
buildAutoMaterializeRuleWithRuleEvaluations,
buildParentMaterializedRuleEvaluationData,
buildPartitionKeys,
buildUnpartitionedAssetConditionEvaluationNode,
} from '../../../graphql/types';
import {GET_EVALUATIONS_QUERY} from '../GetEvaluationsQuery';
import {
Expand Down Expand Up @@ -69,91 +71,76 @@ export const TEST_EVALUATION_ID = 27;
export const buildEvaluationRecordsWithPartitions = () => {
const now = Date.now();
return [
buildAutoMaterializeAssetEvaluationRecord({
id: 'g',
evaluationId: TEST_EVALUATION_ID,
timestamp: (now - ONE_MINUTE * 6) / 1000,
buildAssetConditionEvaluationRecord({
numRequested: 2,
numSkipped: 2,
numDiscarded: 2,
}),
buildAutoMaterializeAssetEvaluationRecord({
evaluation: buildAssetConditionEvaluation({
rootUniqueId: '1',
evaluationNodes: [
buildUnpartitionedAssetConditionEvaluationNode({
uniqueId: '1',
}),
],
}),
}) as any,
buildAssetConditionEvaluationRecord({
id: 'f',
evaluationId: 24,
timestamp: (now - ONE_MINUTE * 5) / 1000,
numRequested: 2,
numSkipped: 2,
numDiscarded: 0,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'e',
evaluationId: 20,
timestamp: (now - ONE_MINUTE * 4) / 1000,
numRequested: 0,
numSkipped: 2410,
numDiscarded: 3560,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'd',
evaluationId: 13,
timestamp: (now - ONE_MINUTE * 3) / 1000,
numRequested: 2,
numSkipped: 0,
numDiscarded: 2,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'c',
timestamp: (now - ONE_MINUTE * 2) / 1000,
evaluationId: 12,
numRequested: 0,
numSkipped: 0,
numDiscarded: 2,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'b',
evaluationId: 4,
timestamp: (now - ONE_MINUTE) / 1000,
numRequested: 0,
numSkipped: 2,
numDiscarded: 0,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'a',
evaluationId: 0,
timestamp: now / 1000,
numRequested: 2,
numSkipped: 0,
numDiscarded: 0,
}),
];
};

export const buildEvaluationRecordsWithoutPartitions = () => {
const now = Date.now();
return [
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'g',
evaluationId: TEST_EVALUATION_ID,
timestamp: (now - ONE_MINUTE * 6) / 1000,
numRequested: 1,
numSkipped: 0,
numDiscarded: 0,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'f',
evaluationId: 24,
timestamp: (now - ONE_MINUTE * 5) / 1000,
numRequested: 0,
numSkipped: 1,
numDiscarded: 0,
}),
buildAutoMaterializeAssetEvaluationRecord({
buildAssetConditionEvaluationRecord({
id: 'e',
evaluationId: 20,
timestamp: (now - ONE_MINUTE * 4) / 1000,
numRequested: 0,
numSkipped: 0,
numDiscarded: 1,
}),
];
};
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';

import {AutoMaterializePolicyType} from '../../../graphql/types';
import {AssetAutomaterializePolicyPage} from '../AssetAutomaterializePolicyPage';
import {Evaluations, Policies} from '../__fixtures__/AutoMaterializePolicyPage.fixtures';
import {Evaluations} from '../__fixtures__/AutoMaterializePolicyPage.fixtures';

// eslint-disable-next-line import/no-default-export
export default {
Expand All @@ -16,24 +16,16 @@ const path = ['test'];

export const EmptyState = () => {
return (
<MockedProvider
mocks={[Policies.NoAutomaterializeNoFreshnessPolicy(path), Evaluations.None(path, true)]}
>
<AssetAutomaterializePolicyPage assetKey={{path}} assetHasDefinedPartitions />
<MockedProvider mocks={[Evaluations.None(path, true)]}>
<AssetAutomaterializePolicyPage assetKey={{path}} />
</MockedProvider>
);
};

export const Errors = () => {
return (
<MockedProvider
mocks={[
Evaluations.Errors(path),
Evaluations.Errors(path, true),
Policies.NoAutomaterializeNoFreshnessPolicy(path),
]}
>
<AssetAutomaterializePolicyPage assetKey={{path}} assetHasDefinedPartitions />
<MockedProvider mocks={[Evaluations.Errors(path), Evaluations.Errors(path, true)]}>
<AssetAutomaterializePolicyPage assetKey={{path}} />
</MockedProvider>
);
};
Expand All @@ -42,23 +34,10 @@ export const Controlled = () => {
const [policyType, setPolicyType] = React.useState<any>(AutoMaterializePolicyType.EAGER);
const [freshnessPolicy, setFreshnessPolicy] = React.useState(true);

const policyMock = React.useMemo(() => {
if (policyType === 'None') {
return freshnessPolicy
? Policies.NoAutomaterializeYesFreshnessPolicy(path)
: Policies.NoAutomaterializeNoFreshnessPolicy(path);
} else {
return freshnessPolicy
? Policies.YesAutomaterializeYesFreshnessPolicy(path, policyType)
: Policies.NoAutomaterializeYesFreshnessPolicy(path);
}
}, [freshnessPolicy, policyType]);

return (
<div key={policyType + freshnessPolicy.toString()}>
<div key={freshnessPolicy.toString()}>
<MockedProvider
mocks={[
policyMock,
Evaluations.Some(path),
Evaluations.SinglePartitioned(path, '9798'),
Evaluations.SinglePartitioned(path, '28'),
Expand Down Expand Up @@ -88,7 +67,7 @@ export const Controlled = () => {
/>
</JoinedButtons>
</Box>
<AssetAutomaterializePolicyPage assetKey={{path}} assetHasDefinedPartitions />
<AssetAutomaterializePolicyPage assetKey={{path}} />
</div>
</MockedProvider>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
buildEvaluationRecordsWithPartitions,
buildEvaluationRecordsWithoutPartitions,
} from '../__fixtures__/AutoMaterializePolicyPage.fixtures';
import {AutoMaterializeEvaluationRecordItemFragment} from '../types/GetEvaluationsQuery.types';
import {AssetConditionEvaluationRecordFragment} from '../types/GetEvaluationsQuery.types';

// eslint-disable-next-line import/no-default-export
export default {
Expand All @@ -15,17 +15,16 @@ export default {

export const WithPartitions = () => {
const [selectedEvaluation, setSelectedEvaluation] = React.useState<
AutoMaterializeEvaluationRecordItemFragment | undefined
AssetConditionEvaluationRecordFragment | undefined
>();

const evaluations = buildEvaluationRecordsWithPartitions();

return (
<div style={{width: '320px'}}>
<AutomaterializeLeftList
assetHasDefinedPartitions
evaluations={evaluations}
onSelectEvaluation={(evaluation: AutoMaterializeEvaluationRecordItemFragment) =>
onSelectEvaluation={(evaluation: AssetConditionEvaluationRecordFragment) =>
setSelectedEvaluation(evaluation)
}
selectedEvaluation={selectedEvaluation}
Expand All @@ -36,17 +35,16 @@ export const WithPartitions = () => {

export const NoPartitions = () => {
const [selectedEvaluation, setSelectedEvaluation] = React.useState<
AutoMaterializeEvaluationRecordItemFragment | undefined
AssetConditionEvaluationRecordFragment | undefined
>();

const evaluations = buildEvaluationRecordsWithoutPartitions();

return (
<div style={{width: '320px'}}>
<AutomaterializeLeftList
assetHasDefinedPartitions={false}
evaluations={evaluations}
onSelectEvaluation={(evaluation: AutoMaterializeEvaluationRecordItemFragment) =>
onSelectEvaluation={(evaluation: AssetConditionEvaluationRecordFragment) =>
setSelectedEvaluation(evaluation)
}
selectedEvaluation={selectedEvaluation}
Expand Down
Loading

0 comments on commit ce75e38

Please sign in to comment.