Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ofilangi committed Feb 7, 2021
2 parents 3c56d74 + e8bb500 commit d46152c
Show file tree
Hide file tree
Showing 101 changed files with 114,529 additions and 10,681 deletions.
60 changes: 55 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# CREDENTIAL_CONTEXT used by build.sbt
# - REALM_CREDENTIAL,HOST_CREDENTIAL,LOGIN_CREDENTIAL,PASSWORD_CREDENTIAL
#
# NPM_CONTEXT
# - NPM_TOKEN : token (from ~/.npmrc) to publish nodejs lib
#
version: 2.1
workflows:
compile-workflow:
Expand Down Expand Up @@ -56,6 +59,17 @@ workflows:
branches:
ignore: /.*/

# - publish_npm:
# requires:
# - lib_js
# context:
# - NPM_CONTEXT
# filters:
# tags:
# only: /.*/
# branches:
# only: strategySourceRequest

- check_discovery_valid_fullopjs_cdn_jsdelivr:
filters:
tags:
Expand All @@ -64,6 +78,7 @@ workflows:
executors:

openjdk:
working_directory: ~/repo
docker:
- image: circleci/openjdk:8-jdk
auth:
Expand All @@ -76,6 +91,7 @@ executors:
auth:
username: ${DOCKER_USER}
password: ${DOCKER_PASS}

- image: tenforce/virtuoso:virtuoso7.2.5
auth:
username: ${DOCKER_USER}
Expand All @@ -93,6 +109,9 @@ executors:
SPARQL_UPDATE: true
DEFAULT_GRAPH: "graph:test:discovery:default:"

orbs:
node: circleci/node@4.1.0

jobs:
compile:
executor: openjdk
Expand All @@ -117,9 +136,7 @@ jobs:

lib_js:
executor: openjdk
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
working_directory: ~/repo
steps:
- checkout
- setup_remote_docker
Expand All @@ -135,6 +152,10 @@ jobs:
name: fullOptJS
command: cat /dev/null | sbt discoveryJS/fullOptJS

- persist_to_workspace:
root: ./js/target/scala-2.13/scalajs-bundler/main/
paths: discovery-opt.js

