Skip to content

Commit 35fdb75

Browse files
authored
Merge pull request #167 from terry-norbraten/master
Fine tune the CI/CD and use ProcessBuilder to produce proof image as SVG
2 parents f428e5f + f882068 commit 35fdb75

File tree

9 files changed

+94
-68
lines changed

9 files changed

+94
-68
lines changed

.github/workflows/ant.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
name: sigma-webapp
159159
path: /usr/local/tomcat/webapps/sigma.war
160160

161-
build-sumo-ci:
161+
build-sumo-ci-and-sigmakee:
162162
runs-on: ubuntu-latest
163163
needs: build
164164
steps:

.github/workflows/docker-publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ jobs:
3636
password: ${{ secrets.DOCKERHUB_TOKEN }}
3737

3838
- name: Set up Docker Buildx
39-
uses: docker/setup-buildx-action@v2
39+
uses: docker/setup-buildx-action@v3
4040

4141
- name: Set image account name
4242
env:
4343
DOCKER_ACCOUNT: ${{ secrets.DOCKERHUB_USERNAME }}
4444
run: |
4545
echo "IMAGE_ACCOUNT=${DOCKER_ACCOUNT:-$DEFAULT_DOCKER_ACCOUNT}" >> $GITHUB_ENV
4646
47-
- name: Build and push
47+
- name: Build and push sigma-ci
4848
uses: docker/build-push-action@v6
4949
with:
5050
context: .

docker/sigma-ci/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN apt-get update && apt-get install -y --install-recommends \
4949
# wget $E_PROVER &&\
5050
# tar xf E.tgz ;\
5151
# cd E ;\
52-
# ./configure && make CC="clang" CXX="clang++" ;\
52+
# ./configure && make -j`nproc` CC="clang" CXX="clang++" ;\
5353
# cd .. ;\
5454
# wget $WORD_NET &&\
5555
# tar xf WordNet-3.0.tar.gz ;\

docker/sigmakee/Dockerfile

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ COPY --from=builder \
2020
COPY --from=builder \
2121
/usr/local/bin/libz3.* /usr/local/bin/
2222

