Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candelbio namespace, use new multitool, better README #2

Merged
merged 5 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# alzabo

A simple schema management and documentation tool for graph-based systems. [Live example](https://candelbio.github.io/alzabo/).

![Alzabo](resources/public/screenshot.png)

Alzabo does a number of different tasks centered around a simple schema format for graph databases.

- Defines an .edn schema format, with semantics similar to RDF.
Expand Down Expand Up @@ -79,14 +83,14 @@ Opens the generated documentation in browser..

## Use as a library

Add dependency `[org.parkerici/alzabo "1.0.0"]` (or whatever the lastest version is)
Add dependency `[org.candelbio/alzabo "1.0.0"]` (or whatever the lastest version is)

### Example

(ns ...
(:require [org.parkerici.alzabo.schema :as schema]
[org.parkerici.alzabo.datomic :as datomic]
[org.parkerici.alzabo.html :as html]))
(:require [org.candelbio.alzabo.schema :as schema]
[org.candelbio.alzabo.datomic :as datomic]
[org.candelbio.alzabo.html :as html]))

;; read in a schema file
(let [schema (schema/read-schema <schema.edn>)]
Expand Down
20 changes: 10 additions & 10 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(defproject org.parkerici/alzabo "1.0.0"
(defproject org.candelbio/alzabo "1.1.0"
:description "Semantic schema format and tools, for Datomic and other uses."
:url "http://github.com/ParkerICI/alzabo"
:license {:name "GPLv3"
:url "https://www.gnu.org/licenses/gpl-3.0.en.html"}
:url "http://github.com/candelbio/alzabo"
:license {:name "Apache 2 License"
:url "https://opensource.org/licenses/Apache-2.0"}
:dependencies [;; Clojure
[org.clojure/clojure "1.10.0"]
[org.clojure/clojure "1.11.1"]
[hiccup "1.0.5"]
[me.raynes/fs "1.4.6"]
;; Clojurescript
[org.clojure/clojurescript "1.10.520"]
[org.parkerici/multitool "0.0.15"]
[org.candelbio/multitool "0.1.0"]
[reagent "0.8.1"]
[re-frame "0.10.6"]
]
Expand All @@ -24,7 +24,7 @@
["cljsbuild" "once"]
["run" "resources/candel-config.edn" "server" ]
]}
:main org.parkerici.alzabo.core
:main org.candelbio.alzabo.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all
}
Expand All @@ -33,8 +33,8 @@
[figwheel-sidecar "0.5.16"]
]
:cljsbuild
{:builds {:client {:figwheel {:on-jsload "org.parkerici.alzabo.search.core/run"}
:compiler {:main "org.parkerici.alzabo.search.core"
{:builds {:client {:figwheel {:on-jsload "org.candelbio.alzabo.search.core/run"}
:compiler {:main "org.candelbio.alzabo.search.core"
:asset-path "js"
;; for 10x debugger
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
Expand All @@ -53,7 +53,7 @@
{:dependencies [[day8.re-frame/tracing-stubs "0.5.1"]]
:cljsbuild
{:builds {:client {
:compiler {:main "org.parkerici.alzabo.search.core"
:compiler {:main "org.candelbio.alzabo.search.core"
:asset-path "js"
:closure-defines {goog.DEBUG false}
:output-dir "resources/public/js"
Expand Down
Binary file added resources/public/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns org.parkerici.alzabo.candel
(ns org.candelbio.alzabo.candel
(:require [clojure.set :as set]
[clojure.string :as str]
[clojure.java.shell :as shell]
[org.parkerici.alzabo.config :as config]
[org.parkerici.alzabo.schema :as schema]
[org.parkerici.multitool.core :as u]))
[org.candelbio.alzabo.config :as config]
[org.candelbio.alzabo.schema :as schema]
[org.candelbio.multitool.core :as u]))

;;; Converts CANDEL [meta]schema into an Alzabo schema

Expand Down Expand Up @@ -114,8 +114,8 @@
kind-defs (map (fn [em]
{:parent (:kind/parent em)
;; TODO I think this will have to change to allow metamodel to be derived...maybe
:unique-id (u/dens (or (:kind/need-uid em) (:kind/context-id em)))
:label (u/dens (:kind/context-id em))
:unique-id (u/de-ns (or (:kind/need-uid em) (:kind/context-id em)))
:label (u/de-ns (:kind/context-id em))
:reference? (:kind/ref-data em)})
entity-meta)
[enums version] (read-enums)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns org.parkerici.alzabo.config
(ns org.candelbio.alzabo.config
(:require [clojure.edn :as edn]
[org.parkerici.multitool.core :as u])
[org.candelbio.multitool.core :as u])
)

(def the-config (atom nil))
Expand All @@ -20,22 +20,22 @@
([key] (get @the-config key))
([] @the-config ))

;;; TODO document or default config vars here

;;; → multitool – change to deal with keyword bindings
(defn expand-template-string
"Template is a string containing {foo} elements, which get replaced by corresponding values from bindings"
[template bindings]
(let [matches (->> (re-seq u/template-regex template)
(let [matches (->> (re-seq u/param-regex template)
(map (fn [[match key]]
[match (or (bindings key) (bindings (keyword key)) "")])))]
(reduce (fn [s [match key]]
(clojure.string/replace s (u/re-pattern-literal match) (str key)))
template matches)))

;;; TODO document or default config vars here

(defn output-path
[filename]
(str (expand-template-string (config :output-path) config)
(str (expand-template-string (config :output-path) (config))
filename))


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns org.parkerici.alzabo.core
(:require [org.parkerici.alzabo.candel :as candel]
[org.parkerici.alzabo.schema :as schema]
[org.parkerici.alzabo.config :as config]
[org.parkerici.alzabo.html :as html]
[org.parkerici.alzabo.output :as output]
[org.parkerici.alzabo.datomic :as datomic]
[org.parkerici.multitool.core :as u])
(ns org.candelbio.alzabo.core
(:require [org.candelbio.alzabo.candel :as candel]
[org.candelbio.alzabo.schema :as schema]
[org.candelbio.alzabo.config :as config]
[org.candelbio.alzabo.html :as html]
[org.candelbio.alzabo.output :as output]
[org.candelbio.alzabo.datomic :as datomic]
[org.candelbio.multitool.core :as u])
(:gen-class))

;;; Note: CLI use is somewhat deprecated; it's expected that Alzabo will be used
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns org.parkerici.alzabo.datomic
(:require [org.parkerici.multitool.core :as u]
[org.parkerici.alzabo.schema :as alzs]
(ns org.candelbio.alzabo.datomic
(:require [org.candelbio.multitool.core :as u]
[org.candelbio.alzabo.schema :as alzs]
))

;;; Write out a Datomic schema from Alzabo schema
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns org.parkerici.alzabo.html
(:require [org.parkerici.alzabo.schema :as schema]
[org.parkerici.alzabo.config :as config]
[org.parkerici.multitool.core :as u]
(ns org.candelbio.alzabo.html
(:require [org.candelbio.alzabo.schema :as schema]
[org.candelbio.alzabo.config :as config]
[org.candelbio.multitool.core :as u]
[clojure.string :as s]
[clojure.pprint :as pp]
[me.raynes.fs :as fs]
Expand Down Expand Up @@ -177,11 +177,11 @@
(for [enum (sort (keys enums))]
(html [:li (kind-html enum)]))]]
;; Pass the schema to clojurescript widget inside an invisible div
;; See org.parkerici.alzabo.search.core/get-schema
;; See org.candelbio.alzabo.search.core/get-schema
[:div#aschema {:style (style-arg {:display "none"})}
(str schema)]
[:script {:src "js/client.js"}]
[:script "window.onload = function() { org.parkerici.alzabo.search.core.run(); }"]
[:script "window.onload = function() { org.candelbio.alzabo.search.core.run(); }"]
]]
)))

Expand All @@ -206,7 +206,7 @@
res))

;;; To use this, do 'brew install graphviz' first (on Mac)
(def dot-command "dot")
(def dot-command "/usr/local/bin/dot")

;;; Font should be available in Docker build image
(def graph-font "Helvetica")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns org.parkerici.alzabo.output
(ns org.candelbio.alzabo.output
(:require [clojure.pprint :as pprint]
[clojure.java.io :as io]
[me.raynes.fs :as fs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns org.parkerici.alzabo.schema
(ns org.candelbio.alzabo.schema
(:require [clojure.spec.alpha :as s]))

(def primitives #{:long :float :string :boolean :instant :keyword})
Expand All @@ -21,7 +21,9 @@
(s/def ::fields (s/map-of keyword? ::field))

(s/def ::kind (s/keys :req-un [::fields] ;::inherits, but CANDEL not using that.
:opt-un [::doc ::reference?]))
:opt-un [::doc
::uri
::reference?])) ;TODO reference is too CANDEL-specific, replace with a kind-labels or tags or something

(s/def ::kinds (s/map-of keyword? ::kind :conform-keys? true))

Expand All @@ -35,6 +37,8 @@

(s/def ::version string?)

(s/def ::uri (s/or :string string? :key keyword?))

(s/def ::schema (s/keys :req-un [::kinds]
:opt-un [::enums ::version ::title]))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns org.parkerici.alzabo.search.lexicon
(ns org.candelbio.alzabo.search.lexicon
(:require [clojure.string :as str]
[org.parkerici.multitool.nlp :as nlp]))
[org.candelbio.multitool.nlp :as nlp]))

(defn add-def-word [dict word def]
(let [word (str/lower-case word)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns org.parkerici.alzabo.search.core
(ns org.candelbio.alzabo.search.core
(:require [reagent.core :as reagent]
[re-frame.core :as rf]
[clojure.reader :as reader]
[org.parkerici.alzabo.search.lexicon :as lex]
[org.candelbio.alzabo.search.lexicon :as lex]
))

;; Get the schema from an invisible div on the page
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns org.parkerici.alzabo.core-test
(:require [org.parkerici.alzabo.core :as sut]
(ns org.candelbio.alzabo.core-test
(:require [org.candelbio.alzabo.core :as sut]
[me.raynes.fs :as fs]
[clojure.test :refer :all]))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns org.parkerici.alzabo.datomic-test
(:require [org.parkerici.alzabo.datomic :refer :all]
[org.parkerici.alzabo.schema :as schema]
(ns org.candelbio.alzabo.datomic-test
(:require [org.candelbio.alzabo.datomic :refer :all]
[org.candelbio.alzabo.schema :as schema]
[clojure.test :refer :all]
))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(ns org.parkerici.alzabo.html-test
(ns org.candelbio.alzabo.html-test
(:require [clojure.test :refer :all]
[org.parkerici.alzabo.schema :as schema]
[org.parkerici.alzabo.config :as config]
[org.candelbio.alzabo.schema :as schema]
[org.candelbio.alzabo.config :as config]
[me.raynes.fs :as fs]
[org.parkerici.alzabo.html :refer :all]))
[org.candelbio.alzabo.html :refer :all]))

;;; TODO this machinery should be for all tests
(def test-config "test/resources/test-config.edn")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns org.parkerici.alzabo.roundtrip
(ns org.candelbio.alzabo.roundtrip
(:require [clojure.data :as data]
[clojure.pprint :refer [pprint]]
[org.parkerici.alzabo.output :as output]
[org.parkerici.alzabo.candel :as candel]
[org.parkerici.alzabo.config :as config]
[org.parkerici.alzabo.datomic :as datomic]
[org.parkerici.multitool.core :as u]))
[org.candelbio.alzabo.output :as output]
[org.candelbio.alzabo.candel :as candel]
[org.candelbio.alzabo.config :as config]
[org.candelbio.alzabo.datomic :as datomic]
[org.candelbio.multitool.core :as u]))

;;; TODO finish?
;;; Experiments in roundtripping.
Expand Down
Loading