ValueError: party is missing on a Command: Python Dazl

Hello,

I am deploying a simple daml and python dazl file in my Hub.
DAML went successfully. Was able to convert the python code .tar file and deploy in the ledger. But I am facing the following error.

I followed the following github. derivhack2019/examples/dablhello at master · digital-asset/derivhack2019 · GitHub

ValueError: string must be in the format PKG_REF:MOD:ENTITY or MOD:ENTITY

Here is the complete error.

  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/api.py", line 691, in _register_created
    self.add_ledger_created(template, match=match, handler=cb)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/api.py", line 716, in add_ledger_created
    bot.add_event_handler(EventKey.contract_created(True, template), handler, filter_fn)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/events.py", line 150, in contract_created
    return EventKey._contract(primary_only, "create", template)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/events.py", line 181, in _contract
    m, t = validate_template(template)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/damlast/lookup.py", line 150, in validate_template
    raise ValueError("string must be in the format PKG_REF:MOD:ENTITY or MOD:ENTITY")
ValueError: string must be in the format PKG_REF:MOD:ENTITY or MOD:ENTITY

 --- End of log stream

@dtanabe I tried replacing the periods with colons and it started running. And I am facing the following issue. Would this be because I am passing the wrong ledger ids for the partys I created? Kindly let me know?

Fetching party map...
Done fetching party map!
Starting a ledger client for party None (Alice) on localhost:6865...
[   INFO] 2021-09-28 19:22:10,131 | dazl    | Opening port 53390 for metrics...
[   INFO] 2021-09-28 19:22:10,289 | dazl    | Listening on None:53390 for metrics.
[   INFO] 2021-09-28 19:22:10,291 | dazl    | Network bots coroutine started.
[   INFO] 2021-09-28 19:22:10,291 | dazl    | Network bots coroutine started.
[   INFO] 2021-09-28 19:22:10,291 | dazl    | Establishing a connection to http://localhost:6865 on party None...
[   INFO] 2021-09-28 19:22:13,334 | dazl    | Ledger ID: c34topu3mj2gpaqq
[   INFO] 2021-09-28 19:22:13,335 | dazl    | grpc_main_thread...
[   INFO] 2021-09-28 19:22:13,369 | dazl    | Parsed 169 bytes of metadata (package ID 'e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b') in 0.07 ms.
[   INFO] 2021-09-28 19:22:13,383 | dazl    | Parsed 25068 bytes of metadata (package ID '40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7') in 3.66 ms.
[   INFO] 2021-09-28 19:22:13,391 | dazl    | Parsed 463 bytes of metadata (package ID '733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a') in 0.06 ms.
[   INFO] 2021-09-28 19:22:13,498 | dazl    | Parsed 549327 bytes of metadata (package ID 'ad8c5e6ca7a2b8c09ccde733892b8f0ee022c1f7346613116a94d967e47f3262') in 65.53 ms.
[   INFO] 2021-09-28 19:22:13,506 | dazl    | Parsed 58 bytes of metadata (package ID 'd14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662') in 0.03 ms.
[   INFO] 2021-09-28 19:22:13,512 | dazl    | Parsed 59 bytes of metadata (package ID '518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c') in 0.03 ms.
[   INFO] 2021-09-28 19:22:13,519 | dazl    | Parsed 272 bytes of metadata (package ID '97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657') in 0.06 ms.
[   INFO] 2021-09-28 19:22:13,525 | dazl    | Parsed 288 bytes of metadata (package ID '86828b9843465f419db1ef8a8ee741d1eef645df02375ebf509cdc8c3ddd16cb') in 0.05 ms.
[   INFO] 2021-09-28 19:22:13,531 | dazl    | Parsed 1372 bytes of metadata (package ID 'c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd') in 0.13 ms.
[   INFO] 2021-09-28 19:22:13,537 | dazl    | Parsed 297 bytes of metadata (package ID '3f4deaf145a15cdcfa762c058005e2edb9baa75bb7f95a4f8f6f937378e86415') in 0.04 ms.
[   INFO] 2021-09-28 19:22:13,543 | dazl    | Parsed 297 bytes of metadata (package ID 'cb0552debf219cc909f51cbb5c3b41e9981d39f8f645b1f35e2ef5be2e0b858a') in 0.04 ms.
[   INFO] 2021-09-28 19:22:13,549 | dazl    | Parsed 235 bytes of metadata (package ID '6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d') in 0.05 ms.
[   INFO] 2021-09-28 19:22:13,554 | dazl    | Parsed 194 bytes of metadata (package ID 'bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f') in 0.02 ms.
[   INFO] 2021-09-28 19:22:13,560 | dazl    | Parsed 513 bytes of metadata (package ID '8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb') in 0.09 ms.
[   INFO] 2021-09-28 19:22:13,565 | dazl    | Parsed 871 bytes of metadata (package ID 'e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c') in 0.09 ms.
[   INFO] 2021-09-28 19:22:13,571 | dazl    | Parsed 275 bytes of metadata (package ID '057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba') in 0.04 ms.
[   INFO] 2021-09-28 19:22:13,577 | dazl    | Parsed 306 bytes of metadata (package ID 'f20de1e4e37b92280264c08bf15eca0be0bc5babd7a7b5e574997f154c00cb78') in 0.05 ms.
[   INFO] 2021-09-28 19:22:13,583 | dazl    | Parsed 1787 bytes of metadata (package ID '6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06') in 0.16 ms.
[   INFO] 2021-09-28 19:22:13,629 | dazl    | Parsed 294628 bytes of metadata (package ID '57b5c520512c24035057aa4c783cb7ac7f3f49db29806280962e188be7aadb66') in 34.60 ms.
[   INFO] 2021-09-28 19:22:13,638 | dazl    | Parsed 20277 bytes of metadata (package ID 'f99a4f0be2e609d79aa8ce924ba5767716a7af8327022e0ce8f4d14bd2de2779') in 1.48 ms.
[   INFO] 2021-09-28 19:22:13,643 | dazl    | Parsed 74 bytes of metadata (package ID 'd58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97') in 0.02 ms.
[   INFO] 2021-09-28 19:22:13,649 | dazl    | Parsed 840 bytes of metadata (package ID '99a2705ed38c1c26cbb8fe7acf36bbf626668e167a33335de932599219e0a235') in 0.16 ms.
[   INFO] 2021-09-28 19:22:13,655 | dazl    | Parsed 357 bytes of metadata (package ID 'cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7') in 0.04 ms.
[   INFO] 2021-09-28 19:22:13,660 | dazl    | Parsed 53 bytes of metadata (package ID '76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f') in 0.02 ms.
[   INFO] 2021-09-28 19:22:15,106 | dazl    | Reading current ledger state...
[   INFO] 2021-09-28 19:22:15,106 | dazl    | Writer loop for party None is starting...
[   INFO] 2021-09-28 19:22:15,106 | dazl    | Calling read_acs(None, False) for party: None
[   INFO] 2021-09-28 19:22:15,106 | dazl    | ACS request serialization (0.14 ms)
[   INFO] 2021-09-28 19:22:15,108 | dazl    | ACS request initial stream (1.13 ms)
[   INFO] 2021-09-28 19:22:15,170 | dazl    | ACS request consume full stream (62.11 ms)
[   INFO] 2021-09-28 19:22:15,170 | dazl    | ACS find all required packages (0.02 ms)
[   INFO] 2021-09-28 19:22:15,170 | dazl    | ACS transform the message (0.10 ms)
[   INFO] 2021-09-28 19:22:15,171 | dazl    | read_acs() finished at offset '0000000000000008' for party: None
[   INFO] 2021-09-28 19:22:15,233 | dazl    | Catching up...
[   INFO] 2021-09-28 19:22:15,233 | dazl    | Finished catching up.
[   INFO] 2021-09-28 19:22:15,233 | dazl    | Finished reading current ledger state.
[  ERROR] 2021-09-28 19:22:15,234 | dazl    | Tried to send a command and failed!
Traceback (most recent call last):
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/_party_client_impl.py", line 702, in main_writer
    cps = p.command.build(defaults)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/commands.py", line 384, in build
    raise ValueError("party is missing on a Command")
