Popular New Releases in Rule Engine
easy-rules
v4.1.0
RulesEngine
v3.5.0
NRules
v0.9.2
grule-rule-engine
Releasing v1.10.4
node-rules
7.1.0
Popular Libraries in Rule Engine
by j-easy java
3296 MIT
The simple, stupid rules engine for Java
by microsoft csharp
1543 MIT
A Json based Rules Engine with extensive Dynamic expression support
by NRules csharp
1132 MIT
Rules engine for .NET, based on the Rete matching algorithm, with internal DSL in C#.
by hyperjumptech go
1111 NOASSERTION
Rule engine implementation in Golang
by noolsjs javascript
855 MIT
Rete based rules engine written in javascript
by venmo python
681 MIT
Python DSL for setting up business intelligence rules that can be configured without code
by hoaproject php
617
The Hoa\Ruler library.
by mithunsatheesh javascript
543 MIT
Node-rules is a light weight forward chaining rule engine written in JavaScript.
by ulfurinn ruby
419 MIT
A rule engine written in Ruby.
Trending New libraries in Rule Engine
by finos java
33 Apache-2.0
Legend Engine module
by ssh-mitm python
29 GPL-3.0
Python DSL for setting up business intelligence rules
by manfred-kaiser python
16 GPL-3.0
Python DSL for setting up business intelligence rules
by reflexivesecurity python
16 MPL-2.0
The core logic for Reflex rules.
by PwCUK-CTO python
15 Apache-2.0
Indicators of compromise, YARA rules, and Python scripts to supplement the SANS CTI Summit 2021 talk: "xStart when you're ready".
by aws-samples javascript
13 NOASSERTION
by JGefroh ruby
11
by pinussilvestrus javascript
10 MIT
Camunda Modeler plugin to import Excel Sheets to DMN 1.3 Decision Tables (and vice versa).
by adobe swift
9 Apache-2.0
A simple, generic, extensible Rules Engine in Swift
Top Authors in Rule Engine
1
2 Libraries
9
2
2 Libraries
84
3
2 Libraries
39
4
2 Libraries
92
5
2 Libraries
1189
6
2 Libraries
24
7
2 Libraries
32
8
2 Libraries
12
9
2 Libraries
6
10
2 Libraries
25
1
2 Libraries
9
2
2 Libraries
84
3
2 Libraries
39
4
2 Libraries
92
5
2 Libraries
1189
6
2 Libraries
24
7
2 Libraries
32
8
2 Libraries
12
9
2 Libraries
6
10
2 Libraries
25
Trending Kits in Rule Engine
No Trending Kits are available at this moment for Rule Engine
Trending Discussions on Rule Engine
Compile Statically Linked GO Executable for use in AWS Lambda
How to check an alternative of a token in ANTLR's visitor mode?
Problems with Dependencies Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory with Drools version 7.59.0
Why doesn't the Linux redirection operator capture the output of my command?
Ruby method returning as "undefined method `include?' for nil:NilClass (NoMethodError)"
AWS Step function - choice step - TimestampEquals matching with multiple input variables
how to prevent drools engine looping on entry point data
Firebase rule from the standard docs does not validate
pass arguments in dockerfile?
TopQuadrant Shacl Rule Engine Iterative inference
QUESTION
Compile Statically Linked GO Executable for use in AWS Lambda
Asked 2021-Dec-16 at 17:49Context: I am trying to compile a Go program (Specifically, the go-sigma-rule-engine by Markus Kont) to an executable so that I can upload it to AWS Lambda (which is Amazon Linux 2 under the hood I believe, according to this post.) and include/execute it via a Python Lambda function that issues shell/os commands to the rule engine program.
Problem: This program relies on many dependencies and for it to work with as few issues as possible I would like to statically link the program and compile, before uploading to AWS Lambda, so that all necessary dependencies are included within the executable itself.
Question: How do I statically link then compile a program in Go such that I target the AWS Lambda OS?
ANSWER
Answered 2021-Dec-16 at 17:49This can be done via GOOS=linux go build .
Go builds statically linked executables by default so as long as the correct OS is targeted, you will get a binary that runs fine on AWS Lambda without having to include any specific libraries in the deployment package.
QUESTION
How to check an alternative of a token in ANTLR's visitor mode?
Asked 2021-Nov-30 at 06:02I want to build a simple rule engine using ANTLR's visitor mode, but when it comes with alternative tokens, I get confused how to get which alternative is. Can anyone help me with that?(sorry of my poor English)
1grammar RuleExpression;
2expression: '(' Operator arg* ')';
3arg: STRING|INTEGER|BOOLEAN|expression;
4STRING: '"' .+ '"';
5INTEGER: [0-9]+;
6BOOLEAN: 'true'|'false';
7Operator: [a-zA-Z]+[0-9]*;
8WS : [ \t\r\n]+ -> skip;
9
How do know an arg is a STRING or INTEGER or BOOLEAN or expression?
ANSWER
Answered 2021-Nov-30 at 06:02[...] Is there some method which I can use switch statement?
You can inspect the context's start
token type:
1grammar RuleExpression;
2expression: '(' Operator arg* ')';
3arg: STRING|INTEGER|BOOLEAN|expression;
4STRING: '"' .+ '"';
5INTEGER: [0-9]+;
6BOOLEAN: 'true'|'false';
7Operator: [a-zA-Z]+[0-9]*;
8WS : [ \t\r\n]+ -> skip;
9@Override
10public Object visitArg(RuleExpressionParser.ArgContext ctx) {
11 switch (ctx.start.getType()) {
12 case RuleExpressionLexer.STRING:
13 return ...;
14 case RuleExpressionLexer.INTEGER:
15 return ...;
16 case RuleExpressionLexer.BOOLEAN:
17 return ...;
18 default:
19 // It was an `expression`
20 return super.visitExpression(ctx.expression());
21 }
22}
23
Or you could label the arg
alternatives:
1grammar RuleExpression;
2expression: '(' Operator arg* ')';
3arg: STRING|INTEGER|BOOLEAN|expression;
4STRING: '"' .+ '"';
5INTEGER: [0-9]+;
6BOOLEAN: 'true'|'false';
7Operator: [a-zA-Z]+[0-9]*;
8WS : [ \t\r\n]+ -> skip;
9@Override
10public Object visitArg(RuleExpressionParser.ArgContext ctx) {
11 switch (ctx.start.getType()) {
12 case RuleExpressionLexer.STRING:
13 return ...;
14 case RuleExpressionLexer.INTEGER:
15 return ...;
16 case RuleExpressionLexer.BOOLEAN:
17 return ...;
18 default:
19 // It was an `expression`
20 return super.visitExpression(ctx.expression());
21 }
22}
23arg
24 : STRING #StringArg
25 | INTEGER #IntegerArg
26 | BOOLEAN #BooleanArg
27 | expression #ExpressionArg
28 ;
29
which will cause the visitor to have the following methods:
1grammar RuleExpression;
2expression: '(' Operator arg* ')';
3arg: STRING|INTEGER|BOOLEAN|expression;
4STRING: '"' .+ '"';
5INTEGER: [0-9]+;
6BOOLEAN: 'true'|'false';
7Operator: [a-zA-Z]+[0-9]*;
8WS : [ \t\r\n]+ -> skip;
9@Override
10public Object visitArg(RuleExpressionParser.ArgContext ctx) {
11 switch (ctx.start.getType()) {
12 case RuleExpressionLexer.STRING:
13 return ...;
14 case RuleExpressionLexer.INTEGER:
15 return ...;
16 case RuleExpressionLexer.BOOLEAN:
17 return ...;
18 default:
19 // It was an `expression`
20 return super.visitExpression(ctx.expression());
21 }
22}
23arg
24 : STRING #StringArg
25 | INTEGER #IntegerArg
26 | BOOLEAN #BooleanArg
27 | expression #ExpressionArg
28 ;
29@Override
30public T visitStringArg(RuleExpressionParser.StringArgContext ctx) ...
31
32@Override
33public T visitIntegerArg(RuleExpressionParser.IntegerArgContext ctx) ...
34
35@Override
36public T visitBooleanArg(RuleExpressionParser.BooleanArgContext ctx) ...
37
38@Override
39public T visitExpressionArg(RuleExpressionParser.ExpressionArgContext ctx) ...
40
instead of the single T visitArg(RuleExpressionParser.ArgContext ctx)
method.
QUESTION
Problems with Dependencies Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory with Drools version 7.59.0
Asked 2021-Sep-30 at 19:24I just started learning Drools, but I'm having a bad time with it, I'm trying a simple project, but I'm getting this error.
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2
All suggestions of Stackoverflow and other discussion did not help. Does anyone have a solution? When I use mvn clean install is BUILD SUCCESS
This is my code
com.sample.App
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25
com.sample.model
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25package com.model;
26
27public class Item {
28 private String category;
29 private Float cost;
30
31 public Item(String category, Float cost) {
32 this.category = category;
33 this.cost = cost;
34 }
35
36 public String getCategory() {
37 return category;
38 }
39
40 public void setCategory(String category) {
41 this.category = category;
42 }
43
44 public Float getCost() {
45 return cost;
46 }
47
48 public void setCost(Float cost) {
49 this.cost = cost;
50 }
51}
52
This is my pom
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25package com.model;
26
27public class Item {
28 private String category;
29 private Float cost;
30
31 public Item(String category, Float cost) {
32 this.category = category;
33 this.cost = cost;
34 }
35
36 public String getCategory() {
37 return category;
38 }
39
40 public void setCategory(String category) {
41 this.category = category;
42 }
43
44 public Float getCost() {
45 return cost;
46 }
47
48 public void setCost(Float cost) {
49 this.cost = cost;
50 }
51}
52<?xml version="1.0" encoding="UTF-8"?>
53<project xmlns="http://maven.apache.org/POM/4.0.0"
54 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
56 <modelVersion>4.0.0</modelVersion>
57
58 <groupId>org.example</groupId>
59 <artifactId>DroolCmonDude2</artifactId>
60 <version>1.0-SNAPSHOT</version>
61
62 <properties>
63 <maven.compiler.source>11</maven.compiler.source>
64 <maven.compiler.target>11</maven.compiler.target>
65 </properties>
66
67 <dependencies>
68 <dependency>
69 <groupId>org.kie</groupId>
70 <artifactId>kie-api</artifactId>
71 <version>7.59.0.Final</version>
72 <scope>provided</scope>
73 </dependency>
74 <dependency>
75 <groupId>org.drools</groupId>
76 <artifactId>drools-core</artifactId>
77 <version>7.59.0.Final</version>
78 </dependency>
79 <dependency>
80 <groupId>org.drools</groupId>
81 <artifactId>drools-compiler</artifactId>
82 <version>7.59.0.Final</version>
83 </dependency>
84 <dependency>
85 <groupId>org.drools</groupId>
86 <artifactId>drools-decisiontables</artifactId>
87 <version>7.59.0.Final</version>
88 </dependency>
89 </dependencies>
90
91</project>
92
And my Rules.drl at resources.rules
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25package com.model;
26
27public class Item {
28 private String category;
29 private Float cost;
30
31 public Item(String category, Float cost) {
32 this.category = category;
33 this.cost = cost;
34 }
35
36 public String getCategory() {
37 return category;
38 }
39
40 public void setCategory(String category) {
41 this.category = category;
42 }
43
44 public Float getCost() {
45 return cost;
46 }
47
48 public void setCost(Float cost) {
49 this.cost = cost;
50 }
51}
52<?xml version="1.0" encoding="UTF-8"?>
53<project xmlns="http://maven.apache.org/POM/4.0.0"
54 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
56 <modelVersion>4.0.0</modelVersion>
57
58 <groupId>org.example</groupId>
59 <artifactId>DroolCmonDude2</artifactId>
60 <version>1.0-SNAPSHOT</version>
61
62 <properties>
63 <maven.compiler.source>11</maven.compiler.source>
64 <maven.compiler.target>11</maven.compiler.target>
65 </properties>
66
67 <dependencies>
68 <dependency>
69 <groupId>org.kie</groupId>
70 <artifactId>kie-api</artifactId>
71 <version>7.59.0.Final</version>
72 <scope>provided</scope>
73 </dependency>
74 <dependency>
75 <groupId>org.drools</groupId>
76 <artifactId>drools-core</artifactId>
77 <version>7.59.0.Final</version>
78 </dependency>
79 <dependency>
80 <groupId>org.drools</groupId>
81 <artifactId>drools-compiler</artifactId>
82 <version>7.59.0.Final</version>
83 </dependency>
84 <dependency>
85 <groupId>org.drools</groupId>
86 <artifactId>drools-decisiontables</artifactId>
87 <version>7.59.0.Final</version>
88 </dependency>
89 </dependencies>
90
91</project>
92package resources.rules;
93
94import com.model.Item;
95
96rule "Classify Item - Low Range"
97 when
98 $i: Item(cost < 200)
99 then
100 $i.setCategory(Category.LOW_RANGE);
101end
102
My kmodule.xml
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25package com.model;
26
27public class Item {
28 private String category;
29 private Float cost;
30
31 public Item(String category, Float cost) {
32 this.category = category;
33 this.cost = cost;
34 }
35
36 public String getCategory() {
37 return category;
38 }
39
40 public void setCategory(String category) {
41 this.category = category;
42 }
43
44 public Float getCost() {
45 return cost;
46 }
47
48 public void setCost(Float cost) {
49 this.cost = cost;
50 }
51}
52<?xml version="1.0" encoding="UTF-8"?>
53<project xmlns="http://maven.apache.org/POM/4.0.0"
54 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
56 <modelVersion>4.0.0</modelVersion>
57
58 <groupId>org.example</groupId>
59 <artifactId>DroolCmonDude2</artifactId>
60 <version>1.0-SNAPSHOT</version>
61
62 <properties>
63 <maven.compiler.source>11</maven.compiler.source>
64 <maven.compiler.target>11</maven.compiler.target>
65 </properties>
66
67 <dependencies>
68 <dependency>
69 <groupId>org.kie</groupId>
70 <artifactId>kie-api</artifactId>
71 <version>7.59.0.Final</version>
72 <scope>provided</scope>
73 </dependency>
74 <dependency>
75 <groupId>org.drools</groupId>
76 <artifactId>drools-core</artifactId>
77 <version>7.59.0.Final</version>
78 </dependency>
79 <dependency>
80 <groupId>org.drools</groupId>
81 <artifactId>drools-compiler</artifactId>
82 <version>7.59.0.Final</version>
83 </dependency>
84 <dependency>
85 <groupId>org.drools</groupId>
86 <artifactId>drools-decisiontables</artifactId>
87 <version>7.59.0.Final</version>
88 </dependency>
89 </dependencies>
90
91</project>
92package resources.rules;
93
94import com.model.Item;
95
96rule "Classify Item - Low Range"
97 when
98 $i: Item(cost < 200)
99 then
100 $i.setCategory(Category.LOW_RANGE);
101end
102<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
103 xmlns="http://jboss.org/kie/6.0.0/kmodule">
104</kmodule>
105
SOLUTION
As @RoddyoftheFrozenPeas indicated the solution was to add the dependencies for drools-mvel, drools-model-compiler and sfj4 and works. This is for Drools 7> This how my pom looks now:
1Exception in thread "main" java.lang.NoClassDefFoundError: org/kie/api/KieServices$Factory at com.sample.App.main(App.java:12)
2package com.sample;
3
4import com.model.Item;
5import org.kie.api.KieServices;
6import org.kie.api.runtime.KieContainer;
7import org.kie.api.runtime.KieSession;
8
9public class App {
10 public static void main(String[] args)
11 {
12 System.out.println("Rule engine");
13 KieServices ks = KieServices.Factory.get();
14 KieContainer kContainer = ks.getKieClasspathContainer();
15 KieSession kSession = kContainer.newKieSession();
16
17 Item item = new Item("A", (float) 123.35);
18 System.out.println("Item category: " + item.getCategory());
19 kSession.insert(item);
20 int fired = kSession.fireAllRules();
21 System.out.println("Number of Rules executed: " + fired);
22 System.out.println("Item Category: " + item.getCategory());
23 }
24}
25package com.model;
26
27public class Item {
28 private String category;
29 private Float cost;
30
31 public Item(String category, Float cost) {
32 this.category = category;
33 this.cost = cost;
34 }
35
36 public String getCategory() {
37 return category;
38 }
39
40 public void setCategory(String category) {
41 this.category = category;
42 }
43
44 public Float getCost() {
45 return cost;
46 }
47
48 public void setCost(Float cost) {
49 this.cost = cost;
50 }
51}
52<?xml version="1.0" encoding="UTF-8"?>
53<project xmlns="http://maven.apache.org/POM/4.0.0"
54 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
56 <modelVersion>4.0.0</modelVersion>
57
58 <groupId>org.example</groupId>
59 <artifactId>DroolCmonDude2</artifactId>
60 <version>1.0-SNAPSHOT</version>
61
62 <properties>
63 <maven.compiler.source>11</maven.compiler.source>
64 <maven.compiler.target>11</maven.compiler.target>
65 </properties>
66
67 <dependencies>
68 <dependency>
69 <groupId>org.kie</groupId>
70 <artifactId>kie-api</artifactId>
71 <version>7.59.0.Final</version>
72 <scope>provided</scope>
73 </dependency>
74 <dependency>
75 <groupId>org.drools</groupId>
76 <artifactId>drools-core</artifactId>
77 <version>7.59.0.Final</version>
78 </dependency>
79 <dependency>
80 <groupId>org.drools</groupId>
81 <artifactId>drools-compiler</artifactId>
82 <version>7.59.0.Final</version>
83 </dependency>
84 <dependency>
85 <groupId>org.drools</groupId>
86 <artifactId>drools-decisiontables</artifactId>
87 <version>7.59.0.Final</version>
88 </dependency>
89 </dependencies>
90
91</project>
92package resources.rules;
93
94import com.model.Item;
95
96rule "Classify Item - Low Range"
97 when
98 $i: Item(cost < 200)
99 then
100 $i.setCategory(Category.LOW_RANGE);
101end
102<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
103 xmlns="http://jboss.org/kie/6.0.0/kmodule">
104</kmodule>
105<?xml version="1.0" encoding="UTF-8"?>
106<project xmlns="http://maven.apache.org/POM/4.0.0"
107 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
108 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
109 <modelVersion>4.0.0</modelVersion>
110
111 <groupId>org.example</groupId>
112 <artifactId>DroolsAnotherChance</artifactId>
113 <version>1.0-SNAPSHOT</version>
114
115 <properties>
116 <maven.compiler.source>11</maven.compiler.source>
117 <maven.compiler.target>11</maven.compiler.target>
118 </properties>
119
120 <dependencies>
121 <dependency>
122 <groupId>org.drools</groupId>
123 <artifactId>drools-core</artifactId>
124 <version>7.59.0.Final</version>
125 </dependency>
126 <dependency>
127 <groupId>org.drools</groupId>
128 <artifactId>drools-compiler</artifactId>
129 <version>7.59.0.Final</version>
130 </dependency>
131 <dependency>
132 <groupId>org.drools</groupId>
133 <artifactId>drools-decisiontables</artifactId>
134 <version>7.59.0.Final</version>
135 </dependency>
136 <dependency>
137 <groupId>org.drools</groupId>
138 <artifactId>drools-mvel</artifactId>
139 <version>7.59.0.Final</version>
140 </dependency>
141 <dependency>
142 <groupId>org.drools</groupId>
143 <artifactId>drools-model-compiler</artifactId>
144 <version>7.59.0.Final</version>
145 </dependency>
146 <dependency>
147 <groupId>org.slf4j</groupId>
148 <artifactId>slf4j-api</artifactId>
149 <version>1.7.25</version>
150 </dependency>
151
152 <dependency>
153 <groupId>org.slf4j</groupId>
154 <artifactId>slf4j-nop</artifactId>
155 <version>1.7.25</version>
156 </dependency>
157 </dependencies>
158
159</project>
160
ANSWER
Answered 2021-Sep-30 at 19:24There was a non-backwards-compatible change to the Drools library introduced in 7.45. You can read about it in the documentation's release notes here.
Basically, starting in 7.45, the introduction of "executable models" caused mvel support to be broken out into a separate module. As a result you now need to include one of the following dependencies:
- drools-mvel-compiler
- drools-model-compiler
Which one you need depends on what you're actually doing. Prior to 7.45, the mvel compiler support was part of the drools-compiler dependency, so this extra dependency was not necessary.
(As a note, you don't need the kie-api
dependency.)
QUESTION
Why doesn't the Linux redirection operator capture the output of my command?
Asked 2021-Sep-22 at 22:12Context: I have a program (go-sigma-rule-engine by Markus Kont) on my EC2 instance that runs against a logfile and produces some output to screen.
The command used to run this program is ./gsre/go-sigma-rule-engine run --rules-dir ./gsre/rules/ --sigma-input ./logs/exampleLog.json
The program produces output of the form:
1INFO[2021-09-22T21:51:06Z] MATCH at offset 0 : [{[] Example Activity Found}]
2INFO[2021-09-22T21:51:06Z] All workers exited, waiting on loggers to finish
3INFO[2021-09-22T21:51:06Z] Stats logger done
4INFO[2021-09-22T21:51:06Z] Done
5
Goal: I would like to capture this output and store it in a file.
Attempted Solution: I used the redirection operator to capture the output like so:
./gsre/go-sigma-rule-engine run --rules-dir ./gsre/rules/ --sigma-input ./logs/exampleLog.json > output.txt
Problem: The output.txt
file is empty and didn't capture the output of the command invoking the rule engine.
ANSWER
Answered 2021-Sep-22 at 22:05Maybe the output you want to capture goes to standard error rather than standard output. Try using 2>
instead of >
to redirect stderr.
QUESTION
Ruby method returning as "undefined method `include?' for nil:NilClass (NoMethodError)"
Asked 2021-Sep-07 at 10:44Creating a rock, paper, scissors game with randomisation and a rule engine but the winner_is
method seems to be returning nil. I can't really figure out what the variables within it are returning since it still prints them fine before all the if conditions.
1class RPS
2
3 def initialize(guess:)
4 @guess = guess.capitalize
5 end
6
7 def rule_engine
8 {
9 'Rock': ['Scissors'],
10 'Paper': ['Rock'],
11 'Scissors': ['Paper']
12 }
13 end
14
15 def sys_guess
16 rand 12345
17 sys_guesses = %w{Rock Paper Scissors}
18 sys_guesses.sample
19 end
20
21 def winner_is
22 puts sys_guess
23 puts @guess
24
25 if rule_engine[sys_guess.to_sym].include? @guess
26 puts "Computer wins"
27 elsif rule_engine[@guess.to_sym].include? sys_guess
28 puts "You win!"
29 else
30 puts "Tie"
31 end
32 end
33end
34
35rps = RPS.new(guess: gets)
36rps.winner_is
37
ANSWER
Answered 2021-Sep-07 at 10:44Here's your problem:
1class RPS
2
3 def initialize(guess:)
4 @guess = guess.capitalize
5 end
6
7 def rule_engine
8 {
9 'Rock': ['Scissors'],
10 'Paper': ['Rock'],
11 'Scissors': ['Paper']
12 }
13 end
14
15 def sys_guess
16 rand 12345
17 sys_guesses = %w{Rock Paper Scissors}
18 sys_guesses.sample
19 end
20
21 def winner_is
22 puts sys_guess
23 puts @guess
24
25 if rule_engine[sys_guess.to_sym].include? @guess
26 puts "Computer wins"
27 elsif rule_engine[@guess.to_sym].include? sys_guess
28 puts "You win!"
29 else
30 puts "Tie"
31 end
32 end
33end
34
35rps = RPS.new(guess: gets)
36rps.winner_is
37 rps = RPS.new(guess: gets)
38
The string you get from gets
includes a trailing newline. Naturally, this key is not found in your hash, even with .to_sym
. Trim the newline with .chomp
, for example.
I get the feeling that you actually wanted to use string keys. If so, this would be the syntax:
1class RPS
2
3 def initialize(guess:)
4 @guess = guess.capitalize
5 end
6
7 def rule_engine
8 {
9 'Rock': ['Scissors'],
10 'Paper': ['Rock'],
11 'Scissors': ['Paper']
12 }
13 end
14
15 def sys_guess
16 rand 12345
17 sys_guesses = %w{Rock Paper Scissors}
18 sys_guesses.sample
19 end
20
21 def winner_is
22 puts sys_guess
23 puts @guess
24
25 if rule_engine[sys_guess.to_sym].include? @guess
26 puts "Computer wins"
27 elsif rule_engine[@guess.to_sym].include? sys_guess
28 puts "You win!"
29 else
30 puts "Tie"
31 end
32 end
33end
34
35rps = RPS.new(guess: gets)
36rps.winner_is
37 rps = RPS.new(guess: gets)
38 def rule_engine
39 {
40 'Rock' => ['Scissors'],
41 'Paper' => ['Rock'],
42 'Scissors' => ['Paper']
43 }
44 end
45
QUESTION
AWS Step function - choice step - TimestampEquals matching with multiple input variables
Asked 2021-Jun-09 at 12:10I have been trying to create a step function with a choice step that acts as a rule engine. I would like to compare a date variable (from the stale input JSON) to another date variable that I generate with a lambda function.
AWS documentation does not go into details about the Timestamp comparator functions, but I assumed that it can handle two input variables. Here is the relevant part of the code:
1{
2 "Variable": "$.staleInputVariable",
3 "TimestampEquals": "$.generatedTimestampUsingLambda"
4}
5
Here is the error that I am getting when trying to update(!!!) the stepFunction. I would like to highlight the fact that I don't even get to invoking the stepFunction as it fails while updating the function.
1{
2 "Variable": "$.staleInputVariable",
3 "TimestampEquals": "$.generatedTimestampUsingLambda"
4}
5Resource handler returned message: "Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: String does not match RFC3339 timestamp at ..... (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 97df9775-7d2d-4dd2-929b-470c8s741eaf; Proxy: null)" (RequestToken: 030aa97d-35a5-a6a5-0ac5-5698a8662bc2, HandlerErrorCode: InvalidRequest)
6
The stepfunction updates without the Timestamp matching, therefore, I suspect this bit of code.. Any guess?
EDIT (08.Jun.2021):
A comparison – Two fields that specify an input variable to compare, the type of comparison, and the value to compare the variable to. Choice Rules support comparison between two variables. Within a Choice Rule, the value of Variable can be compared with another value from the state input by appending Path to name of supported comparison operators. Source: AWS docs
It clearly states that two variables can be compared, but to no avail. Still trying :)
ANSWER
Answered 2021-Jun-09 at 12:10When I explained the problem to one of my peers, I realised that the AWS documentation mentions a Path postfix (which I confused with the $.). This Path needs to be added to the operatorName.
The following code works:
1{
2 "Variable": "$.staleInputVariable",
3 "TimestampEquals": "$.generatedTimestampUsingLambda"
4}
5Resource handler returned message: "Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: String does not match RFC3339 timestamp at ..... (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 97df9775-7d2d-4dd2-929b-470c8s741eaf; Proxy: null)" (RequestToken: 030aa97d-35a5-a6a5-0ac5-5698a8662bc2, HandlerErrorCode: InvalidRequest)
6{
7 "Variable": "$.staleInputVariable",
8 "TimestampEqualsPath": "$.generatedTimestampUsingLambda"
9}
10
Again, I would like to draw your attention to the "Path" word. That makes the magic!
QUESTION
how to prevent drools engine looping on entry point data
Asked 2021-May-16 at 07:25I'm using drools to raise alarm on streaming transaction data. The drools engine is STREAM and ACTIVE mode. I also use an entry point (OM-TRANS) to transmit data to the rule engine. I have written a simple rule to test the behaviour of the engine. I got some results but i don't understand them and their are not what i expect.
This is the first simple rule:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9
These are the results i got after testing:
- transaction from msisdn msisdn_1:
------------ an alarm on msisdn_1 ----------
- transaction from msisdn msisdn_1 again:
------------ an alarm on msisdn_1 ----------
- transaction from msisdn msisdn_2:
------------ an alarm on msisdn_2 ----------
- transaction from msisdn msisdn_2 again:
------------ an alarm on msisdn_2 ----------
- transaction from msisdn msisdn_3:
------------ an alarm on msisdn_3 ----------
This is now the second version of the rule:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17
and i got the following results and what i expect:
- transaction from msisdn msisdn_1:
------------ an alarm on msisdn_1, total Transaction: 1 ----------
(this is the one expected)
- transaction from msisdn msisdn_1 again:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19
What i expected is : A sigle row ------------ an alarm on msisdn_1, total Transaction: 2 ----------
- transaction from msisdn msisdn_2:
------------ an alarm on msisdn_2, total Transaction: 1 ----------
(as expected)
- transaction from msisdn msisdn_2 again:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21
What i expected is : A sigle row ------------ an alarm on msisdn_2, total Transaction: 2 ----------
- transaction from msisdn msisdn_3:
------------ an alarm on msisdn_3, total Transaction: 1 ----------
(this is the one expected)
- transaction from msisdn msisdn_3 again:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21------------ an alarm on msisdn_3, total Transaction: 2 ----------
22------------ an alarm on msisdn_3, total Transaction: 2 ----------
23
What i expected is : A sigle row ------------ an alarm on msisdn_3, total Transaction: 2 ----------
- transaction from msisdn msisdn_3 again:
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21------------ an alarm on msisdn_3, total Transaction: 2 ----------
22------------ an alarm on msisdn_3, total Transaction: 2 ----------
23------------ an alarm on msisdn_3, total Transaction: 3 ----------
24------------ an alarm on msisdn_3, total Transaction: 3 ----------
25------------ an alarm on msisdn_3, total Transaction: 3 ----------
26
What i expected is : A sigle row ------------ an alarm on msisdn_3, total Transaction: 3 ----------
Can someone explain to me why i got those result? Is it possible to get what i expect ? Thanks you.
ANSWER
Answered 2021-May-16 at 07:25Because your events expire only in 24h, older ones do participate in the rule logic.
Usually this can be fixed with sliding length window
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21------------ an alarm on msisdn_3, total Transaction: 2 ----------
22------------ an alarm on msisdn_3, total Transaction: 2 ----------
23------------ an alarm on msisdn_3, total Transaction: 3 ----------
24------------ an alarm on msisdn_3, total Transaction: 3 ----------
25------------ an alarm on msisdn_3, total Transaction: 3 ----------
26 over window:length(1) from entry-point "OM-TRANS"
27
full snippet
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21------------ an alarm on msisdn_3, total Transaction: 2 ----------
22------------ an alarm on msisdn_3, total Transaction: 2 ----------
23------------ an alarm on msisdn_3, total Transaction: 3 ----------
24------------ an alarm on msisdn_3, total Transaction: 3 ----------
25------------ an alarm on msisdn_3, total Transaction: 3 ----------
26 over window:length(1) from entry-point "OM-TRANS"
27rule "My rule2"
28no-loop true
29when
30 $transaction: TransactionOmDto($msisdn: msisdn) over window:length(1) from entry-point "OM-TRANS"
31 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
32then
33 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
34end
35
output
1rule "My rule"
2 no-loop true
3 when
4 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
5 then
6 System.out.println("------------ an alarm on "+$msisdn+" ----------");
7 end
8
9rule "My rule"
10 no-loop true
11 when
12 $transaction: TransactionOmDto($msisdn: msisdn) from entry-point "OM-TRANS"
13 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
14 then
15 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
16 end
17------------ an alarm on msisdn_1, total Transaction: 2 ----------
18------------ an alarm on msisdn_1, total Transaction: 2 ----------
19------------ an alarm on msisdn_2, total Transaction: 2 ----------
20------------ an alarm on msisdn_2, total Transaction: 2 ----------
21------------ an alarm on msisdn_3, total Transaction: 2 ----------
22------------ an alarm on msisdn_3, total Transaction: 2 ----------
23------------ an alarm on msisdn_3, total Transaction: 3 ----------
24------------ an alarm on msisdn_3, total Transaction: 3 ----------
25------------ an alarm on msisdn_3, total Transaction: 3 ----------
26 over window:length(1) from entry-point "OM-TRANS"
27rule "My rule2"
28no-loop true
29when
30 $transaction: TransactionOmDto($msisdn: msisdn) over window:length(1) from entry-point "OM-TRANS"
31 $datasTransaction: List() from collect(TransactionOmDto(msisdn == $msisdn) from entry-point "OM-TRANS")
32then
33 System.out.println("------------ an alarm on "+$msisdn+", total Transaction: "+$datasTransaction.size()+" ----------");
34end
35------------ an alarm on msisdn_1, total Transaction: 1 ----------
36------------ an alarm on msisdn_1, total Transaction: 2 ----------
37------------ an alarm on msisdn_1, total Transaction: 3 ----------
38
QUESTION
Firebase rule from the standard docs does not validate
Asked 2021-Apr-01 at 18:06I've just simply copy and pasted over a firebase rule from this documentation to implement token revocations. However, the RTDB rule engine does not allow this expression to be published, notice the screenshot below..
I have literally copied this rule from the documentation found here: https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens
The error is shown in the picture below:
what am I doing wrong here?
ANSWER
Answered 2021-Apr-01 at 18:06Yeah, that looks like it's not going to work. Luckily you can get the same result with a bit more code:
1".read": "$user_id === auth.uid
2 && (!root.child('metadata').child(auth.uid).child('revokeTime').exists()
3 || auth.token.auth_time > root.child('metadata').child(auth.uid).child('revokeTime').val())
4
So instead of using the || 0
trick to handle the case where there's no revokeTime
, this now have an explicit condition for that case.
I also filed a bug to get this fixed in our documentation.
QUESTION
pass arguments in dockerfile?
Asked 2021-Mar-14 at 07:50I want to pass an argument to my dockerfile such that I should be able to use that argument in my run command but it seems I am not able to do so
I am using a simple bash file that will trigger the docker build and docker run
1FROM openjdk:8 AS SCRATCH
2
3WORKDIR /
4
5ADD . .
6
7RUN apt install unzip
8
9RUN unzip target/universal/rule_engine-1.0.zip -d target/universal/rule_engine-1.0
10
11COPY target/universal/rule_engine-1.0 .
12
13ENV MONGO_DB_HOST="host.docker.internal"
14ENV MONGO_DB_PORT="27017"
15
16EXPOSE 9000
17
18ARG path
19
20CMD target/universal/rule_engine-1.0/bin/rule_engine -Dconfig.file=$path
21
above is my dockerfile and below is my bash file which will access this dockerfile
1FROM openjdk:8 AS SCRATCH
2
3WORKDIR /
4
5ADD . .
6
7RUN apt install unzip
8
9RUN unzip target/universal/rule_engine-1.0.zip -d target/universal/rule_engine-1.0
10
11COPY target/universal/rule_engine-1.0 .
12
13ENV MONGO_DB_HOST="host.docker.internal"
14ENV MONGO_DB_PORT="27017"
15
16EXPOSE 9000
17
18ARG path
19
20CMD target/universal/rule_engine-1.0/bin/rule_engine -Dconfig.file=$path
21#!/bin/bash
22
23# change the current path to rule engine path
24cd /Users/zomato/Documents/Intern_Project/rule_engine
25
26sbt dist
27
28ENVIR=$1
29
30config=""
31if [ $ENVIR == "local" ]
32then
33 config=conf/application.conf
34elif [ $ENVIR == "staging" ]
35then
36 config=conf/staging.conf
37else
38 config=conf/production.conf
39fi
40
41echo $config
42docker build --build-arg path=$config -t rule_engine_zip .
43docker run -i -t -p 9000:9000 rule_engine_zip
44
but when i access the dockerfile through bash script which will set config variable I am not able to set path variable in last line of dockerfile to the value of config.
ANSWER
Answered 2021-Mar-14 at 07:50ARG
values won't be available after the image is built, so
a running container won’t have access to those values. To dynamically set an env variable, you can combine both ARG
and ENV
(since ENV
can't be overridden):
1FROM openjdk:8 AS SCRATCH
2
3WORKDIR /
4
5ADD . .
6
7RUN apt install unzip
8
9RUN unzip target/universal/rule_engine-1.0.zip -d target/universal/rule_engine-1.0
10
11COPY target/universal/rule_engine-1.0 .
12
13ENV MONGO_DB_HOST="host.docker.internal"
14ENV MONGO_DB_PORT="27017"
15
16EXPOSE 9000
17
18ARG path
19
20CMD target/universal/rule_engine-1.0/bin/rule_engine -Dconfig.file=$path
21#!/bin/bash
22
23# change the current path to rule engine path
24cd /Users/zomato/Documents/Intern_Project/rule_engine
25
26sbt dist
27
28ENVIR=$1
29
30config=""
31if [ $ENVIR == "local" ]
32then
33 config=conf/application.conf
34elif [ $ENVIR == "staging" ]
35then
36 config=conf/staging.conf
37else
38 config=conf/production.conf
39fi
40
41echo $config
42docker build --build-arg path=$config -t rule_engine_zip .
43docker run -i -t -p 9000:9000 rule_engine_zip
44ARG PATH
45ENV P=${PATH}
46CMD target/universal/rule_engine-1.0/bin/rule_engine -Dconfig.file=$P
47
For further explanation, I recommend this article, which explains the difference between ARG
and ENV
in a clear way:
As you can see from the above image, the ARG
values are available only during the image build.
QUESTION
TopQuadrant Shacl Rule Engine Iterative inference
Asked 2021-Feb-09 at 02:14does the Shacl API Rule engine support sh:order for Rule execution as TopBraid Composer does.
I tested rule ordering in TBC and it goes iteratively until it reach a fixed point. No more rule to execute. I suspect that it is considered one-pass, but rule are prioritized and their result made available for the next rule to be execute in that same pass.
Anyhow, independently of how this is implemented, i wonder if it is a feature of the shacl rule engine or an implementation specific to TopBraid composer.
The following thread hint at the answer i am looking for but fall short.
ANSWER
Answered 2021-Feb-09 at 02:14The current SHACL API does not do the iterations out of the box. RuleEngine does a single iteration of all rules, and those rules may access each other's results following the outline at
https://w3c.github.io/shacl/shacl-af/#rules-execution
To do iterative looping, simply call RuleEngine.executeAll until one round has not created any new inferences. Care needs to be taken to avoid infinite loops, as some rules may in theory produce blank nodes, random values etc. TopBraid Composer does this looping automatically.
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Rule Engine
Tutorials and Learning Resources are not available at this moment for Rule Engine