Skip to content

Commit

Permalink
use the DataSpace analytics result to bypass reading the connection w…
Browse files Browse the repository at this point in the history
…hen using PMCD to load the minimal graph (#3508)
  • Loading branch information
YannanGao-gs authored Sep 16, 2024
1 parent 2f4227b commit ec76548
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-snakes-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-extension-dsl-data-space': patch
---

Use the DataSpace analytics result to bypass reading the connection when using PMCD to load the minimal graph
3 changes: 3 additions & 0 deletions .changeset/cool-jars-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-application-query': patch
---
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { type QueryEditorStore } from '../../stores/QueryEditorStore.js';
import {
type DataSpace,
type DataSpaceExecutionContext,
DataSpaceQueryBuilderState,
DataSpaceSupportEmail,
} from '@finos/legend-extension-dsl-data-space/graph';
import {
Expand Down Expand Up @@ -93,12 +94,36 @@ export const QueryEditorDataspaceInfoModal = observer(
}
};

const dataSpaceAnalysisResult =
editorStore.queryBuilderState instanceof DataSpaceQueryBuilderState
? editorStore.queryBuilderState.dataSpaceAnalysisResult
: undefined;
const dataSpaceMedata = dataSpaceAnalysisResult?.executionContextsIndex.get(
executionContext.name,
)?.runtimeMetadata;
const connection =
executionContext.defaultRuntime.value.runtimeValue.connections[0]
?.storeConnections[0]?.connection instanceof ConnectionPointer
executionContext.defaultRuntime.value.runtimeValue.connections.length > 0
? executionContext.defaultRuntime.value.runtimeValue.connections[0]
?.storeConnections[0]?.connection
?.storeConnections?.[0]?.connection instanceof ConnectionPointer
? executionContext.defaultRuntime.value.runtimeValue.connections[0]
?.storeConnections?.[0]?.connection
: undefined
: undefined;
const connectionPath = connection
? connection.packageableConnection.value.path
: dataSpaceMedata
? dataSpaceMedata.connectionPath
: undefined;
const connectionType =
connection &&
connection.packageableConnection.value.connectionValue instanceof
RelationalDatabaseConnection
? connection.packageableConnection.value.connectionValue.type
: dataSpaceMedata
? dataSpaceMedata.connectionType
: undefined;
const storePath =
connection?.store?.value.path ?? dataSpaceMedata?.storePath;

const openInTaxonomy = (): void => {
if (
Expand Down Expand Up @@ -209,24 +234,20 @@ export const QueryEditorDataspaceInfoModal = observer(
{executionContext.defaultRuntime.value.name}
</div>
</div>
{connection && (
{(connection || dataSpaceMedata) && (
<>
{connection.store && (
{storePath && (
<div className="dataspace-info-modal__field">
<div className="dataspace-info-modal__field__label">
Store
</div>
<div
className="dataspace-info-modal__field__value dataspace-info-modal__field__value--linkable"
onClick={() => {
if (connection.store) {
flowResult(
visitElement(connection.store.value.path),
);
}
flowResult(visitElement(storePath));
}}
>
{connection.store.value.name}
{connection?.store?.value.name ?? storePath}
</div>
</div>
)}
Expand All @@ -236,18 +257,23 @@ export const QueryEditorDataspaceInfoModal = observer(
</div>
<div
className="dataspace-info-modal__field__value dataspace-info-modal__field__value--linkable"
onClick={() =>
flowResult(
visitElement(
connection.packageableConnection.value.path,
),
)
}
onClick={() => {
if (connectionPath) {
flowResult(visitElement(connectionPath));
}
}}
>
{connection.packageableConnection.value
{connection &&
connection.packageableConnection.value
.connectionValue instanceof RelationalDatabaseConnection
? `${connection.packageableConnection.value.name}:${connection.packageableConnection.value.connectionValue.type}`
: connection.packageableConnection.value.name}
: connection
? connection.packageableConnection.value.name
: connectionPath && connectionType
? `${connectionPath}:${connectionType}`
: connectionPath
? `${connectionPath}`
: `${connectionType}`}
</div>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export class DataSpaceExecutionContextAnalysisResult {
compatibleRuntimes!: PackageableRuntime[];
mappingModelCoverageAnalysisResult!: MappingModelCoverageAnalysisResult;
datasets: DatasetSpecification[] = [];
runtimeMetadata?: DataSpaceExecutionContextRuntimeMetadata;
}

export class DataSpaceExecutionContextRuntimeMetadata {
storePath?: string;
connectionPath?: string;
connectionType?: string;
}

export class DataSpaceTaggedValueInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
DataSpaceMultiExecutionServiceKeyedExecutableInfo,
DataSpaceTemplateExecutableInfo,
DataSpaceFunctionPointerExecutableInfo,
DataSpaceExecutionContextRuntimeMetadata,
} from '../../../action/analytics/DataSpaceAnalysis.js';
import { DSL_DataSpace_PureGraphManagerExtension } from '../DSL_DataSpace_PureGraphManagerExtension.js';
import {
Expand Down Expand Up @@ -412,6 +413,19 @@ export class V1_DSL_DataSpace_PureGraphManagerExtension extends DSL_DataSpace_Pu
contextAnalysisResult.defaultRuntime = graph.getRuntime(
context.defaultRuntime,
);
if (context.runtimeMetadata) {
const metadata = new DataSpaceExecutionContextRuntimeMetadata();
if (context.runtimeMetadata.storePath) {
metadata.storePath = context.runtimeMetadata.storePath;
}
if (context.runtimeMetadata.connectionPath) {
metadata.connectionPath = context.runtimeMetadata.connectionPath;
}
if (context.runtimeMetadata.connectionType) {
metadata.connectionType = context.runtimeMetadata.connectionType;
}
contextAnalysisResult.runtimeMetadata = metadata;
}
contextAnalysisResult.mappingModelCoverageAnalysisResult =
V1_buildModelCoverageAnalysisResult(
context.mappingModelCoverageAnalysisResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
import {
type V1_Multiplicity,
type V1_PureModelContextData,
V1_multiplicityModelSchema,
type V1_DatasetSpecification,
type PureProtocolProcessorPlugin,
V1_multiplicityModelSchema,
V1_deserializeDatasetSpecification,
V1_pureModelContextDataPropSchema,
V1_MappingModelCoverageAnalysisResult,
} from '@finos/legend-graph';
import {
type PlainObject,
SerializationFactory,
optionalCustom,
type PlainObject,
UnsupportedOperationError,
customListWithSchema,
usingConstantValueSchema,
Expand All @@ -37,6 +37,7 @@ import {
usingModelSchema,
} from '@finos/legend-shared';
import {
type ModelSchema,
createModelSchema,
custom,
deserialize,
Expand All @@ -45,7 +46,6 @@ import {
optional,
primitive,
SKIP,
type ModelSchema,
} from 'serializr';
import type { V1_DataSpaceSupportInfo } from '../../model/packageableElements/dataSpace/V1_DSL_DataSpace_DataSpace.js';
import { V1_deserializeSupportInfo } from '../../transformation/pureProtocol/V1_DSL_DataSpace_ProtocolHelper.js';
Expand Down Expand Up @@ -85,6 +85,21 @@ class V1_DataSpaceExecutionContextAnalysisResult {
compatibleRuntimes!: string[];
mappingModelCoverageAnalysisResult!: V1_MappingModelCoverageAnalysisResult;
datasets: V1_DatasetSpecification[] = [];
runtimeMetadata?: V1_DataSpaceExecutionContextRuntimeMetadata;
}

class V1_DataSpaceExecutionContextRuntimeMetadata {
storePath?: string;
connectionPath?: string;
connectionType?: string;

static readonly serialization = new SerializationFactory(
createModelSchema(V1_DataSpaceExecutionContextRuntimeMetadata, {
storePath: optional(primitive()),
connectionPath: optional(primitive()),
connectionType: optional(primitive()),
}),
);
}

const V1_dataSpaceExecutionContextAnalysisResultModelSchema = (
Expand All @@ -107,6 +122,9 @@ const V1_dataSpaceExecutionContextAnalysisResultModelSchema = (
mapping: primitive(),
name: primitive(),
title: optional(primitive()),
runtimeMetadata: usingModelSchema(
V1_DataSpaceExecutionContextRuntimeMetadata.serialization.schema,
),
});

export class V1_DataSpaceBasicDocumentationEntry {
Expand Down

0 comments on commit ec76548

Please sign in to comment.