From 0873375e69d660757dcf8551c9b0c2a66fc4f87c Mon Sep 17 00:00:00 2001 From: Jake Kim <60619826+jake-kim1@users.noreply.github.com> Date: Fri, 28 Jun 2024 18:55:55 -0400 Subject: [PATCH] Fix Service with milestoning elements in lambda (#2939) --- .../pure/compiler/toPureGraph/PureModel.java | 5 ++- .../ServiceCompilerExtensionImpl.java | 12 +++++++ .../TestServiceCompilationFromGrammar.java | 35 +++++++++++++++++++ ...TestLegendServicePostValidationRunner.java | 6 ++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java index d9fc523ea8d..fb779800e62 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-compiler/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/PureModel.java @@ -349,7 +349,10 @@ else if (cause instanceof RuntimeException) finally { span.finish(); - forkJoinPool.shutdown(); + if (this.pureModelProcessParameter.getForkJoinPool() == null) + { + forkJoinPool.shutdown(); + } } } diff --git a/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/main/java/org/finos/legend/engine/language/pure/dsl/service/compiler/toPureGraph/ServiceCompilerExtensionImpl.java b/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/main/java/org/finos/legend/engine/language/pure/dsl/service/compiler/toPureGraph/ServiceCompilerExtensionImpl.java index 70cfe9d699c..9aee7ec9b97 100644 --- a/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/main/java/org/finos/legend/engine/language/pure/dsl/service/compiler/toPureGraph/ServiceCompilerExtensionImpl.java +++ b/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/main/java/org/finos/legend/engine/language/pure/dsl/service/compiler/toPureGraph/ServiceCompilerExtensionImpl.java @@ -84,6 +84,18 @@ public Iterable> getExtraProcessors() Lists.fixedSize.with(PackageableConnection.class, PackageableRuntime.class, DataElement.class, ExecutionEnvironmentInstance.class, DataSpace.class), (service, context) -> processserviceFirstPass(service, context), (service, context) -> + { + + }, + (service, context) -> + { + + }, + (service, context) -> + { + + }, + (service, context) -> { Root_meta_legend_service_metamodel_Service pureService = (Root_meta_legend_service_metamodel_Service) context.pureModel.getOrCreatePackage(service._package)._children().detect(c -> service.name.equals(c._name())); diff --git a/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestServiceCompilationFromGrammar.java b/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestServiceCompilationFromGrammar.java index 094fa8633c1..0ec8b1ee38a 100644 --- a/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestServiceCompilationFromGrammar.java +++ b/legend-engine-xts-service/legend-engine-language-pure-dsl-service/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestServiceCompilationFromGrammar.java @@ -893,6 +893,41 @@ public void testServiceCompilationWithOnlyLambda() "}\n"); } + @Test + public void testServiceCompilationWithMilestoningElements() + { + String resource = "" + + "Class <> test::class\n" + + "{\n" + + " prop1 : test::class2[0..1];\n" + + "}\n" + + "Class <> test::class2\n" + + "{\n" + + " prop1 : Integer[0..1];\n" + + "}\n"; + + test(resource + "###Service\n" + + "Service test::Service\n" + + "{\n" + + " pattern: 'url/myUrl/';\n" + + " owners: ['ownerName', 'ownerName2'];\n" + + " documentation: 'test';\n" + + " autoActivateUpdates: true;\n" + + " execution: Single\n" + + " {\n" + + " query: |test::class.allVersions()->project(x | $x.prop1AllVersions.prop1, 'hello');\n" + + " }\n" + + " test: Single\n" + + " {\n" + + " data: 'moreThanData';\n" + + " asserts:\n" + + " [\n" + + " { [], res: meta::pure::mapping::Result[1]|$res.values->toOne()->size() == 1 }\n" + + " ];\n" + + " }\n" + + "}\n"); + } + @Test public void testServiceWithImport() { diff --git a/legend-engine-xts-service/legend-engine-service-post-validation-runner/src/test/java/org/finos/legend/engine/service/post/validation/runner/TestLegendServicePostValidationRunner.java b/legend-engine-xts-service/legend-engine-service-post-validation-runner/src/test/java/org/finos/legend/engine/service/post/validation/runner/TestLegendServicePostValidationRunner.java index f3378f7c300..cb723f5bb85 100644 --- a/legend-engine-xts-service/legend-engine-service-post-validation-runner/src/test/java/org/finos/legend/engine/service/post/validation/runner/TestLegendServicePostValidationRunner.java +++ b/legend-engine-xts-service/legend-engine-service-post-validation-runner/src/test/java/org/finos/legend/engine/service/post/validation/runner/TestLegendServicePostValidationRunner.java @@ -20,8 +20,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import org.eclipse.collections.impl.utility.LazyIterate; import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableElementFifthPassBuilder; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableElementFirstPassBuilder; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableElementFourthPassBuilder; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableElementSecondPassBuilder; +import org.finos.legend.engine.language.pure.compiler.toPureGraph.PackageableElementThirdPassBuilder; import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel; import org.finos.legend.engine.plan.execution.PlanExecutor; import org.finos.legend.engine.plan.execution.result.serialization.SerializationFormat; @@ -107,6 +110,9 @@ public Root_meta_legend_service_metamodel_Service compileService(Service service Root_meta_legend_service_metamodel_Service compiledService = (Root_meta_legend_service_metamodel_Service) service.accept(new PackageableElementFirstPassBuilder(compileContext)); service.accept(new PackageableElementSecondPassBuilder(compileContext)); + service.accept(new PackageableElementThirdPassBuilder(compileContext)); + service.accept(new PackageableElementFourthPassBuilder(compileContext)); + service.accept(new PackageableElementFifthPassBuilder(compileContext)); return compiledService; }