Fork me on GitHub
#datomic
<
2020-07-31
>
hadils20:07:29

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?

stuarthalloway20:07:13

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

stuarthalloway20:07:25

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.

hadils20:07:43

@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.

stuarthalloway20:07:20

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

hadils20:07:36

Yes, I mean Clojure compiler errors...

stuarthalloway20:07:56

You have some options:

stuarthalloway20:07:01

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.

stuarthalloway20:07:05

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

hadils20:07:11

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

stuarthalloway20:07:44

Good news: you don't have to.

stuarthalloway20:07:55

Jars are jars are jars

hadils20:07:37

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

stuarthalloway20:07:40

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

hadils20:07:53

Ok. Understood.

stuarthalloway20:07:02

You definitely do not need gen-class

hadils20:07:04

In deps.edn rifht?

stuarthalloway20:07:35

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.

hadils20:07:06

Aha! Interesting idea!

stuarthalloway20:07:34

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

stuarthalloway20:07:40

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.

hadils20:07:08

Can I use maven with tools.deps.alpha?

stuarthalloway20:07:50

For some definitions of "use", yes 🙂

hadils20:07:31

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

Nassin21:07:47

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

cpdean21:07:57

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

Nassin21:07:42

do all :attrName* express the same relation?

cpdean21:07:39

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

cpdean21:07:46

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

favila21:07:16

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

cpdean21:07:25

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]

favila21:07:51

^^ this is what I would expect

cpdean21:07:07

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

favila21:07:44

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

cpdean21:07:26

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 😬

cpdean21:07:15

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