test_and_coverage_jvm:
executor: virtuoso_environment_executor
environment:
Expand All @@ -149,7 +170,7 @@ jobs:
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Test and Coverage
name: Test JVM env and Coverage
command: |
cat /dev/null | sbt clean coverage discoveryJVM/test:test
sbt discoveryJVM/coverageReport
Expand Down Expand Up @@ -206,8 +227,37 @@ jobs:
F2=./dist/checksum
if [ "$(diff -q $F1 $F2)" != "" ]; then
echo "discovery and discovery-web have to be updated with update_cdn_libjs.sh !" ;
echo "current checksum : "$(cat checksum)
echo "repo checksum : "$(cat dist/checksum)
exit 1;
fi ;
publish_npm:
docker:
- image: circleci/node:12.20
auth:
username: ${DOCKER_USER}
password: ${DOCKER_PASS}
working_directory: ~/repo
steps:
- checkout
- setup_remote_docker
- restore_cache:
keys:
- v1-dependencies-{{ checksum "build.sbt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- attach_workspace:
at: ~/repo/js/target/scala-2.13/scalajs-bundler/main/

- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

- run:
name: Js Opt Lib generation
command: |
npm config set registry http://registry.npmjs.org
npm version 0.0.4
npm publish --access public
134 changes: 66 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,91 @@
[![CodeFactor](https://www.codefactor.io/repository/github/p2m2/discovery/badge)](https://www.codefactor.io/repository/github/p2m2/discovery)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/8d8ecb66f9ff4963a22efab3c693b629)](https://www.codacy.com/gh/p2m2/Discovery/dashboard?utm_source=github.com&utm_medium=referral&utm_content=p2m2/Discovery&utm_campaign=Badge_Grade)

## Installation

```sbt
resolvers += Resolver.bintrayRepo("hmil", "maven")
libraryDependencies += "com.github.p2m2" %%% "discovery" % "0.0.2-SNAPSHOT"
```
- easy sparql query construct using a simple editor and a web browser
- display rich information on the web page or console
- offers building blocks to facilitate queries

## Library generation

```
sbt discoveryJS/fullOptJS
sbt discoveryJVM/package
sbt publishLocal
```

### Library generation html/nodejs

```bash
./update_cdn_libjs.sh
```

## test
```
sbt discoveryJVM/test
```

## coverage
```
sbt discoveryJVM/coverageReport
```

### Html/Js example

#### Html import

```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/p2m2/Discovery@master/dist/discovery-web.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/p2m2/discovery@develop/dist/discovery-web.min.js"> </script>
<script>
var SWDiscovery = discovery.SWDiscovery ;
var SWDiscoveryConfiguration = discovery.SWDiscoveryConfiguration ;
var URI = discovery.URI ;
</script>
```

[js fiddle example](https://jsfiddle.net/ofilangi/3xkay1f6/10/)
let config = SWDiscoveryConfiguration.setConfigString(`
{
"sources" : [{
"id" : "peakforest",
"url" : "https://peakforest.semantic-metabolomics.fr/sparql"
}]}
`)
let r = SWDiscovery(config)
.prefix("peak_class","https://metabohub.peakforest.org/ontology/class#")
.prefix("peak_prop","https://metabohub.peakforest.org/ontology/property#")
.root()
.something("i")
.setList(18,19,20)
.root()
.something("m1")
.isA("peak_class:Compound")
.datatype("rdfs:label","label1")
.isSubjectOf("peak_prop:InChIKey","inchikey1")
.bind("block1").subStr(0,"?i")
.root()
.something("m2")
.filter.notEqual("?m1")
.isA("peak_class:Compound")
.datatype("rdfs:label","label2")
.isSubjectOf("peak_prop:InChIKey","inchikey2")
.bind("block2").subStr(0,"?i")
.filter.equal("?block1")
.focus("m1")
.console() // display information on the console
.helper("metabo") // display information on the web page and propose new building block.
.select("m1","m2","label1","label2","block1","block2")
.limit(10);
r.commit().raw().then((response) => {
for (let i=0;i<response.results.bindings.length;i++) {
let m1 =response.results.bindings[i]["m1"].value;
let m2 =response.results.bindings[i]["m2"].value;
/* decorations/datatype properties management */
let label1=response.results.datatypes["label1"][m1][0].value; // all studies with all languages, here we take the first one arbitrarily.
let label2=response.results.datatypes["label2"][m2][0].value;
let b1 =response.results.bindings[i]["block1"].value;
let b2 =response.results.bindings[i]["block2"].value;
console.log(label1 + "-" + label2 + " block1:"+b1 + " block2:"+b2 );
}
}).catch( (error) => {
console.error(" -- catch exception --")
console.error(error)
} );
</script>
```


[js fiddle example](https://jsfiddle.net/ofilangi/h6fbg845/)

#### Node import

##### dependencies

```bash
npm install require-from-url
```

```node
var requireFromUrl = require('require-from-url/sync');
var discoveryjs = requireFromUrl("https://cdn.jsdelivr.net/gh/p2m2/Discovery@master/dist/discovery.js")

var SWDiscoveryConfiguration = discoveryjs.SWDiscoveryConfiguration ;
var SWDiscovery = discoveryjs.SWDiscovery ;
var URI = discoveryjs.URI ;
```
### html examples

[discovery-tutorial-html-js](https://github.com/p2m2/discovery-tutorial-html-js)

### NodeJs example
### NodeJs examples

[discovery-tutorial-nodejs](https://github.com/p2m2/discovery-tutorial-nodejs)

### Scala Exemple
### Scala examples

full example with [table view implementation](https://github.com/p2m2/discovery-table-view) using [scalatags](https://github.com/lihaoyi/scalatags)


## note dev

```
sbt compile
sbt run # run web app http://localhost:9000
sbt package
sbt test
sbt fastOptJS => generer le JS
sbt discoveryJVM/testOnly inrae.semantic_web.QueryPlannerTest
## local publication -> .ivy2
sbt publishLocal
## osssonatype maven centra repository publication
sbt publish
```
53 changes: 36 additions & 17 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import sbt.Keys.scalacOptions
import sbtcrossproject.CrossPlugin.autoImport.crossProject

lazy val utestVersion = "0.7.5"
lazy val utestVersion = "0.7.7"
lazy val upickleVersion = "1.2.2"
lazy val airframeLogVersion = "20.11.0"
lazy val scalaParserCombinatorVersion = "1.1.2"
lazy val scalaReflectVersion = "1.0.0"
lazy val RosHttpVersion = "3.0.0"
lazy val scalaJsDOMVersion = "1.1.0"
lazy val scalaStubVersion = "1.0.0"
lazy val scalatagVersion = "0.9.2"
lazy val jenaVersion = "3.16.0"
lazy val rdf4jVersion = "3.6.0-M2"

//https://jitpack.io/

releaseIgnoreUntrackedFiles := true

val version_build = scala.util.Properties.envOrElse("DISCOVERY_VERSION", "local-SNAPSHOT" )
val SWDiscoveryVersionAtBuildTimeFile = "./shared/src/main/scala/inrae/semantic_web/SWDiscoveryVersionAtBuildTime.scala"

Expand All @@ -25,7 +27,7 @@ val buildSWDiscoveryVersionAtBuildTimeFile =
|package inrae.semantic_web
|
|object SWDiscoveryVersionAtBuildTime {
| val version : String = "${version_build}"
| val version : String = " build ${java.time.LocalDate.now.toString}"
|}""").stripMargin)


Expand All @@ -45,6 +47,9 @@ def getPackageSetting() = Seq(
"scm:git@github.com:p2m2/Discovery.git"
)
),
developers := List(
Developer("ofilangi", "Olivier Filangi", "olivier.filangi@inrae.fr",url("https://github.com/ofilangi"))
),
credentials += {

val realm = scala.util.Properties.envOrElse("REALM_CREDENTIAL", "" )
Expand Down Expand Up @@ -85,35 +90,49 @@ lazy val discovery=crossProject(JSPlatform, JVMPlatform).in(file("."))
.settings(
resolvers += Resolver.bintrayRepo("hmil", "maven"),
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "utest" % utestVersion % "test",
"com.lihaoyi" %%% "utest" % utestVersion % Test,
"fr.hmil" %%% "roshttp" % RosHttpVersion % Test ,
"com.lihaoyi" %%% "upickle" % upickleVersion,
"org.wvlet.airframe" %%% "airframe-log" % airframeLogVersion,
"org.scala-lang.modules" %%% "scala-parser-combinators" % scalaParserCombinatorVersion,
"org.portable-scala" %%% "portable-scala-reflect" % scalaReflectVersion,
"fr.hmil" %%% "roshttp" % RosHttpVersion,
"com.softwaremill.sttp.client3" %%% "core" % "3.0.0"
"org.scala-lang.modules" %%% "scala-parser-combinators" % scalaParserCombinatorVersion
),
testFrameworks += new TestFramework("utest.runner.Framework"),
scalacOptions ++= Seq("-deprecation", "-feature"),
classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars,
coverageMinimum := 70,
coverageFailOnMinimum := false,
coverageHighlighting := true
coverageHighlighting := true,
parallelExecution in Test := false
)
.jsConfigure(_.enablePlugins(ScalaJSBundlerPlugin))
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) } ,
scalaJSLinkerConfig in (Compile, fullOptJS) ~= { _.withSourceMap(false) },
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % scalaJsDOMVersion
webpackBundlingMode := BundlingMode.LibraryAndApplication(),
npmDependencies in Compile ++= Seq(
"axios" -> "0.21.1",
"qs" -> "6.9.6",
"showdown" -> "1.9.1"
),
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv()
scalaJSLinkerConfig in (Compile, fastOptJS ) ~= {
_.withOptimizer(false)
.withPrettyPrint(true)
.withSourceMap(true)
},
scalaJSLinkerConfig in (Compile, fullOptJS) ~= {
_.withSourceMap(false)
.withModuleKind(ModuleKind.CommonJSModule)
},
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "1.1.0"
)
)
.jvmSettings(
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-stubs" % scalaStubVersion % "provided",
"org.apache.jena" % "apache-jena" % jenaVersion pomOnly()
"org.slf4j" % "slf4j-api" % "1.7.9",
"org.slf4j" % "slf4j-simple" % "1.7.9",
"org.eclipse.rdf4j" % "rdf4j-storage" % rdf4jVersion,
"org.eclipse.rdf4j" % "rdf4j-tools-federation" % rdf4jVersion
))
//.enablePlugins(ScalaJSBundlerPlugin)

Global / onChangedBuildSource := ReloadOnSourceChanges
//publishTo in ThisBuild :=

0 comments on commit d46152c

Please sign in to comment.