Git Product home page Git Product logo

Comments (7)

adamecr avatar adamecr commented on May 26, 2024 1

Hello Radoslaw,
I think that just chaning the DMN parsing version to V1_3ext will solve your problem. The way how the DMN XML has been designed, corresponds to that version of parser.

I did try also with your application (just tweaked a bit the repository service, so I don't need to use the DB and keep the uploaded definitions just in DI singleton object) and it worked.
dmnok1
dmnok2

Hope this help

from common.dmn.engine.

rmerkx avatar rmerkx commented on May 26, 2024 1

You are awesome! Thanks a lot. Your engine works like a charm.

from common.dmn.engine.

rmerkx avatar rmerkx commented on May 26, 2024

KWS30_Inkomen_Bepaal inkomens toetsnorm v0.12.dmn.txt
image

from common.dmn.engine.

rmerkx avatar rmerkx commented on May 26, 2024

In order to reproduce the exception call the enigine in NET 6 with the following input parameters set as follows:

Decision = "Bepaal inkomens toetsnorm"

inputvar = value:
beleidsvrijheid_PW_normpercentage = 90
beleidsvrijheid_AOW_normenkader = "PW"
aanvrager_AOW = "ja"
partner_AOW = "nee"
aantal_kostendelers = 2
leefvorm = "Gehuwd/samenwonend"

from common.dmn.engine.

adamecr avatar adamecr commented on May 26, 2024

Hello Radoslaw,
thanks for your feedback.

I had a quick check and will need some additional clarification from you.

The DMN Engine library (both project and nuget) is netstandard 2.0, but I'm not sure what do you mean when saying that the decision is "executed in netstandard 2.0". When the DMN Engine lib is referenced/imported in an executable project, the runtime (for example .net 5 or .net 6) is set in that project. So I would say you never execute "netstandard 2.0" as it's not a .net runtime.

I did try to open your DMN file in DMN Simulator that uses .NET 6 runtime. I executed the decision as described in the comment above and I think it worked fine as you can see on the image below.

Could you please provide me more details how do you

  • set the executable project - what typ of app and what runtime do you use
  • use the DMN Engine library - import nuget, include clonned project, or copied the code into executable project, etc.
  • parse the DMN - what parser method/version. Meaning how do you get dmnModel before calling DmnDefinitionFactory.CreateDmnDefinition(dmnModel). For example dmnModel = DmnParser.Parse13ext(fileFullName);
  • configure the execution context when calling DmnExecutionContextFactory.CreateExecutionContext (if applicable)

Thanks in advance
Radek

dmn-18

cc @rmerkx

from common.dmn.engine.

rmerkx avatar rmerkx commented on May 26, 2024

Hi Radek,
Thanks for the quick reply! I am calling the engine from a Net.6 application, which is now attached to this issue. It doesn't matter if I reference the nuget package or clone the project, in both cases on executing the DMN (Definition generation gave no error) with the same inputs you tried yourself results in an expression being invalidated concerning input parameter 'aantal_kostendelers', which should be interpreted as integer but appears not to be. I will give detailed steps to reproduce.

I use almost the same way of parsing the definition and making the executioncontext as done in DmnService.cs in the Simulator, with small differences. The idea is to create a webservice which can receive any DMN's to store for execution later. Once stored a get operation is used to execute the specific DMN by supplying the parameters in a json request. So I first upload the DMN as base64 to the database and then retrieve the model like this, assuming decisionModel.DecisionModelFile holds the base64 file content of the DMN:

byte[] data = Convert.FromBase64String(decisionModel.DecisionModelFile); string dmnDefinition = Encoding.UTF8.GetString(data); var dmnModel = DmnParser.ParseString(dmnDefinition, decisionModel.DmnVersion);

The version used here is DmnVersionEnum.V1_3. Please see DecisionModelRepository.cs for actual implementation.

Creation of the context and execution is also implemented inspired by the Simulator approach. Please chekc out DecisionModelEngineService.cs

DmnExecutionContext? ctx = null; ctx = DmnExecutionContextFactory.CreateExecutionContext(definition, o => { o.RecordSnapshots = true; o.ParsedExpressionCacheScope = ParsedExpressionCacheScopeEnum.Execution; });

ctx.WithInputParameter(inputVeld.Key, inputVeldWaarde.Item2);

ctx!.ExecuteDecision(decisionName);

I will detail the steps to run this DMN in the attached service below. Please don't hesitate if more is needed. Your help is much appreciated!

Best regards,
Radoslaw ([email protected])

from common.dmn.engine.

rmerkx avatar rmerkx commented on May 26, 2024

post_a_dmn

execute_the_dmn

post_request _to_upload_dmn_to_database.json.txt

IB.DMN.EngineService.zip.txt

Once you have the solution IB.DMN.EngineService.sln open in VS please follow these steps:

  1. The tool requires a MSSQL database server to store the DMN. You can change the connection string in appsettings.json. It uses Entity Framework to create the database. To create set the service project as your startup project and run in package manager console: dotnet ef database update

  2. Assuming you have a database you can now run the service and POST the attached request to upload the DMN.

  3. Once the DMN is available in the database you can send attached GET request to execute the DMN with the same values as you did in the example execution above.

curl -X 'GET' \
  'https://localhost:7036/DecisionModelEngine?Name=name1&Version=version1&Product=KWS&InputValues=beleidsvrijheid_PW_normpercentage&InputValues=90&InputValues=beleidsvrijheid_AOW_normenkader&InputValues=PW&InputValues=aanvrager_AOW&InputValues=ja&InputValues=partner_AOW&InputValues=nee&InputValues=aantal_kostendelers&InputValues=2&InputValues=leefvorm&InputValues=Gehuwd%2Fsamenwonend&Decision=Bepaal%20inkomens%20toetsnorm' \
  -H 'accept: text/plain'

Also see the screenshots if you prefer to use the Swagger interface.

The response shows the exception:
(Exception while parsing the expression aantal kostendelers> 0) (Exception while parsing the expression aantal kostendelers==0)\r\n", "outputValues": null }

from common.dmn.engine.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.