datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
hadils 2020-07-31T20:05:29.029Z

Hi there, I am using Datomic Cloud. I would like to compile the code in my CI pipeline before deploying it, to save time and money. Can anyone tell me how Datomic Cloud invokes the compiler, and if it's reproducible?

stuarthalloway 2020-07-31T20:37:13.030Z

Hi @hadilsabbagh18. Are you writing ion code that runs inside a cluster node?

hadils 2020-07-31T20:37:30.030200Z

Yes sir.

stuarthalloway 2020-07-31T20:39:25.032Z

If you compile your code before deploying it to an ion, it will load into the cluster node faster, but I am not sure that will save you a visible amount of time or money.

hadils 2020-07-31T20:40:43.034100Z

@stuarthalloway I have deployed code that has had Java compiler errors, which costs time and money. I am just try to pre-compile the code to make sure that it will pass.

stuarthalloway 2020-07-31T20:41:20.034800Z

Do you mean Clojure compiler errors? The cluster node does not compile Java for you.

hadils 2020-07-31T20:41:36.035100Z

Yes, I mean Clojure compiler errors...

stuarthalloway 2020-07-31T20:41:56.035600Z

You have some options:

stuarthalloway 2020-07-31T20:43:01.036900Z

If you are already going to the trouble of running the compiler locally, then you deploy make a jar with the compiled code instead of with source. Then there is no compilation on the cluster node, and no possibility of (that class of) error.

stuarthalloway 2020-07-31T20:44:05.037800Z

In that case the cluster node will also start faster after an ion deploy, although the difference may not matter much.

hadils 2020-07-31T20:45:11.039500Z

How would I indicate to the Ion deployment that I have already compiled my code into a jar? I can figure our that part...

stuarthalloway 2020-07-31T20:45:44.039800Z

Good news: you don't have to.

stuarthalloway 2020-07-31T20:45:55.040Z

Jars are jars are jars

hadils 2020-07-31T20:46:37.041100Z

ok. So I just declare :gen-class in my code and compile ir?

stuarthalloway 2020-07-31T20:46:40.041200Z

Have your ion depend on your compiled code as a maven dep.

hadils 2020-07-31T20:46:53.041600Z

Ok. Understood.

stuarthalloway 2020-07-31T20:47:02.041900Z

You definitely do not need gen-class

hadils 2020-07-31T20:47:04.042100Z

In deps.edn rifht?

stuarthalloway 2020-07-31T20:47:08.042400Z

right

stuarthalloway 2020-07-31T20:47:35.043300Z

This leads to a two-project structure, where your code is in one project, and your ion has deps on that code and probably just ion-config.edn.

hadils 2020-07-31T20:48:06.043800Z

Aha! Interesting idea!

stuarthalloway 2020-07-31T20:48:34.044400Z

I do this all the time. As soon as code is nontrivial I want to use it from more than one ion.

stuarthalloway 2020-07-31T20:49:40.045500Z

To get the compilation benefit, you still need to do whatever maven/leiningen/boot magic you need to compile all your Clojure code in the code project.

hadils 2020-07-31T20:50:08.045900Z

Can I use maven with tools.deps.alpha?

stuarthalloway 2020-07-31T20:51:50.046400Z

For some definitions of "use", yes 🙂

stuarthalloway 2020-07-31T20:53:41.046700Z

This space is evolving https://github.com/clojure/tools.deps.alpha/wiki/Tools#packaging

hadils 2020-07-31T20:58:31.047600Z

I have found @seancorfield's depstar repo. I will use that. Thanks for your help @stuarthalloway!

Nassin 2020-07-31T21:22:47.048100Z

is the dev-local client compatible with on-premise client? (ignoring the features that on-premise support that cloud doesn't)

cpdean 2020-07-31T21:32:57.053700Z

What's the idiomatic way to model something like a link table but against multiple other entities? in old datalog/prolog you'd do something like attrName(entity1, other1, other2, other3). assuming entity1, other1, etc are either scalar values or entity ids. but in datomic's datalog, if vecs are allowed as a value in a datom, you might be able to do something like this

[entity1 :attrName [other1, other2, other3]]
or if not, you could... maybe this is how you'd do it?
[entity1 :attrName1 other1]
[entity1 :attrName2 other2]
[entity1 :attrName3 other3]
the fact attrName is meant to be something that must join entity1 with 3 other entities, rather than it representing an unordered collection of linked entities, like the :movie/cast attr in http://learndatalogtoday.org

Nassin 2020-07-31T21:38:42.054400Z

do all :attrName* express the same relation?

cpdean 2020-07-31T21:40:39.055700Z

yeah. maybe i should have come up with a better concrete example for this...

cpdean 2020-07-31T21:41:46.056400Z

boughtHouse(buyer, seller, house, notary). maybe? i don't actually know how houses are sold haha

favila 2020-07-31T21:43:16.058300Z

why is this different from having separate ref attributes? each assertion has a different meaning

cpdean 2020-07-31T21:43:25.058500Z

maybe the orientation of what an entity is can be reversed?

[house-sale-eid :housesale/buyer buyer-eid]
[house-sale-eid :housesale/seller seller-eid]
[house-sale-eid :housesale/house house-eid]
[house-sale-eid :housesale/notary notary-eid]

favila 2020-07-31T21:43:51.059Z

^^ this is what I would expect

cpdean 2020-07-31T21:44:07.059500Z

i don't know if it's different - i'm totally new to this and only have a background in dimensional modelling, datavault, and datalog

favila 2020-07-31T21:44:44.060Z

I think you’re getting at something though. Is it maybe a constraint you’re trying to enforce?

cpdean 2020-07-31T21:45:26.060700Z

i definitely know that i want some constraints to be enforced, but i don't know what the term means in datomic's context yet 😬

cpdean 2020-07-31T21:51:15.064Z

yeah i guess orienting the entity around the event and not the buyer, or whatever the 'primary subject' of the event is is how you'd avoid having more than one instance of an entity for a given field