Fork me on GitHub
#datomic
<
2020-07-22
>
onetom05:07:39

what's the current recommendation for datomic.api/pull-many when using the datomic.client.api? there is a nice comparison of the peer and the client apis on the https://docs.datomic.com/on-prem/clients-and-peers.html#peer-only page, but it doesn't mention datomic.api/pull-many and what should it's equivalent be on datomic.client.api. i know it's possible to provide pull patterns as dc/q, but that couples the queries more to pulls, than it would otherwise, using the q+find-rel + pull-many.

onetom05:07:13

based on the introduction of this new qseq function, i suspect that's the one I should use instead of pull-many. Is my suspicion correct?

maxt10:07:24

I get this error when adding dev-local as a dependency to a previously working ions project:

Could not locate cognitect/hmac_authn__init.class, cognitect/hmac_authn.clj or cognitect/hmac_authn.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I guess it's a dependency conflict but I've checked with -Stree and I get the same versions of com.cognitect/hmac-authn 0.1.195 in both with and without dev-local. Still trying to track it down, but wanted to ask if anyone else have seen it or something similar?

danieroux11:07:18

@maxt I had this issue too, and it solved by having latest tools.deps - 1.10.1.561 Upgrade on osx with: brew upgrade clojure/tools/clojure

maxt12:07:39

@danie Thank you for the hint! Just noticed that it works from cli, but not through cursive, which indeed seems to be stuck at an older version of tools deps

Alex Miller (Clojure team)12:07:56

You can have cursive use your local version of clj too

maxt13:07:43

@alexmiller that would be great, but when I try I get this

The following errors were found during project resolve: /home/max/wavy/wavy-v2/deps.edn: Coordinate type :mvn not loaded for library org.clojure/clojure in coordinate {:mvn/version "1.10.1"}
I don't yet understand why I see that in cursive but not from cli

maxt13:07:17

Yep, thank you

onetom15:07:56

@maxt yes, you can specify Cursive to use the installed CLI tools, by pointing it to the clojure executable

maxt15:07:06

@onetom Thank you. That option sadly does not work for me, I get a wierd error when doing so.

onetom15:07:42

i would recommend using nix to manage your projects' dependencies

onetom15:07:40

that way it's guaranteed that you have the exact version of everything in a read-only folder and it doesn't clash with the needs with any other project

onetom15:07:42

here is an example of a shell.nix file, which can provide you the exact same environment in a shell, even years later:

# To upgrade pinned versions, get the latest git commit SHAs:
#     git ls-remote  nixos-20.03 nixpkgs-unstable

with import (builtins.fetchGit {
    name = "nixos-20.03";
    ref = "refs/heads/nixos-20.03";
    rev = "bb8f0cc2279934cc2274afb6d0941de30b6187ae";
    url = ;
}) {};

let
    sharedJDK = jdk11;
    clojure = callPackage ../clojure { jdk11 = sharedJDK; };
    maven = maven3.override { jdk = sharedJDK; };
in

mkShell rec {
    buildInputs = [
        coreutils cacert wget unzip overmind
     	sharedJDK maven clojure
    ];
    
    shellHook = ''
        export LC_CTYPE="UTF-8"
    '';
}

onetom15:07:23

the ../clojure folder contains a copy of https://github.com/NixOS/nixpkgs/blob/99afbadaca7a7edead14dc5f930aff4ca4636608/pkgs/development/interpreters/clojure/default.nix and i just adjusted the cli tool version and sha in it.

onetom15:07:30

the Nix pkg manager works great under any Linux or macOS, but Windows is not really supported or might never be supported.

onetom15:07:16

im happy to hop on a https://screen.so/ session and help you to set nix up or i can show it in action on my machine

onetom15:07:30

maybe i should do a screencast about it... 😕

maxt15:07:41

I did not know about Nix, thank you for mentioning it.

maxt15:07:33

In this case, It works from my command line but not from inside IntelliJ, and I don't think a package manager would help me then.

maxt15:07:51

And thank you for offering help. In this case, I just found a workaround that solves my current issue.

staypufd04:07:18

@maxt What was the work-around?

maxt13:07:10

@U060WE55Z Using the option "Use tools.deps directly" on a updated Cursive.

maxt15:07:06

Using tools.deps version 0.8.709 from inside Cursive finally did allow me to use dev-local. Thank you again @danie

