rocklabs-io / ic-py

Python Agent Library for the DFINITY Internet Computer
MIT License
128 stars 27 forks source link

Unstable result calling some Entrepot NFT canister #23

Closed Pepn closed 2 years ago

Pepn commented 2 years ago
from ic.client import Client
from ic.identity import Identity
from ic.agent import Agent
from ic.candid import encode, decode, Types
#from struct import *

iden = Identity()
client = Client(url = "https://ic0.app")
agent = Agent(iden, client)

canister_id = '3mttv-dqaaa-aaaah-qcn6q-cai'
function_to_call = "getGenes"

params = []
params = encode(params)

res = agent.query_raw(canister_id, function_to_call, encode([]))

print(res)

This gives me either the error Traceback (most recent call last): File "..\traitchecker.py", line 17, in <module> res = agent.query_raw(canister_id, function_to_call, encode([])) File "C:\Python39\lib\site-packages\ic\agent.py", line 73, in query_raw if result['status'] == 'replied': TypeError: byte indices must be integers or slices, not str

Or the correct result (a shitload of data). Probably one out of 4 calls returns correct.

bodily11 commented 2 years ago

@Pepn This is really weird because I just copied and pasted your code and ran it 100 times in a row and it worked every single time. 100 successes out of 100 trials. This seems very different from the results you were getting. Are you on the latest and greatest in the GitHub repo?

The only difference is I used print(len(res[0]['value'])) instead of print(res) because I didn't want to print a ton of stuff, but that shouldn't have affected the success rate.

So maybe it isn't the Entrepot NFT canister endpoint, and something to do with your current ic-py installation?

Myse1f commented 2 years ago

I got the same result as @bodily11 did. Can you reproduce the error with exact method?

Pepn commented 2 years ago

Idk, seems to work fine on a fresh install on my other machine as well.

Installed using pip btw