23-
COPY ./sigmakee-runtime /root/sigmakee-runtime/
24-
23+
# Just the essentials
24+
COPY ./sigmakee-runtime/KBs/config.xml /root/sigmakee-runtime/KBs/
25+
COPY ./sigmakee-runtime/KBs/*.kif /root/sigmakee-runtime/KBs/
26+
COPY ./sigmakee-runtime/KBs/Translations /root/sigmakee-runtime/KBs/
27+
COPY ./sigmakee-runtime/KBs/WordNetMappings /root/sigmakee-runtime/KBs/
28+
COPY ./sigmakee-runtime/KBs/development /root/sigmakee-runtime/KBs/
29+
30+
# Not necessary since everything is in the WAR
2531
COPY ./sigmakee/build/WEB-INF/lib/*.jar /root/sigmakee/
32+
COPY ./sigmakee/build/sigmakee.jar /root/sigmakee/
2633

2734
COPY ./sigma.war $CATALINA_HOME/webapps/sigma.war
2835

docker/sumo-ci/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COPY --from=builder \
2020
COPY --from=builder \
2121
/usr/local/bin/libz3.* /usr/local/bin/
2222

23-
COPY ./sigmakee-runtime /root/sigmakee-runtime/
23+
COPY ./sigmakee-runtime/KBs/config.xml /root/sigmakee-runtime/KBs/
2424

2525
COPY ./sigmakee/build/WEB-INF/lib/*.jar /root/sigmakee/
2626

nbproject/build.properties

+66-48
Original file line numberDiff line numberDiff line change
@@ -125,48 +125,6 @@ kbs_home=../sumo
125125
#spec.vendor=Adam Pease
126126
project.license=LICENSE
127127

128-
# Can't override immutable props
129-
#main.class=com.articulate.sigma.KB
130-
#run.class=com.articulate.sigma.KButilities
131-
run.class=${main.class}
132-
133-
# Various runtime arguments here
134-
135-
# Intentional empty arguments
136-
#run.args=
137-
138-
# Default run for the KB
139-
#run.args=-c Object Transaction
140-
141-
# Load KB files w/ KButilities (should regenerate the KB if cleaned). Add -N for
142-
# sequential (slower) processing <- original implementation
143-
#run.args=-l
144-
run.args=-f ${vamp.out.file}
145-
146-
# KB.cache
147-
#run.args=-a
148-
149-
# Run Vampire on SUMO.tptp and output proof
150-
#run.args=-p
151-
152-
# KB, KIF, TPTP3ProofProcessor, TPTPutil, SUMOtoTFAform - run a test
153-
#run.args=-t
154-
155-
# Formula check for errors
156-
formula='(=> (and (muscleInsertion ?MC ?BPC) (instance ?H Human) (attribute ?H Healthy)) (exists (?M ?BP) (and (instance ?M ?MC) (instance ?BP ?BPC) (part ?M ?H) (part ?BP ?H) (connects ?M ?BP))))'
157-
158-
# Error checking a formula w/ com.articulate.sigma.KButilities
159-
#run.args=-v ${formula}
160-
161-
# Test internal clause in TPTP2SUMO
162-
#run.args=-c
163-
164-
# Translate KB to TFF, no args
165-
# run com.articulate.sigma.trans.SUMOKBtoTFAKB
166-
167-
# Translate KB to FOF, no args
168-
# run com.articulate.sigma.trans.SUMOKBtoTPTPKB
169-
170128
# Tomcat Manager properties
171129
catalina.ops=-Xmx10g -Xss1m
172130
catalina.base=${catalina.home}
@@ -201,27 +159,87 @@ test.integration.resources.dir=${test.integration.dir}/resources
201159
#unit.test.suite=com.articulate.sigma.UnitTestSuite
202160
#integration.test.suite=com.articulate.sigma.IntegrationTestSuite
203161

162+
# Can't override immutable props
163+
#main.class=com.articulate.sigma.KB
164+
#run.class=${main.class}
165+
# Load KB files w/ KButilities (should regenerate the KB if cleaned). Add -N for
166+
# sequential (slower) processing <- original implementation
167+
#run.args=-l
168+
# Default run for checking KB operation
169+
#run.args=-c Object Transaction
170+
171+
#run.class=com.articulate.sigma.KButilities
172+
# Formula check for errors
173+
formula='(=> (and (muscleInsertion ?MC ?BPC) (instance ?H Human) (attribute ?H Healthy)) (exists (?M ?BP) (and (instance ?M ?MC) (instance ?BP ?BPC) (part ?M ?H) (part ?BP ?H) (connects ?M ?BP))))'
174+
# Error checking a formula w/ com.articulate.sigma.KButilities
175+
#run.args=-v ${formula}
176+
177+
#run.class=com.articulate.sigma.KBcache
178+
#run.args=-a
179+
180+
# WordNet term search
181+
#run.class=com.articulate.sigma.wordNet.WordNet
182+
#run.args=-w Cat
183+
184+
# KB, KIF, TPTP3ProofProcessor, TPTPutil, SUMOtoTFAform - run a test
185+
#run.args=-t
186+
187+
# Test internal clause in TPTP2SUMO
188+
#run.class=com.articulate.sigma.trans.TPTP2SUMO
189+
#run.args=-c
190+
191+
### Ontology Process
192+
193+
# (1) Generates FOF, no args
194+
#run.class com.articulate.sigma.trans.SUMOKBtoTPTPKB
195+
#run.args=
196+
# or
197+
# (1) Generates TFF, no args
198+
#run.class=com.articulate.sigma.trans.SUMOKBtoTFAKB
199+
#run.args=
200+
201+
# (2 & 3) Runs Vampire on ~.sigmakee/KBs/SUMO.tptp, produces and analyzes proof
202+
#run.class=com.articulate.sigma.tp.Vampire
203+
#run.args=-p
204+
# or
205+
# (2) run: ant run.vampire
206+
# (3) Analyzes proof after CLI run of Vampire
207+
#run.class=com.articulate.sigma.trans.TPTP3ProofProcessor
208+
#run.args=-f ${vamp.out.file}
209+
210+
# (4) View the proof
211+
# run: ant open.dot.image
212+
213+
### end Ontology Process
214+
204215
# Vampire
205216

206217
# default timeout is 60 if -t is not specified
207218
# NOTE: [- -mode casc] is a shortcut for [- -mode portfolio -sched casc -p tptp]
208219
#tptp.file=${workspace}/sigmakee/nbproject/private/resources/tiny/SUMO.tptp
220+
#vamp.out.file=${workspace}/sigmakee/nbproject/private/resources/tiny/vamp-out.txt
209221
tptp.file=${sigma_home}/KBs/SUMO.tptp
210222
vamp.out.file=${sigma_home}/KBs/vamp-out.txt
211-
#vamp.out.file=${workspace}/sigmakee/nbproject/private/resources/tiny/vamp-out.txt
212-
#vamp.args=--mode casc -t 900 ${tptp.file} &amp;> ${vamp.out.file}
213-
vamp.args=--cores 0 --mode portfolio --schedule snake_tptp_uns -p tptp --input_syntax tptp --output_axiom_names on -t 10 ${tptp.file} &> ${vamp.out.file}
223+
vamp.time=-t 900
224+
#vamp.args=--mode casc ${vamp.time} ${tptp.file} &amp;> ${vamp.out.file}
225+
vamp.args=--cores 0 --mode portfolio --schedule snake_tptp_uns -p tptp --input_syntax tptp --output_axiom_names on ${vamp.time} ${tptp.file} &> ${vamp.out.file}
214226

215-
dot.file='${deploy_home}/graph/proof.dot'
216227
dot.cmd=/usr/local/bin/dot
217-
dot.args=-Tsvg -Kosage -O ${dot.file}
228+
image.ext=svg
229+
# default: dot
230+
#dot.layout=
231+
dot.layout=-Kdot
232+
dot.file='${deploy_home}/graph/proof.dot'
233+
dot.args=-T${image.ext} ${dot.layout} -O ${dot.file}
234+
dot.image.file=${dot.file}.${image.ext}
218235

236+
# PasswordService
219237
#System.out.println("PasswordService: ");
220238
#System.out.println("-h show this Help message");
221239
#System.out.println("-l Login");
222240
#System.out.println("-c Create db");
223241
#System.out.println("-a create Admin user");
224-
#
242+
225243
#System.out.println("-u show User IDs");
226244
#System.out.println("-r Register a new username and password (fail if username taken)");
227245
#System.out.println("-a3 <u> <p> <e> create Admin user");

nbproject/ide-targets.xml

+10-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
<copy tofile="${sigma_home}/KBs/config.xml" file="${tiny.sumo.config}" overwrite="true"/>
565565
</target>
566566
<target name="thorough.clean" depends="clean">
567-
<antcall target="kb.clean"/>
567+
<antcall target="clean.kbs"/>
568568
<delete includeemptydirs="true" failonerror="false">
569569
<!-- Delete the old web code -->
570570
<fileset dir="${deploy_home}"/>
@@ -615,7 +615,7 @@
615615
=========
616616
-->
617617

618-
<target name="run.vampire" depends="init" description="Assumes that ${sigma_home}/KBs/SUMO.tptp has already been generated">
618+
<target name="run.vampire" depends="init" description="Assumes that ${sigma_home}/KBs/SUMO.* has already been generated">
619619
<exec executable="sh">
620620
<arg value="-c"/>
621621
<arg value="${programs.dir}/vampire/build/vampire ${vamp.args}"/>
@@ -629,6 +629,14 @@
629629
<arg value="-c"/>
630630
<arg value="${dot.cmd} ${dot.args}"/>
631631
</exec>
632+
<antcall target="open.dot.image"/>
633+
</target>
634+
635+
<target name="view.dot.image" depends="init" description="Open the image produces by GraphViz">
636+
<exec executable="sh" osfamily="mac">
637+
<arg value="-c"/>
638+
<arg value="open -a 'Google Chrome' ${dot.image.file}"/>
639+
</exec>
632640
</target>
633641

634642
</project>

src/java/com/articulate/sigma/tp/Vampire.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,8 @@ else if (args.length > 0 && args[0].equals("-p")) {
359359
StringBuilder answerVars = new StringBuilder("?X ?Y ?Z");
360360
System.out.println("input: " + vampire.output + "\n");
361361
tpp.parseProofOutput(vampire.output, query, kb, answerVars);
362-
363-
String sep = File.separator;
364-
dir = System.getenv("CATALINA_HOME") + sep + "webapps"
365-
+ sep + "sigma" + sep + "graph";
366-
File webGphDir = new File(dir);
367-
if (!webGphDir.exists())
368-
webGphDir.mkdirs();
369362
tpp.createProofDotGraph();
370-
363+
371364
System.out.println("Vampire.main(): " + tpp.proof.size() + " steps ");
372365
System.out.println("Vampire.main() bindings: " + tpp.bindingMap);
373366
System.out.println("Vampire.main() skolems: " + tpp.skolemTypes);

src/java/com/articulate/sigma/trans/TPTP3ProofProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ private void createProofDotGraphImage(String filename) throws IOException {
11501150
List<String> cmd = new ArrayList<>();
11511151
cmd.add(graphVizDir + File.separator + "dot");
11521152
cmd.add("-T" + imageExt);
1153-
cmd.add("-Kosage");
1153+
cmd.add("-Kdot");
11541154
cmd.add("-O");
11551155
cmd.add(filename + ".dot");
11561156
try {
@@ -1484,10 +1484,10 @@ public static void main(String[] args) throws IOException {
14841484
tpp.parseProofOutput(lines, query, kb, answerVars);
14851485
tpp.createProofDotGraph();
14861486
System.out.println("TPTP3ProofProcessor.main(): " + tpp.proof.size() + " steps ");
1487-
Formula f;
1487+
Formula f = new Formula();
14881488
for (TPTPFormula step : tpp.proof) {
14891489
System.out.println(":: " + step);
1490-
f = new Formula(step.sumo);
1490+
f.setFormula(step.sumo);
14911491
System.out.println(f.format("", " ", "\n"));
14921492
}
14931493
System.out.println("TPTP3ProofProcessor.main() bindings: " + tpp.bindingMap);

0 commit comments

Comments
 (0)