Skip to content

Commit

Permalink
Added support for loading to default graph. (#51)
Browse files Browse the repository at this point in the history
* Added support for loading to default graph.

* Added classpath property since owl-load runs as a subprocess.

* Switched to a different API for loading to the default graph.

* Export OntologyIrisPath

* Several changes:

1. Owlload
- Now supports incremental loading
- Now supports query service param
- Now supports passing username/password param
- Now supports loading to default param
- Now supports iris path param

2. OwlQuery
- Now supports query service param

3. OwlShacl
- Now supports shacl service param

4. OwlStartFuseki
- Now supports classpath param
- Now supports jvm arguments param
- Fix cmdline for port and max pings

* typo

* Added docs to owl-reason for the new outputOntologyIrisPath param

* Updates per discussion w/ @melaasar

* For start fuseki, make the output folder an internal gradle property to avoid it being hashed for determining whether the task is up-to-date

* Fixed deresolveURI logic w/ file separator.

* parallel loading with prefixing of task output.

* Fixed deresolveURI for correct changed iri handling.

* Multiple fixes:

- Make incremental model default for OwlLoad and print to stdout
- Dispose OWL reasoner when done

* Remove task name from OwlLoad main method

---------

Co-authored-by: Maged Elaasar <[email protected]>
  • Loading branch information
NicolasRouquette and melaasar authored Feb 21, 2024
1 parent 426e2ed commit df89f46
Show file tree
Hide file tree
Showing 20 changed files with 1,068 additions and 640 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build
.launch
*.eml
*.iml
.history
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
subprojects {
group = 'io.opencaesar.owl'
version = '2.6.1'
version = '2.7.0'

ext.versions = [
owl: '5.1.17',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;

Expand Down Expand Up @@ -41,7 +42,7 @@ public StartFusekiTask( ) {
*
* @return DirectoryProperty
*/
@OutputDirectory
@Internal
public abstract DirectoryProperty getOutputFolderPath();

/**
Expand All @@ -63,6 +64,24 @@ public StartFusekiTask( ) {
@Input
public abstract Property<String> getFusekiVersion();

/**
* The list of additional classpath dependencies, each of the form: {group}:{artifact}:{exact version}
*
* @return List of additional classpath dependencies.
*/
@Optional
@Input
public abstract ListProperty<String> getClasspath();

/**
* The optional list of additional JVM arguments
*
* @return List of additional JVM arguments.
*/
@Optional
@Input
public abstract ListProperty<String> getJVMArguments();

/**
* The optional gradle task fuseki port property (default is 3030).
*
Expand Down Expand Up @@ -150,7 +169,7 @@ public void run() {
args.add(getOutputFolderPath().get().getAsFile().getAbsolutePath());
}
if (getPort().isPresent()) {
args.add("--port");
args.add("-p");
args.add(getPort().get().toString());
}
if (getWebUI().isPresent()) {
Expand All @@ -159,9 +178,21 @@ public void run() {
}
}
if (getMaxPings().isPresent()) {
args.add("-p");
args.add("-n");
args.add(getMaxPings().get().toString());
}
if (getJVMArguments().isPresent()) {
getJVMArguments().get().forEach(arg -> {
args.add("-jvm");
args.add(arg);
});
}
if (getClasspath().isPresent()) {
getClasspath().get().forEach(dep -> {
args.add("-cp");
args.add(dep);
});
}
if (getDebug().isPresent() && getDebug().get()) {
args.add("-d");
}
Expand Down
20 changes: 12 additions & 8 deletions owl-fuseki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ gradlew.bat owl-fuseki:run --args="..."
```
Args:
```
--command | -c start|stop [Required]
--configurationPath | -g path/to/.fuseki.ttl [Required]
--outputFolderPath | -o path/to/output/folder [Required]
--remote-repository-url | url [Optional, default: https://repo.maven.apache.org/maven2/]
--fuseki-version | -fv <version> [Optional, default: 4.6.1]
--port | -p <port> [Optional, default: 3030)
--webui | -ui [Optional]
--max-pings | -p [Optional]
-c | --command start|stop [Required]
-g | --configurationPath path/to/.fuseki.ttl [Required]
-o | --outputFolderPath path/to/output/folder [Required]
-url | --remote-repository-url <url> [Optional, default: https://repo.maven.apache.org/maven2/]
-fv | --fuseki-version <version> [Optional, default: 4.6.1]
-p | --port <port> [Optional, default: 3030)
-ui | --webui [Optional]
-n | --max-pings [Optional]
-cp | --classpath group:artifact:exact-version [Optional, additional classpath dependencies]
-jvm | --jvm-arguments "-Xms256m" [Optional, additional JVM arguments]
```

## Run as Gradle Task
Expand Down Expand Up @@ -50,6 +52,8 @@ task startFuseki(type: io.opencaesar.owl.fuseki.StartFusekiTask) {
port = 3030 // optional, default: 3030
webUI = true // optional, default: false [creates a 'webapp' subfolder under outputFolderPath]
maxPings = 10 // optional, default: 10
classpath = ['group:artifact:exact-version'] // optional
jvmArguments = ['-Xms256m'] // optional
}
task stopFuseki(type: io.opencaesar.owl.fuseki.StopFusekiTask) {
Expand Down
35 changes: 25 additions & 10 deletions owl-fuseki/src/main/java/io/opencaesar/owl/fuseki/FusekiApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ enum Command {
private String fusekiVersion = "4.6.1";

@Parameter(
names = {"--port, -p"},
names = {"--port", "-p"},
description = "Fuseki server port (defaults to 3030)",
required = false,
order = 6)
Expand All @@ -123,24 +123,38 @@ enum Command {
private boolean webui = false;

@Parameter(
names = {"--max-pings", "-p"},
names = {"--max-pings", "-n"},
description = "Maximum number (10 by default) of pings to the server before giving up",
help = true,
required = false,
order = 8)
private int maxPings = 10;

@Parameter(
names = {"--classpath", "-cp"},
description = "Additional classpath dependencies to load when starting Fuseki, each of the form: <group>:<artifact>:<exact version>",
required = false,
order = 9)
private List<String> classpath = new ArrayList<>();

@Parameter(
names = {"jvm-arguments", "-jvm"},
description = "Additional JVM arguments",
required = false,
order = 10)
private List<String> jvmArguments = new ArrayList<>();

@Parameter(
names = {"--debug", "-d"},
description = "Shows debug logging statements",
order = 9)
order = 11)
private boolean debug = false;

@Parameter(
names = {"--help", "-h"},
description = "Displays summary of options",
help = true,
order = 10)
order = 12)
private boolean help = false;

private final static Logger LOGGER = Logger.getLogger(FusekiApp.class);
Expand Down Expand Up @@ -214,10 +228,10 @@ private void run(FusekiApp app) throws Exception {
}

String[] cpEntries = deps.toArray(new String[0]);
startFuseki(cpEntries, new File(configurationPath), new File(outputFolderPath), app.port, false, app.maxPings, "org.apache.jena.fuseki.cmd.FusekiCmd", app, "--localhost");
startFuseki(cpEntries, new File(configurationPath), new File(outputFolderPath), app.port, false, app.maxPings, "org.apache.jena.fuseki.cmd.FusekiCmd", app.jvmArguments, "--localhost");
} else {
String[] cpEntries = deps.toArray(new String[0]);
startFuseki(cpEntries, new File(configurationPath), new File(outputFolderPath), app.port, true, app.maxPings, "org.apache.jena.fuseki.main.cmds.FusekiMainCmd", app);
startFuseki(cpEntries, new File(configurationPath), new File(outputFolderPath), app.port, true, app.maxPings, "org.apache.jena.fuseki.main.cmds.FusekiMainCmd", app.jvmArguments);
}
} else {
stopFuseki(new File(outputFolderPath));
Expand Down Expand Up @@ -275,7 +289,7 @@ public static void unzip(InputStream source, File target) throws IOException {
* @param pingArg Whether to add --ping to the command
* @param maxPings The maximum number of pings to try before giving up
* @param clazz Qualified name of the Fuseki server application (with or without Web UI)
* @param app Fuseki application
* @param jvmArgs A list of additional JVM arguments.
* @param argv Additional arguments
* @throws IOException if the 'fuseki.pid' file could not be written to
* @throws URISyntaxException If there is a problem retrieving the location of the fuseki jar.
Expand All @@ -288,7 +302,7 @@ public static void startFuseki(
boolean pingArg,
int maxPings,
String clazz,
FusekiApp app,
List<String> jvmArgs,
String... argv) throws IOException, URISyntaxException {
Path output = fusekiDir.toPath();
File pidFile = output.resolve(PID_FILENAME).toFile();
Expand All @@ -310,15 +324,16 @@ public static void startFuseki(

List<String> args = new ArrayList<String>();
args.add(getJavaCommandPath());
args.addAll(jvmArgs);
args.add("-cp");
args.add(String.join(File.pathSeparator, cpEntries));
args.add(clazz);
args.add("--port");
args.add(Integer.toString(port));
if (pingArg) {
args.add("--ping");
}
args.add("--config=" + output.relativize(config.toPath()).toString().replace("\\", "/")); // put the relative path to avoid spaces in path
args.add("--port");
args.add(Integer.toString(port));
args.addAll(Arrays.asList(argv));

ProcessBuilder pb = new ProcessBuilder(args);
Expand Down
163 changes: 0 additions & 163 deletions owl-load-gradle/src/main/java/io/opencaesar/owl/load/OwlCatalog.java

This file was deleted.

Loading

0 comments on commit df89f46

Please sign in to comment.