ADS importing other JS

72 views
Skip to first unread message

Nicholas Car

unread,
Mar 17, 2022, 8:09:32 PM3/17/22
to topbrai...@googlegroups.com
Dear TB users,

Is it possible, within an ADS script, to import arbitrary JavaScript packages?

For example, if I wanted to use luxon (https://openbase.com/js/luxon) for date/time manipulation, how would I get it? Are there options other than having to inline the entire module?

I understand that there are several modes for executing ADS code, but I'm interested in the in-EDG mode in particular.

Thanks,

Nick

Holger Knublauch

unread,
Mar 17, 2022, 8:21:11 PM3/17/22
to topbrai...@googlegroups.com

Hi Nick,

no, inline execution would be the only option right now, e.g. copy the library into a dash:IncludedScript. I am aware this is not ideal and we have a Jira ticket to make working with files (from the workspace) easier. But it won't happen in 7.2 which is ready for release very soon.

One problem is that adding libraries adds to the footprint of the GraalVM that we use. Consider that you have dozens of asset collections. For each Ontology in them, TopBraid will generate a new ADS API, and I am not sure if GraalVM would optimize each copy to reuse those building blocks. So any solution here would need to optimize that.

Holger

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CAP7nqh0G_%3DLZRvDs1OHk3mNs_2W4N-m0xLijXUsdNr3Ks50tVQ%40mail.gmail.com.

Fan Li

unread,
Mar 18, 2022, 8:19:10 AM3/18/22
to TopBraid Suite Users
Hi Holger, it would be great if ADS can support ES module import from node_modules, which would open up a lot of possibilities.

Holger Knublauch

unread,
Mar 18, 2022, 6:31:45 PM3/18/22
to topbrai...@googlegroups.com
Hi Fan Li, others,


I agree it would be nice to have ES modules within TopBraid but this also opens up potential problems, trying to cram everything into a single (Java) virtual machine. With the Node.js approach above, users can more easily divide the workload, into a more traditional services architecture.

I would be interested in hearing what types of external libraries people would be particularly interested in using, so that we are better informed about the future direction here.

Thanks
Holger



Nicholas Car

unread,
Mar 24, 2022, 10:42:36 PM3/24/22
to topbrai...@googlegroups.com
We have successfully tested manipulation of local RDF data in EDG ADS script using N3.js imported inline into an ADS script.

So now we can retrieve external RDF, in Turtle, parse it, query it (not SPARQL, just triple patterns) and do things with it like insert it into local EDG graphs.

Nick

Holger Knublauch

unread,
Mar 24, 2022, 10:50:00 PM3/24/22
to topbrai...@googlegroups.com

That's nice to hear! Did you notice any slow-downs when it had to do the extra parsing of such a library (e.g. measure the request response time of the Refresh button on the Script Editor panel)? How big is the .js snippet that you have added? The ADS engine needs to periodically rebuild those APIs, esp after ontology changes.

Holger

Nicholas Car

unread,
Mar 29, 2022, 8:56:29 PM3/29/22
to topbrai...@googlegroups.com
No slowdown discernable since I'm using the smallest RDF parser library I could find - N3.js, so only N3/Turtle support for now - and we're parsing very light resources - small online ontologies and vocabs.

Nick

Holger Knublauch

unread,
Mar 29, 2022, 9:05:35 PM3/29/22
to topbrai...@googlegroups.com
Ok thanks. I have meanwhile added a new built-in function IO.parseRDF(text, serialisation?) which will create a temp graph by parsing an RDF (Turtle etc) string, which can then be queried. This will be for 7.3. We are on 3-monthly release cycles now.

Holger

 

Nicholas Car

unread,
Mar 30, 2022, 9:49:32 AM3/30/22
to topbrai...@googlegroups.com
Great, thanks. That will certainly simplify things!

Nick

Reply all
Reply to author
Forward
0 new messages