ValueError: party is missing on a Command
[  ERROR] 2021-09-28 19:22:15,236 | dazl    | A command submission failed!
Traceback (most recent call last):
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/_party_client_impl.py", line 702, in main_writer
    cps = p.command.build(defaults)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/commands.py", line 384, in build
    raise ValueError("party is missing on a Command")
ValueError: party is missing on a Command
[  ERROR] 2021-09-28 19:22:15,236 | dazl    | An event handler in a bot has thrown an exception!
Traceback (most recent call last):
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/bots.py", line 192, in _handle_event
    await fut
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/_party_client_impl.py", line 702, in main_writer
    cps = p.command.build(defaults)
  File "/home/squidly/.local/lib/python3.9/site-packages/dazl/client/commands.py", line 384, in build
    raise ValueError("party is missing on a Command")
ValueError: party is missing on a Command

This code example is unfortunately a bit old. Essentially, wherever you see strings of the form:

MyModule.MyTemplate

they must now be

MyModule:MyTemplate

Note the period changed to a colon. The first public releases of Daml Connect (then called DAML SDK) required the use of a colon here, but dazl supported the period form for historical reasons; that support has since been dropped.

Hello, Thanks a lot for reaching out. Will I be able to replace those periods with colons? Or is there a github tutorial you can suggest to me where I can follow the new format?

Oh looks like that piece of code is in the DAZL itself. So replacing might not be an option it seems. Please suggest me the new code or any method that I might use to get this going.

I’m curious—how did you find this particular example? It’s a bit outdated at this point.

If you’re getting started with Daml, I suggest following this page: Getting Started with Daml — Daml SDK 1.16.0 documentation

If you also want to deploy to Daml Hub, after you’ve logged in, there are a few sample apps that you can deploy; there are links there to other, more up-to-date examples.

I was going through the github abd stumble up on this. Also, I was going through various comments too. And found this as well.

Sure, will find more samples on python bots.

Also, I found this python bots link here as well under the resources section, which was referring to DAZL Python. Would you mind updating it if it is outdated now?

https://hub.daml.com/docs/

Thanks! Good to know.

The docs linked at hub.daml.com/docs should be a bit more up-to-date, and contain colons in their examples instead of periods. (Although if you find a place where that isn’t the case, please do let us know and we’ll update it promptly! :slight_smile: )

Sure, But I think I am confused. So, that says DAZL right? Can I go ahead and use DAZL library in python then?

Solved the issue by replacing. It was some code minor issue with the ledger ids associated to the party I created in the hub.

Yep, you can continue to use dazl no problem! It’s just the example and docs that are slightly out of date.

Sure, We are able to build a sample use case basing on these examples.

1 Like