👍 3
joshkh17:07:59

hello! i am attempting to get a handle on the AWS_ACCESS_KEY_ID environment variable from within my Ion lambda -- something that is typically available based on the execution role. however, listing the environment variables from within my Ion returns the environment variables of the query group, which is expected but not very helpful in my case. is there another way to retrieve the execution role credentials?

marshall17:07:30

usually you would use the instance role credentials

marshall17:07:36

one sec - let me get you an example

joshkh18:07:23

hi marshall, ghadi and kenny sorted me out with a good example. thanks just the same for investigating

ghadi17:07:41

@joshkh you shouldn't need AWS_ACCESS_KEY_ID to use an AWS SDK

ghadi17:07:26

all AWS SDKs detect that they are running in an EC2 machine with an instance role, and transparently fetch and remember credentials

ghadi17:07:52

but I'm not sure what you're trying to do

ghadi17:07:21

if it's "use an aws API" just call the constructor function for whatever SDK you're using, and don't pass any explicit credentials

ghadi17:07:12

EC2 machines don't have that env var unless you've explicitly set it -- which is not recommended

joshkh17:07:15

thanks for the feedback ghadi. in my case i need to manually sign an HTTP request

ghadi17:07:27

for an AWS API?

joshkh17:07:53

specifically, a raw GraphQL query to an AppSync endpoint

joshkh17:07:47

ie a server side mutation from an ion

ghadi18:07:07

if manually signing, you could ask an sdk for credentials

ghadi18:07:22

credentials periodically rotate in ec2 machines, and the sdk's handle this for you

ghadi18:07:31

would love to see some sample code

joshkh18:07:31

i'm using cognitect's aws-api, although there is no "server side" appsync client or API to perform mutations, so it appears that manually posting signed requests to AppSync is the way to go. i'm drawing some inspiration from the code at the end of this article: https://adrianhall.github.io/cloud/2018/10/26/backend-graphql-trigger-appsync/ nodejs has the benefit of using the AWS AppSync client, but that's not an option in the JVM

ghadi18:07:59

cool you are in luck, I am a maintainer of that sdk 🙂

joshkh18:07:22

it's my lucky day!

ghadi18:07:14

interesting, I didn't realize the aws js sdk exposes sigv4 as an API

ghadi18:07:59

that is not the same thing

ghadi18:07:06

that is a code signing api for IOT

ghadi18:07:14

an actual service

ghadi18:07:39

what you are looking for is a thing that signs HTTP maps with AWS credentials

ghadi18:07:09

we don't yet have v4 request signing a la carte in cognitect labs' aws-api

ghadi18:07:18

but I think @U083D6HK9 may have done it

ghadi18:07:32

it's useful for API Gateway, as well as GraphQL

joshkh18:07:31

(re: AWS Signer, yes thanks for pointing that out. i was crossing wires)

ghadi18:07:06

in any case: don't rely on the datomic machine to have static credentials in the env vars

joshkh18:07:53

for sure. i didn't really expect them to be there as with a typical lambda.

ghadi18:07:10

but that doesn't solve your larger problem of signing a request

kenny18:07:47

Haven’t read the background on your issue @joshkh but perhaps this is useful https://gist.github.com/kennyjwilli/aa9e99321d9443a8ae80448974850e79

joshkh18:07:03

forgive me ghadi, but doesn't that demonstrate a way to provide custom credentials? whereas in my case i need to retrieve the current access-key-id etc.?

joshkh18:07:11

@U083D6HK9 i think that's exactly what i'm looking for

ghadi18:07:02

if you call (cognitect.aws.client.shared/credentials-provider) you'll have access to the default provider which will pull and refresh the creds automatically

ghadi18:07:15

combine that with kenny's script

joshkh18:07:03

yup, this looks great. thank you both for your help. it's always interesting to dive a little deeper into ions / aws api.

joshkh18:07:52

and thanks for your work on aws-api. it was a game changer when moving from the aws java sdk.

3
joshkh18:07:01

on a side note, i wasn't able to sign S3 / CloudFront urls with aws-api in the past (although maybe that has changed), so i ported over an AWS java example to Clojure. might be useful to someone who finds this thread in the future. https://gist.github.com/joshkh/99718bfd4cd95cd48cda8533f162ffbf

ghadi17:07:09

hmm which sdk ?

joshkh17:07:51

^ i started a thread above 🙂