<commit_before>(ns duratom.core-test
  (:require [clojure.test :refer :all]
            [duratom.core :refer :all]
            [duratom.utils :as ut]
            [taoensso.nippy :as nippy]
            [clojure.java
             [shell :as shell]
             [io :as io]]
            [clojure.string :as str])
  (:import (clojure.lang Agent)))

(defonce docker-default-machine-ip
  ;; `localhost` which works on Ubuntu simply won't work on MacOS.
  ;; we need the public IP of the docker-machine - `default` in this case.
  ;; this tends to be 192.168.99.100, but we can easily check via `docker-machine ip default`
  (delay
    (or (try
          (some-> (shell/sh "docker-machine" "ip" "default")
                  :out
                  str/trim-newline
                  not-empty)
          (catch Throwable _))
        ;; per https://devilbox.readthedocs.io/en/latest/howto/docker-toolbox/find-docker-toolbox-ip-address.html
        "192.168.99.100")))

(defn- common*
  [dura exists? async?]
  (let [sleep-time 200
        [f atom?] (if (instance? Agent dura)
                    [send-off false]
                    [swap! true])]
    (-> dura ;; init = {:x 1 :y 2}
        (doto (f assoc :z 3))
        (doto (f dissoc :x)))

    (when async?
      (Thread/sleep sleep-time))

    (is (= {:z 3 :y 2} @dura))
    (is (= (backend-snapshot dura) @dura))

    (-> dura
        (doto (f  (constantly [1 2 3])))
        (doto (f  (comp vec rest))))

    (when async?
      (Thread/sleep sleep-time))<commit_msg>add running instructions in the form of comments in core_test.clj<commit_after>(ns duratom.core-test
  (:require [clojure.test :refer :all]
            [duratom.core :refer :all]
            [duratom.utils :as ut]
            [taoensso.nippy :as nippy]
            [clojure.java
             [shell :as shell]
             [io :as io]]
            [clojure.string :as str])
  (:import (clojure.lang Agent)))
;====================================
;; start the `default` VM:
;$ docker-machine start default

;; switch to `default` when using any docker commands
;$ eval $(docker-machine env default)

;; start up the specified containers
;$ docker-compose up -d

;; run tests
; lein test OR selectively in repl

;; shutdown the containers
;$ docker-compose down
;====================================

(defonce docker-default-machine-ip
  ;; `localhost` which works on Ubuntu simply won't work on MacOS.
  ;; we need the public IP of the docker-machine - `default` in this case.
  ;; this tends to be 192.168.99.100, but we can easily check via `docker-machine ip default`
  (delay
    (or (try
          (some-> (shell/sh "docker-machine" "ip" "default")
                  :out
                  str/trim-newline
                  not-empty)
          (catch Throwable _))
        ;; perhaps docker-machine is not involved
        "localhost")))

(defn- common*
  [dura exists? async?]
  (let [sleep-time 200
        [f atom?] (if (instance? Agent dura)
                    [send-off false]
                    [swap! true])]
    (-> dura ;; init = {:x 1 :y 2}
        (doto (f assoc :z 3))
        (doto (f dissoc :x)))

    (when async?
      (Thread/sleep sleep-time))

    (is (= {:z 3 :y 2} @dura))
    (is (= (backend-snapshot dura) @dura))

    (-> dura
        (doto (f  (constantly [1 2 3])))
        (doto (f  (comp vec rest))))

    (when async?
      (Thread/sleep sleep-time))
{'fraction_non_alphanumeric': 0.1555424875036754, 'fraction_numerical': 0.016171714201705382, 'mean_word_length': 2.0429338103756707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177291', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1090, 'n_words': 341}