Skip to content

Recompute flag in clojure math runner is ignored, and somewhat unclear in config #1914

@jucor

Description

@jucor

TLDR: @metasoarous , do you remember please:

  • did you you ever managed to get the recompute flag working as you wanted?
  • if so, what cases did you use it for, please?
  • or is it vestigial code that could be removed?
    Thanks !

Details:

The clojure runner for math worker has a --recompute flags it advertises, which is supposed to "recompute conversations from scratch", rather than incrementally from last known position:

(def cli-options
"Has the same options as simulation if simulations are run"
[["-r" "--recompute" "Recompute conversations from scratch instead of starting from most recent values"]

I was hoping to use it for several tests.

However, it seems that while it is parsed, it is not used.
If I understand correctly the clojure code-base (with Cursor's help, so I'm treading carefully), it should be passed to conv-man/load-or-init, but it is not:

(defn update-conv
[conv-man zid]
(try
(let [conv (conv-man/load-or-init conv-man zid)

That function itself would then (were it called with that keyword, which it isn't) take it into account here:

(defn load-or-init
"Given a zid, either load a minimal set of information from postgres, or if a new zid, create a new conv"
[conv-man zid & {:keys [recompute]}]
;; TODO On recompute should try to preserve in conv and such
(log/info "Running load or init")
(if-let [conv (and (not recompute) (db/load-conv (:postgres conv-man) zid))]
(-> conv
;(->> (tr/trace "load-or-init (about to restructure):"))
restructure-json-conv
;(->> (tr/trace "load-or-init (post restructure):"))
;; What the fuck is this all about? Should this really be getting set here?
(assoc :recompute :reboot)
(assoc :raw-rating-mat
(-> (nm/named-matrix)
(nm/update-nmat (->> (db/conv-poll (:postgres conv-man) zid 0)
(map (fn [vote-row] (mapv (partial get vote-row) [:pid :tid :vote])))))))
(conv/mod-update
(db/conv-mod-poll (:postgres conv-man) zid 0)))
; would be nice to have :recompute :initial
(assoc (conv/new-conv) :zid zid :recompute :full)))

but the surprise expressed in the comments make me think it might not be entirely working as intended...

Beyond the runner, the load-or-init is only called in one place with potentially the :recompute flag, in conv-actor:

(defn conv-actor
[{:as conv-man :keys [conversations kill-chan config]} zid]
(log/info "Starting message batch queue and handler routine for conv zid:" zid)
(let [conv (load-or-init conv-man zid :recompute (:recompute config))

depending on the configuration defined in components/config.clj, which also come with comments showing some amount of uncertainty:
;; Need to think more about the semantics of a recompute; once; always; only if not booted; etc? XXX
:recompute {:parse ->boolean
:doc "Whether or not to perform a recompute"}

This would require the RECOMPUTE environment variable to set that flag. It is not set in example.env, nor can I see any trace of it anywhere else in the codebase. Therefore if it has ever been used, it has been done manually on an instance.

So it's unclear how much the recompute feature has been used, and for what, and whether the runner should be modified to allow for its use, or on the contrary whether the recompute functionality is vestigial code that could be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions