This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-27
Channels
- # announcements (4)
- # asami (6)
- # aws-lambda (1)
- # babashka (38)
- # babashka-sci-dev (20)
- # beginners (87)
- # calva (67)
- # cider (19)
- # clerk (7)
- # clojure (102)
- # clojure-europe (52)
- # clojure-filipino (1)
- # clojure-hungary (4)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-sweden (3)
- # clojure-uk (1)
- # cursive (13)
- # data-science (7)
- # datomic (8)
- # deps-new (1)
- # emacs (3)
- # fulcro (16)
- # graphql (3)
- # humbleui (3)
- # kaocha (3)
- # leiningen (3)
- # malli (3)
- # off-topic (14)
- # pathom (34)
- # polylith (4)
- # rdf (12)
- # reitit (3)
- # releases (1)
- # remote-jobs (7)
- # rum (2)
- # sci (22)
- # shadow-cljs (115)
- # tools-deps (26)
- # tree-sitter (29)
Hello All, I'm new to polylith and need some advice. • I used the polytool to generate a component. • It create a resource folder with a subfolder as the name of the component. • I put a nippy file in the folder that the component joins data from in a function call. • The component references the resource using a relative path. • The function works and runs in the component directory. • However, when I try to invoke the function via the polylith interface, in code, I get the error that it cannot find the resource nippy file, necessary for the join. In the component, the code looks like this:
(def ref-data (-> (tc/dataset ".\\resources\\geocode\\3digitzipcode.nippy")
(tc/convert-types "3Digit" :string)
(ds/column-map "meta-join" (fn [a b] (str a "-" b))
["3Digit" "Country"])
(tc/drop-columns "Country")))
(defn Geocode3DigitZip [dataset zip-code country]
(-> dataset
(tc/convert-types zip-code :string)
(ds/column-map :Zip3Digit (fn [a] (subs (str a) 0 3))
[zip-code])
(ds/column-map "meta-join" (fn [a b] (str a "-" b)) [:Zip3Digit country])
(tc/left-join
ref-data
"meta-join")
(tc/drop-columns ["3Digit", "meta-join", ".\\resources\\geocode\\3digitzipcode.nippy.meta-join"])
(tc/replace-missing ["State" "Country"] :value "XX")))
This code successfully runs in the component with this call:
(def sample-data (ds/->dataset {:zipcode [414 750 48168 "abc"]
:country ["US" "US" "MX" "XX"]}))
(Geocode3DigitZip sample-data :zipcode :country)
However, when I call the same function via the interface,
(ns spinnakersca.07-sample
(:require [tech.v3.dataset :as ds]
[taoensso.nippy :as nippy]
[tablecloth.api :as tc]
[spinnakersca.geocode.interface :as geo]))
(def sample-data (ds/->dataset {:zipcode [414 750 48168 "abc"]
:country ["US" "US" "MX" "XX"]}))
(geo/Geocode3DigitZip sample-data :zipcode :country)
I get the following error: "Unable to find 3Digit"
This is a field from the nippy file in the component's resource folder.
Is there a setting a can adjust (perhaps in the deps.edn) to allow the component to function? Or is the solution to embed the data structure within the component file itself?resources
is on the classpath and files are generally accessed relative to the classpath so you want "geocode/3digitzipcode.nippy"
-- classpath-relative -- and you'll need to ensure you use
on that to get something readable.
(this is not Polylith-specific -- Clojure works that way in general)
Thank you! This solved my problem and I learned something new about clojure.