tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-08-28T12:10:43.101100Z

Are there any plans to support data-readers in deps.edn :args data?

2020-08-28T12:14:36.104Z

The use case is defining overrides for an integrant system, allowing #ig/ref. Obviously it’s also easy to put that system in a separate file, and read that, so not a big deal, and I can imagine that it’d add complexity to tools.deps. Just curious.

alexmiller 2020-08-28T12:43:32.104500Z

I don’t think there’s any need for that

alexmiller 2020-08-28T12:44:47.105100Z

Or do you mean for data in aliases in deps.edn?

dominicm 2020-08-28T12:48:32.105800Z

for context #ig/ref creates a record type. I suspect Rick is trying to pass in the integrant system to run via deps.edn aliases.

alexmiller 2020-08-28T13:04:20.107800Z

when you use -X the alias data is actually loaded in the context of the program you're running, so the data readers available via data_readers.clj[c] are available (but not currently being used in the edn/read, so seems like this shouldn't be too hard

2020-08-28T13:41:40.108400Z

Yeah it’s for data in aliases

2020-08-28T13:43:09.109700Z

And yeah I was thinking the same, using data_readers.clj(c) would be great for this.

alexmiller 2020-08-28T13:45:47.111700Z

I will log a jira for this, seems a reasonable thing to want

2020-08-28T13:46:43.112600Z

@dominicm’s suspicions are right… Essentially I’m writing a script, that wants to leverage some integrant components pre-defined in libraries. I currently have the system defined in a var in my program, and it would be useful to be able to override some of the components configs via args. I could obviously just put it in a separate edn config file; but it’s another config file (sigh) for something that’s intended to be pretty minimal.

alexmiller 2020-08-28T13:47:05.112900Z

yep, got it

2020-08-28T13:48:21.114100Z

It would be fab if tools.deps could do this… it’d make configuring and overriding bits of integrant systems much nicer.

2020-08-28T13:49:36.115100Z

Though I warn you, it’ll be a slippery slope, I’ll probably next want data aliases and command line args to be meta-merged 😆

alexmiller 2020-08-28T13:53:16.115400Z

https://clojure.atlassian.net/browse/TDEPS-163

alexmiller 2020-08-28T13:53:28.115600Z

what does "meta-merged" mean?

alexmiller 2020-08-28T13:55:18.116600Z

I'm guessing you mean deps.edn and -Sdeps alias data merged?

alexmiller 2020-08-28T13:57:51.117200Z

those will be merged now, but perhaps not in the way you want :)

2020-08-28T14:16:39.117400Z

Well I was just joking about supporting meta-merge 🙂 But I meant: https://github.com/weavejester/meta-merge which is very useful for doing deep merges of data. We tend to structure our integrant systems into profiles that get applied and meta-merged in a certain order.

2020-08-28T14:20:02.117700Z

So in a tools.deps meta-merge context you could have data aliases for each of those profiles, and meta-merge them all together in the specified order, with -Sdeps and command line args on top etc. I was only joking though assoc-in makes more sense for tools.deps.

alexmiller 2020-08-28T14:20:30.117900Z

well, that's there for -X with an :args map and pathed data on the command line

alexmiller 2020-08-28T14:21:32.118100Z

I'm not going to use meta-merge on deps data, but your program can combine data from multiple aliases that you load in any way you want

alexmiller 2020-08-28T14:21:42.118300Z

by loading it via the runtime basis

2020-08-28T14:22:26.118500Z

:thumbsup: Ahh yes that’s true — I’d forgotten I could do that.

2020-08-28T14:23:18.118700Z

I think that would work quite nicely actually :thinking_face:

2020-08-28T14:24:39.119100Z

I already have it slurped in my REPL 😁

2020-08-28T14:24:43.119300Z

Thanks

alexmiller 2020-08-28T14:25:13.119500Z

I guess that code could use data readers too :)

2020-08-28T14:25:26.119700Z

Yeah was just going to ask about that

2020-08-28T14:25:44.119900Z

:thumbsup:

alexmiller 2020-08-28T14:26:02.120100Z

edn/read-string takes an optional opts map where you can pass :readers

👍 1
alexmiller 2020-08-28T14:27:17.120400Z

(def basis (edn/read-string {:readers *data-readers*} (-> (System/getProperty "clojure.basis") jio/file slurp)))

alexmiller 2020-08-28T14:27:22.120600Z

something like that?

2020-08-28T14:28:06.120800Z

yeah that would work nicely with TDEPS-163

alexmiller 2020-08-28T14:28:46.121Z

there are other places that edn/read-string that you don't control, so those should do this too

alexmiller 2020-08-28T14:29:00.121200Z

inside tools.deps (deps reader) and the exec stub (command line)

2020-08-28T14:29:42.121500Z

Yeah I can’t do anything without TDEPS-163 also supporting the readers properly

alexmiller 2020-08-28T14:30:09.121700Z

I probably won't get to it today, but it shouldn't be a big deal

2020-08-28T14:32:13.121900Z

No rush, but it’ll be great to see this

2020-08-28T14:33:20.122100Z

Other use cases for us are that we like to represent URIs as data, not strings… and we have quite a lot of URIs in config data.