Daml-dit-if

Hello guys.
I’m trying to use daml-dit-if from here. Is there a way to run it separately from daml locally and listen events from daml?

I have the next situation. I’m running DAML locally and want to catch events from it. I’m using DAZL package, and I catch events, but I faced with issues when one python process blocks other. I thought that daml-dit-if can resolve my issue, but I don’t understand how to run it locally. When I try to import modules from this package i have exception - ImportError: cannot import name 'IntegrationEntryPoint' from partially initialized module 'daml_dit_if.api'.

Hi @Anton_Aksyonov :wave:

The DA team is on a Christmas break so it might take a bit longer to get a reply.

Hope you understand :pray:

No problem :slight_smile:

@Anton_Aksyonov Thanks for both the question and the patience.

daml-dit-if is a library that’s used to build integrations, which is a specific term we use to refer to components that connect Daml Hub to the outside world. It’s a layer that sits atop Dazl and adds support for running in the Hub environment, as well as a few common integration patterns. (There’s built in queueing, some error recovery, etc.)

Outside of building integrations specifically for Daml Hub, daml-dit-if doesn’t have much use and the preference is to build directly on Dazl. (If you are in fact building a Hub integration, there are ways of runninig daml-dit-if locally for the purpose of testing during development, and I’m happy to assist in that if it would be useful. The general process is centered around a build tool we have, ddit, that packages integrations and allows them to be run locally.)

With that out of the way, daml-dit-if is built on Dazl (as is much of Daml Hub itself)… it should be within the capabilities of Dazl to find an approach that will resolve the concurrency issue you are facing.

Can you provide a bit more detail about the processes that are blocking each other and how they are interacting with Dazl? We should be able to provide a clearer path forward with that additional detail.

1 Like

Hello Michael. Thank you for the answer. I can’t share the code with you due to NDA, but I will try to explain what I tried to do in schema.
I have a next workflow: Users login from the front-end and this action creates event on the DAML side. After that python event listener receives events and collect them to the collection. Next async function takes every event form the collection and starts verify process, that includes request to the external API and receives status from it. While status in not TRUE we proceed to do requests. When we get TRUE in respond we exercise document into the DAML. All function are asynchronous, but I still have issue with blocking operation because I can’t do login for other users while first verification won’t finish.

Also, if it’s possible, could you provide an example (with DAZL package) how to build script to handle multi-threading or multi-process workflow, that I described.

@Michael_Schaeffer
I have resolved issue with blocking operations, so now I can handle several simultaneous processes. But question about example (with DAZL package) is still open.

@Anton_Aksyonov I’m not fully sure what sort of example you’re looking for. Can you provide a few more details on the specific use case?

Dazl’s v7 API is built around a model of registering handlers for various events on ledger and then handling those events as appropriate for your application. There’s no reason why you can’t register multiple sets of handlers for various processes you want a single client application to manage. (We do this internally within Daml Hub for many different scenarios - a single application with a single connection to the ledger has several different internal modules that each subscribe to various events for their specific purposes.)

Apologies if I’ve missed what you’re asking.Happy to provide more details.

@Michael_Schaeffer
Yes, I understand that, and I already have managed with that, but for me it’s still not clear how to use daml_dit_if locally.
When I try to make simple import, python raises the ImportError: cannot import name 'IntegrationEntryPoint' from partially initialized module 'daml_dit_if.api' (most likely due to a circular import)
I need to use daml-dit-ddit for that?

You shouldn’t need to use daml-dit-if unless you’re building an integration - a specific extension to be run in Daml Hub. If you’re doing that, we should continue this conversation over Zoom, which I am happy to do.