Error while trying to run the Python binding (aka Dazl) Hello world example

I’m trying to run this example: dazl-client/samples/hello-world/src at main · digital-asset/dazl-client · GitHub

I’ve made some changes reacting to error messages and to allocate the ledger party with a Daml Script, now this is the Daml file:

module Sample where
import Daml.Script

template Setup
    party: Party
    signatory party
    controller party can
      Execute : ContractId HelloRole
          cidRole <- lookupByKey @HelloRole party
          case cidRole of
            Some cid -> return cid
            None -> create HelloRole with ..

template HelloRole
    party: Party
    signatory party
    key party : Party
    maintainer key

    controller party can
      nonconsuming SayHello : ContractId HelloMessage
          to : Party
          message: Text
          create HelloMessage with
            sender = party
            recipient = to

template HelloMessage
    sender: Party
    recipient: Party
    message: Text
    signatory sender
    observer recipient

    controller recipient can
      AcceptMessage : ()
          return ()

      RejectMessage : ()
          return ()

setup : Script Party
setup = script do 
  alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
  aliceId <- validateUserId "alice"
  createUser (User aliceId (Some alice)) [CanActAs alice]
  return alice

And this is the Python file:

#!/usr/bin/env python3

import json
import os
import dazl
from dotenv import load_dotenv

def main():
    party = os.getenv('DAML_LEDGER_PARTY')
    url = os.getenv('DAML_LEDGER_URL')
    print(f'Starting a ledger for party {party!r} on {url}...')

    network = dazl.Network()
    client = network.aio_party(party)

    def ensure_setup(event):
        return dazl.create_and_exercise('Sample:Setup', {'party':}, 'Execute', {})

    def on_message(event):
        if (event.cdata['recipient'] == and (event.cdata['sender'] !=
            return dazl.exercise_by_key('Sample:HelloRole',, 'SayHello', {
                'to': event.cdata['sender'],
                'message': f'Thank you for telling me, {json.dumps(event.cdata["message"])}'


if __name__ == '__main__':

And this is the error message I get:

Starting a ledger for party 'Alice::122072b3dd5b69e438b623e11e5854e3dc75b26a62255c7dde609fd15b79bab4278e' on localhost:6865...
The main monitoring thread died.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/dazl/protocols/", line 182, in _main
    for i, metadata in enumerate(_monitor_ledger_network(conn)):
  File "/usr/local/lib/python3.9/site-packages/dazl/protocols/v1/", line 270, in grpc_main_thread
    grpc_package_sync(package_provider, store)
  File "/usr/local/lib/python3.9/site-packages/dazl/protocols/v1/", line 372, in grpc_package_sync
    m = parse_daml_metadata_pb(package_id, archive_bytes)
  File "/usr/local/lib/python3.9/site-packages/dazl/protocols/v1/", line 256, in parse_daml_metadata_pb
    return _parse_daml_metadata_pb(Archive(package_id, package))
  File "/usr/local/lib/python3.9/site-packages/dazl/protocols/v1/", line 273, in _parse_daml_metadata_pb
    psb.add_value(vt, vv.expr)
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 2238, in expr
    expr = self._expr_fn()  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 694, in <lambda>
    expr=lambda: self.parse_Expr(pb.expr),
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 264, in parse_Expr
    args["abs"] = self.parse_Expr_Abs(pb.abs)
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 368, in parse_Expr_Abs
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 276, in parse_Expr
    args["update"] = self.parse_Update(pb.update)
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 483, in parse_Update
    return Update(exercise_by_key=self.parse_Update_ExerciseByKey(pb.exercise_by_key))
  File "/usr/local/lib/python3.9/site-packages/dazl/damlast/", line 515, in parse_Update_ExerciseByKey
AttributeError: choice
The above error was propagated as an initialization error.

Am I doing something wrong, or some changes happened in the Python binding which is not reflected in the example?

I know that there is the new connect API which works better, but I now need the old Network API.

Thanks for reporting! This was, indeed, a bug in dazl itself and has been fixed in 7.8.3. Something about your Daml model triggered this, and dazl is merely crashing on trying to read packages from the ledger.

Please try this version and let me know if it fixes the problem you were encountering!

Thank you David, it works fine now.