├── .gitignore ├── script ├── cibuild └── test ├── project.clj ├── benches └── laboratory │ └── benchmarks.clj ├── test └── laboratory │ └── experiment_test.clj ├── README.md ├── src └── laboratory │ └── experiment.clj └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | -------------------------------------------------------------------------------- /script/cibuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$JANKY_SHA1" ]; then 4 | lein test 5 | else 6 | lein test 7 | lein with-profile benches run -m laboratory.benchmarks 8 | fi 9 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | grench eval "(do (require 'bolth.test) (bolth.test/pretty-refresh) nil)" 5 | grench eval "(do (require 'bolth.test) (bolth.test/run-all-tests #\"laboratory.*\") nil)" 6 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject laboratory "0.1.0-SNAPSHOT" 2 | :description "do science in production" 3 | :url "https://github.com/yeller/laboratory" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"]]} 8 | :benches {:dependencies [[criterium "0.4.1"]] 9 | :source-paths ["src" "benches"]}} 10 | :global-vars {*warn-on-reflection* true 11 | *unchecked-math* :warn-on-boxed 12 | ;*compiler-options* {:disable-locals-clearing true} 13 | *assert* true}) 14 | -------------------------------------------------------------------------------- /benches/laboratory/benchmarks.clj: -------------------------------------------------------------------------------- 1 | (ns laboratory.benchmarks 2 | (:require [criterium.core :as criterium] 3 | [laboratory.experiment :as science])) 4 | 5 | (defmacro bench [bench-name & body] 6 | `(do 7 | (println ~bench-name) 8 | (println "======================================================") 9 | (println) 10 | (criterium/bench 11 | ~@body))) 12 | 13 | (def experiment-with-broken-candidate 14 | {:use (fn [] 1) 15 | :try (fn [] 2)}) 16 | 17 | (def with-one-arg 18 | {:use (fn [user] (:email user)) 19 | :try (fn [user] (:email user))}) 20 | 21 | (def with-two-args 22 | {:use (fn [user _] (:email user)) 23 | :try (fn [user _] (:email user))}) 24 | 25 | (def with-three-args 26 | {:use (fn [user _ _] (:email user)) 27 | :try (fn [user _ _] (:email user))}) 28 | 29 | (defn -main [& args] 30 | (bench "with-no-args-map" 31 | (science/run experiment-with-broken-candidate)) 32 | 33 | (let [faster-experiment (science/make-it-faster! experiment-with-broken-candidate)] 34 | (bench "with-no-args-record" 35 | (science/run faster-experiment))) 36 | 37 | (bench "with-one-arg-map" 38 | (science/run with-one-arg {:email "tom@tcrayford.com"})) 39 | 40 | (let [faster-experiment (science/make-it-faster! with-one-arg)] 41 | (bench "with-one-arg-record" 42 | (science/run faster-experiment {:email "tom@tcrayford.com"}))) 43 | 44 | (bench "with-two-arg-map" 45 | (science/run with-two-args {:email "tom@tcrayford.com"} 1)) 46 | 47 | (let [faster-experiment (science/make-it-faster! with-two-args)] 48 | (bench "with-two-arg-record" 49 | (science/run faster-experiment {:email "tom@tcrayford.com"} 1))) 50 | 51 | (bench "with-three-args" 52 | (science/run with-three-args {:email "tom@tcrayford.com"} 1 2)) 53 | 54 | (let [faster-experiment (science/make-it-faster! with-three-args)] 55 | (bench "with-three-args-record" 56 | (science/run faster-experiment {:email "tom@tcrayford.com"} 1 2)))) 57 | -------------------------------------------------------------------------------- /test/laboratory/experiment_test.clj: -------------------------------------------------------------------------------- 1 | (ns laboratory..experiment-test 2 | (:require [clojure.test :refer :all] 3 | [laboratory.experiment :as science])) 4 | 5 | (deftest run-experiment-test 6 | (testing "always returns the control result" 7 | (is (= (science/run {:use (fn [] 1) 8 | :try (fn [] 2) 9 | :publish identity}) 10 | 1))) 11 | 12 | (testing "doesn't blow up if the candidate throws an exception" 13 | (is (= (science/run {:use (fn [] 1) 14 | :try (fn [] (throw (ex-info "blowing up" {}))) 15 | :publish identity}) 16 | 1))) 17 | 18 | (testing "blows up if the control blows up" 19 | (is (thrown? Exception (science/run {:use (fn [] (throw (ex-info "blowing up" {}))) 20 | :try (fn [] 1) 21 | :publish identity})))) 22 | 23 | (testing "publishes the values" 24 | (let [published (atom nil)] 25 | (science/run {:use (fn [] 1) 26 | :try (fn [] 2) 27 | :publish (fn [result] 28 | (reset! published result))}) 29 | (is (= (-> @published :control :value) 1)) 30 | (is (= (-> @published :candidate :value) 2)))) 31 | 32 | (testing "publishes the durations" 33 | (let [published (atom nil)] 34 | (science/run {:use (fn [] 1) 35 | :try (fn [] 2) 36 | :publish (fn [result] 37 | (reset! published result))}) 38 | (is (pos? (-> @published :control :metrics :duration-ns))) 39 | (is (pos? (-> @published :candidate :metrics :duration-ns))))) 40 | 41 | (testing "publishes the user-defined metrics, in addition to durations" 42 | (let [published (atom nil)] 43 | (science/run {:use (fn [] 1) 44 | :try (fn [] 2) 45 | :publish (fn [result] 46 | (reset! published result)) 47 | :metrics {:a-number #(inc (rand-int 10))}}) 48 | (is (pos? (-> @published :control :metrics :duration-ns))) 49 | (is (pos? (-> @published :candidate :metrics :duration-ns))) 50 | (is (number? (-> @published :control :metrics :a-number))) 51 | (is (number? (-> @published :candidate :metrics :a-number))))) 52 | 53 | (testing "doesn't publish if the experiment is disabled" 54 | (let [published (atom nil)] 55 | (science/run {:use (fn [] 1) 56 | :try (fn [] 2) 57 | :publish (fn [result] (reset! published result)) 58 | :enabled (fn [] false)}) 59 | (is (= @published nil)))) 60 | 61 | (testing "experiment is disabled if it isn't published" 62 | (let [tried (atom nil)] 63 | (science/run {:use (fn [] 1) 64 | :try (fn [] (reset! tried 2))}) 65 | (is (= @tried nil)))) 66 | 67 | (testing "it returns the result after being made faster" 68 | (is (= (science/run (science/map->Experiment {:use (fn [] 1) 69 | :try (fn [] 2) 70 | :metrics {} 71 | :publish identity 72 | :enabled (constantly true)})) 73 | 1))) 74 | 75 | (dotimes [n 10] 76 | (testing (str "it works with " n " args") 77 | (let [experiment (eval `{:use (fn [~@(map symbol (map #(str "arg" %) (range n)))] 1) 78 | :try (fn [~@(map symbol (map #(str "arg" %) (range n)))] 2) 79 | :enabled (fn [~@(map symbol (map #(str "arg" %) (range n)))] true) 80 | :metrics {} 81 | :publish identity})] 82 | (is (= 1 (apply science/run experiment (range n)))) 83 | (is (= 1 (apply science/run (science/map->Experiment experiment) (range n))))))) 84 | 85 | (dotimes [n 10] 86 | (testing (str "it works with " n " args") 87 | (let [experiment (eval `{:use (fn [~@(map symbol (map #(str "arg" %) (range n)))] 1) 88 | :try (fn [~@(map symbol (map #(str "arg" %) (range n)))] 2) 89 | :enabled (fn [~@(map symbol (map #(str "arg" %) (range n)))] false) 90 | :metrics {} 91 | :publish identity})] 92 | (is (= 1 (apply science/run experiment (range n)))) 93 | (is (= 1 (apply science/run (science/map->Experiment experiment) (range n)))))))) 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > This isn't SCIENCE this is PRODUCTION 2 | 3 | # laboratory 4 | 5 | A Clojure library designed to help you experiment in production. 6 | https://github.com/github/scientist, but for Clojure (api and readme liberally stolen) 7 | 8 | ## Usage 9 | 10 | ```clojure 11 | (require '[laboratory.experiment :as science]) 12 | 13 | (def my-experiment 14 | {:name "widget-permissions" 15 | :use (fn [widget user] (check-user? widget user)) 16 | :try (fn [widget user] (allowed-to? :read user widget)) 17 | :publish prn}) 18 | 19 | (science/run my-experiment widget user) 20 | ``` 21 | 22 | laboratory runs experiments as *functions*. 23 | Whatever arguments you pass to `run` are also passed to `:try` and `:use`. 24 | The function under `:use` is the "control" (the original code you used to have). 25 | The function under `:try` is the "experiment" (the new code that you want to compare). 26 | 27 | Experiments are just maps with some data and functions in them. 28 | There are a lot of options though. `:use`, `:try` and `:name` are the only required keys, 29 | but experiments won't run if their results aren't published. 30 | 31 | ### Making Science Useful 32 | 33 | The above example will run, but it's only printing out results. 34 | To make it more useful, the `:publish` function could be enhanced: 35 | 36 | ```clojure 37 | :publish (fn [result] ; whatever you want to do on results happens here 38 | ) 39 | ``` 40 | 41 | ## Results 42 | 43 | Results passed to `:publish` are a Record: 44 | 45 | ``` 46 | {:name "widget-permissions" 47 | :experiment {the original experiment map/record} 48 | :args [a vector of the args passed to the use/try functions] 49 | :control 50 | { 51 | :metrics {:duration-ns 10} ; number of nanoseconds the control took 52 | :value true ; whatever value your :use function returned 53 | } 54 | :candidate 55 | { 56 | :metrics {:duration-ns 3} ; number of nanoseconds the candidate took 57 | :value true ; whatever value your :try function returned 58 | } 59 | } 60 | ``` 61 | 62 | ## Ramping up Experiments 63 | 64 | ### Deciding to enable an experiment 65 | 66 | To control if your `:try` function runs, you can pass a `:enabled` function in an experiment: 67 | 68 | ```clojure 69 | :enabled (fn [widget user] (is-staff? user)) 70 | ``` 71 | 72 | Note that this function will be called for every invocation of every experiment. 73 | Be very sensitive to it's performance. 74 | Feature flags are recommended - consider using something like https://github.com/yeller/shoutout for this. 75 | 76 | ### User-defined metrics 77 | 78 | Experiments can also execute user-defined metrics for the control and the candidate. 79 | Metrics are 0-arity functions that return some number. Metrics are called before 80 | and after executing the function under inspection, and the difference is logged 81 | in the result's `:metrics`. 82 | 83 | An experiment will take a map of additional metrics. Additional metrics will 84 | have an impact on experiment execution time - be mindful of performance. 85 | Here is an experiment that calculates a very crude memory metric: 86 | 87 | ```clojure 88 | (require '[laboratory.experiment :as science]) 89 | 90 | (def my-experiment 91 | {:name "widget-permissions" 92 | :use (fn [widget user] (check-user? widget user)) 93 | :try (fn [widget user] (allowed-to? :read user widget)) 94 | :publish prn 95 | :metrics {:bytes-used #(- (.totalMemory (Runtime/getRuntime)) 96 | (.freeMemory (Runtime/getRuntime)))}}) 97 | 98 | (science/run my-experiment widget user) 99 | ``` 100 | 101 | ## Faster, more Validated Science 102 | 103 | Defining experiments as maps is easy and very flexible, however, their impact on the JVM will be noticeable. 104 | You may optionally use the `Experiment` record to enhance performance, but you 105 | must supply all experiment keys `[:enabled :publish :metrics :use :try]`: 106 | 107 | ```clojure 108 | (science/map->Experiment my-experiment) ; returns a record 109 | ``` 110 | 111 | ## Rationale 112 | 113 | Feature flags are *great* for rolling out production code changes gradually. 114 | But they don't go far enough for changes to critical paths - there's nothing in them about comparing results, or comparing performance of each side. 115 | That's where laboratory comes in. 116 | 117 | ## Non-Goals 118 | 119 | laboratory leaves choice of metrics system, how to record mismatches, how to enable experiments for particular cases all up to you. 120 | 121 | ## Punted On 122 | 123 | See `Non-Goals` 124 | 125 | ## Future Work 126 | 127 | See `Non-Goals` 128 | 129 | ## Open Questions 130 | 131 | See `Non-Goals` 132 | 133 | Shoutout to Brandon Bloom 134 | 135 | ## License 136 | 137 | Copyright © 2015 Tom Crayford 138 | 139 | Distributed under the Eclipse Public License either version 1.0 or (at 140 | your option) any later version. 141 | -------------------------------------------------------------------------------- /src/laboratory/experiment.clj: -------------------------------------------------------------------------------- 1 | (ns laboratory.experiment) 2 | 3 | (defrecord Experiment [enabled publish metrics use try]) 4 | (defrecord ExperimentSideResult [value metrics]) 5 | (defrecord ExperimentResult [name experiment args control candidate]) 6 | 7 | (def always-enabled (constantly true)) 8 | (def publish-nowhere (constantly nil)) 9 | 10 | (defn nanos->ms [^long nanos] 11 | (float (/ nanos 1000000))) 12 | 13 | (defn run-with-result 14 | ([f metrics] 15 | (let [metrics0 (mapv #(%) (vals metrics)) 16 | t0 (System/nanoTime) 17 | result (try (f) (catch Exception e e)) 18 | t1 (System/nanoTime) 19 | metrics1 (mapv #(%) (vals metrics))] 20 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 21 | (zipmap (keys metrics) (map - metrics1 metrics0)))))) 22 | ([f metrics arg1] 23 | (let [metrics0 (mapv #(%) (vals metrics)) 24 | t0 (System/nanoTime) 25 | result (try (f arg1) (catch Exception e e)) 26 | t1 (System/nanoTime) 27 | metrics1 (mapv #(%) (vals metrics))] 28 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 29 | (zipmap (keys metrics) (map - metrics1 metrics0)))))) 30 | ([f metrics arg1 arg2] 31 | (let [metrics0 (mapv #(%) (vals metrics)) 32 | t0 (System/nanoTime) 33 | result (try (f arg1 arg2) (catch Exception e e)) 34 | t1 (System/nanoTime) 35 | metrics1 (mapv #(%) (vals metrics))] 36 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 37 | (zipmap (keys metrics) (map - metrics1 metrics0)))))) 38 | ([f metrics arg1 arg2 arg3] 39 | (let [metrics0 (mapv #(%) (vals metrics)) 40 | t0 (System/nanoTime) 41 | result (try (f arg1 arg2 arg3) (catch Exception e e)) 42 | t1 (System/nanoTime) 43 | metrics1 (mapv #(%) (vals metrics))] 44 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 45 | (zipmap (keys metrics) (map - metrics1 metrics0)))))) 46 | 47 | ([f metrics arg1 arg2 arg3 arg4] 48 | (let [metrics0 (mapv #(%) (vals metrics)) 49 | t0 (System/nanoTime) 50 | result (try (f arg1 arg2 arg3 arg4) (catch Exception e e)) 51 | t1 (System/nanoTime) 52 | metrics1 (mapv #(%) (vals metrics))] 53 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 54 | (zipmap (keys metrics) (map - metrics1 metrics0)))))) 55 | ([f metrics arg1 arg2 arg3 arg4 & args] 56 | (let [metrics0 (mapv #(%) (vals metrics)) 57 | t0 (System/nanoTime) 58 | result (try (apply f arg1 arg2 arg3 arg4 args) (catch Exception e e)) 59 | t1 (System/nanoTime) 60 | metrics1 (mapv #(%) (vals metrics))] 61 | (->ExperimentSideResult result (merge {:duration-ns (unchecked-subtract t1 t0)} 62 | (zipmap (keys metrics) (map - metrics1 metrics0))))))) 63 | 64 | (defn make-result [experiment args control-result candidate-result] 65 | (->ExperimentResult (:name experiment) experiment args control-result candidate-result)) 66 | 67 | (defn run 68 | "Given an experiment map 69 | Run the experiment, capturing the `:duration-ns` and other experiment `:metrics`. 70 | If the results aren't `:publish`ed, the experiment isn't run, 71 | if no one is looking at the results, the experiment isn't worth conducting." 72 | ([experiment] 73 | (if (and ((:enabled experiment always-enabled)) 74 | (:publish experiment)) 75 | (let [control-result (run-with-result (:use experiment) (:metrics experiment)) 76 | candidate-result (run-with-result (:try experiment) (:metrics experiment))] 77 | ((:publish experiment publish-nowhere) (make-result experiment [] control-result candidate-result)) 78 | (if (instance? Throwable (:value control-result)) 79 | (throw (:value control-result)) 80 | (:value control-result))) 81 | ((:use experiment)))) 82 | 83 | ([experiment arg1] 84 | (if (and ((:enabled experiment always-enabled) arg1) 85 | (:publish experiment)) 86 | (let [control-result (run-with-result (:use experiment) (:metrics experiment) arg1) 87 | candidate-result (run-with-result (:try experiment) (:metrics experiment) arg1)] 88 | ((:publish experiment publish-nowhere) (make-result experiment [arg1] control-result candidate-result)) 89 | (if (instance? Throwable (:value control-result)) 90 | (throw (:value control-result)) 91 | (:value control-result))) 92 | ((:use experiment) arg1))) 93 | 94 | ([experiment arg1 arg2] 95 | (if (and ((:enabled experiment always-enabled) arg1 arg2) 96 | (:publish experiment)) 97 | (let [control-result (run-with-result (:use experiment) (:metrics experiment) arg1 arg2) 98 | candidate-result (run-with-result (:try experiment) (:metrics experiment) arg1 arg2)] 99 | ((:publish experiment publish-nowhere) (make-result experiment [arg1 arg2] control-result candidate-result)) 100 | (if (instance? Throwable (:value control-result)) 101 | (throw (:value control-result)) 102 | (:value control-result))) 103 | ((:use experiment) arg1 arg2))) 104 | 105 | 106 | ([experiment arg1 arg2 arg3] 107 | (if (and ((:enabled experiment always-enabled) arg1 arg2 arg3) 108 | (:publish experiment)) 109 | (let [control-result (run-with-result (:use experiment) (:metrics experiment) arg1 arg2 arg3) 110 | candidate-result (run-with-result (:try experiment) (:metrics experiment) arg1 arg2 arg3)] 111 | ((:publish experiment publish-nowhere) (make-result experiment [arg1 arg2 arg3] control-result candidate-result)) 112 | (if (instance? Throwable (:value control-result)) 113 | (throw (:value control-result)) 114 | (:value control-result))) 115 | ((:use experiment) arg1 arg2 arg3))) 116 | 117 | ([experiment arg1 arg2 arg3 arg4] 118 | (if (and ((:enabled experiment always-enabled) arg1 arg2 arg3 arg4) 119 | (:publish experiment)) 120 | (let [control-result (run-with-result (:use experiment) (:metrics experiment) arg1 arg2 arg3 arg4) 121 | candidate-result (run-with-result (:try experiment) (:metrics experiment) arg1 arg2 arg3 arg4)] 122 | ((:publish experiment publish-nowhere) (make-result experiment [arg1 arg2 arg3 arg4] control-result candidate-result)) 123 | (if (instance? Throwable (:value control-result)) 124 | (throw (:value control-result)) 125 | (:value control-result))) 126 | ((:use experiment) arg1 arg2 arg3 arg4))) 127 | 128 | ([experiment arg1 arg2 arg3 arg4 & args] 129 | (if (and (apply (:enabled experiment always-enabled) arg1 arg2 arg3 arg4 args) 130 | (:publish experiment)) 131 | (let [control-result (apply run-with-result (:use experiment) (:metrics experiment) arg1 arg2 arg3 arg4 args) 132 | candidate-result (apply run-with-result (:try experiment) (:metrics experiment) arg1 arg2 arg3 arg4 args)] 133 | ((:publish experiment publish-nowhere) (make-result experiment (into [arg1 arg2 arg3 arg4] args) control-result candidate-result)) 134 | (if (instance? Throwable (:value control-result)) 135 | (throw (:value control-result)) 136 | (:value control-result))) 137 | (apply (:use experiment) arg1 arg2 arg3 arg4 args)))) 138 | 139 | 140 | (comment 141 | 142 | (defn add5 [x] 143 | (+ x 5)) 144 | 145 | (defn add5fast [^long x] 146 | (unchecked-add x 5)) 147 | 148 | (def experiment {:name "Add5" 149 | :use add5 150 | :try add5fast 151 | :publish prn 152 | :metrics {:used-bytes #(- (.totalMemory (Runtime/getRuntime)) 153 | (.freeMemory (Runtime/getRuntime)))}}) 154 | 155 | (time (add5fast 1)) 156 | (time (run experiment 1)) 157 | ) 158 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | --------------------------------------------------------------------------------