Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47b44e3
commit 636d1f5
Showing
23 changed files
with
1,278 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(ns clojush.cli.log | ||
(:require [puget.printer :as puget] | ||
[plumbing.fnk.pfnk :as pfnk] | ||
[plumbing.core :refer [map-vals]] | ||
|
||
[clojush.log.events :refer [label->compute-graph]] | ||
[clojush.log.events.generation.individual :as individual]) | ||
(:import (schema.core.Predicate) | ||
(schema.core.AnythingSchema))) | ||
|
||
(def schema-handlers | ||
{schema.core.Predicate (fn [_1 _2] nil) | ||
schema.core.AnythingSchema (fn [_1 _2] nil)}) | ||
|
||
(defn my-print [form] | ||
(puget/cprint | ||
form | ||
{:print-handlers schema-handlers})) | ||
|
||
|
||
(defn event-inputs | ||
"Prints the mapping of each event to it's outputs" | ||
[& args] | ||
(my-print | ||
(map-vals pfnk/input-schema label->compute-graph))) | ||
|
||
(defn event-outputs | ||
"Prints the mapping of each event to it's inputs" | ||
[& args] | ||
(my-print | ||
(map-vals pfnk/output-schema label->compute-graph))) | ||
|
||
|
||
(defn individual-input [& args] | ||
(my-print | ||
(pfnk/input-schema | ||
individual/compute-graph))) | ||
|
||
(defn individual-output [& args] | ||
(my-print | ||
(pfnk/output-schema | ||
individual/compute-graph))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns clojush.log | ||
(:require [clojush.structured-logger :refer [->structured-logger]] | ||
[clojush.log.events :refer [label->compute-graph]] | ||
[clojush.log.handlers :refer [handlers]])) | ||
;; this stuff is spread out over many files in subdirectories | ||
;; Not only does this help with keeping files shorter, but it also allows | ||
;; us to use the defnk names directly in the graph, because we don't | ||
;; have to namespace them. For example, if we define `best` in the | ||
;; lexicase file, then we can just throw that in the graph we defined | ||
;; there, and it will registered under :best. | ||
|
||
(def structured-logger | ||
(->structured-logger | ||
{:handlers handlers | ||
:label->compute-graph label->compute-graph})) | ||
|
||
(def log! (:log! structured-logger)) | ||
|
||
(def get-computed (:get-computed structured-logger)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(ns clojush.log.events | ||
(:require [clojush.log.events.init] | ||
[clojush.log.events.config] | ||
[clojush.log.events.generation])) | ||
|
||
(def label->compute-graph | ||
{:init clojush.log.events.init/compute-graph | ||
:config clojush.log.events.config/compute-graph | ||
:generation clojush.log.events.generation/compute-graph}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns clojush.log.events.config | ||
(:require [plumbing.core :refer [defnk]] | ||
[plumbing.graph :as graph] | ||
[clj-random.core :as random] | ||
[local-file] | ||
[clojure.string :as string])) | ||
|
||
(defnk clojush-version [] | ||
(let [version-str (apply str (butlast (re-find #"\".*\"" | ||
(first (string/split-lines | ||
(local-file/slurp* "project.clj"))))))] | ||
(.substring version-str 1 (count version-str)))) | ||
|
||
(defnk argmap [argmap-input] | ||
argmap-input) | ||
|
||
(defnk registered-instructions [registered-instructions-input] | ||
registered-instructions-input) | ||
|
||
(defnk argmap-with-random-str [argmap-input] | ||
(update argmap :random-seed random/seed-to-string)) | ||
|
||
(defnk git-hash [] | ||
(let [dir (local-file/project-dir)] | ||
(string/trim | ||
(slurp | ||
(str dir | ||
"/.git/" | ||
(subs | ||
(string/trim | ||
(slurp | ||
(str dir "/.git/HEAD"))) | ||
5)))))) | ||
|
||
(defnk initialization-ms [timing-map] | ||
(:initialization timing-map)) | ||
|
||
(def compute-graph | ||
(graph/graph | ||
clojush-version | ||
argmap | ||
registered-instructions | ||
git-hash | ||
initialization-ms | ||
argmap-with-random-str)) |
Oops, something went wrong.