janezpodhostnik / flow-py-sdk

Unofficial flow blockchain python sdk
MIT License
35 stars 26 forks source link

get_events_for_block_i_ds and get_events_for_height_range methods fail #23

Closed chrfla closed 3 years ago

chrfla commented 3 years ago

Not sure, if it's just me doing something wrong, but I did not manage to make get_events_for_block_i_ds and get_events_for_height_range work.

Example:

async def run_events():
    return await client.get_events_for_height_range(type = "A.c1e4f4f4c4257510.Market.MomentPurchased", start_height = 15141027, end_height = 15241127)

Error:

File "/Users/me/.local/lib/python3.9/site-packages/betterproto/__init__.py", line 640, in _type_hint
    type_hints = get_type_hints(cls, vars(module))

TypeError: vars() argument must have __dict__ attribute

Double checked the official Flow Documentation, it expects a string for the type. I adapted the syntax for the type argument from this article.

janezpodhostnik commented 3 years ago

Thank you for the report. Let me check this today and get back to you.

janezpodhostnik commented 3 years ago

I was not able to replicate your problem. the same code worked fine for me. It is likely related to the python setup. I still wish to investigate this further.

Any more Info you can give me would help a lot.

Did you install flow-py-sdk using poetry? which version are you using? how are you running this code? anything really...

Edit: how is the client created here?

janezpodhostnik commented 3 years ago

So looking at this again. I just want to make sure you doing something equivalent to

from flow_py_sdk import flow_client

# ...

async def run_events():
    async with flow_client( host="some_node_url", port=9000 ) as client:
        return await client.get_events_for_height_range(type = "A.c1e4f4f4c4257510.Market.MomentPurchased", start_height = 15141027, end_height = 15241127)
chrfla commented 3 years ago

thanks a lot! I installed it with pip install flow-py-sdk. Python version: 3.9.5

Ah ok, no I'm doing it a bit differently, let me try again.

from flow_py_sdk import Config
from examples.common import Config #set to mainnet

ctx = Config()
client = flow_client(host=ctx.access_node_host, port=ctx.access_node_port)

EDIT: Same Issue with different client initiation. Let me check try poetry add flow-py-sdk.

chrfla commented 3 years ago

Same with poetry add flow-py-sdk. Here are the current dependencies (only used this environment for flow-py-sdk). Managed with Anaconda.

alabaster @ file:///home/ktietz/src/ci/alabaster_1611921544520/work
appdirs==1.4.4
applaunchservices==0.2.1
appnope @ file:///opt/concourse/worker/volumes/live/6ca6f098-d773-4461-5c91-a24a17435bda/volume/appnope_1606859448531/work
argh==0.26.2
arrow @ file:///opt/concourse/worker/volumes/live/1c202787-83f7-4b70-6d98-b40769f597f4/volume/arrow_1617737667847/work
astroid @ file:///opt/concourse/worker/volumes/live/cb98994b-3538-4559-454d-4e045aae6d6c/volume/astroid_1613500840028/work
async-generator @ file:///home/ktietz/src/ci/async_generator_1611927993394/work
atomicwrites==1.4.0
attrs @ file:///tmp/build/80754af9/attrs_1620827162558/work
autopep8 @ file:///tmp/build/80754af9/autopep8_1615918855173/work
Babel @ file:///tmp/build/80754af9/babel_1620871417480/work
backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work
betterproto==1.2.5
binaryornot @ file:///tmp/build/80754af9/binaryornot_1617751525010/work
black==21.5b2
bleach @ file:///tmp/build/80754af9/bleach_1612211392645/work
brotlipy==0.7.0
certifi==2021.5.30
cffi @ file:///opt/concourse/worker/volumes/live/a70943eb-ad97-40c6-78c9-98764c1bee07/volume/cffi_1613246936716/work
chardet @ file:///opt/concourse/worker/volumes/live/7e1102c4-8702-40f2-63d6-f260ce5f85e4/volume/chardet_1607706831384/work
click==8.0.1
cloudpickle @ file:///tmp/build/80754af9/cloudpickle_1598884132938/work
colorama @ file:///tmp/build/80754af9/colorama_1607707115595/work
cookiecutter @ file:///tmp/build/80754af9/cookiecutter_1617748928239/work
cryptography @ file:///opt/concourse/worker/volumes/live/d5dda287-c0b3-4861-7262-fab05baa64dc/volume/cryptography_1616769284011/work
cytoolz==0.11.0
decorator @ file:///tmp/build/80754af9/decorator_1621259047763/work
defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work
diff-match-patch @ file:///tmp/build/80754af9/diff-match-patch_1594828741838/work
docutils @ file:///opt/concourse/worker/volumes/live/c87e10af-317d-45cb-7142-3d02053858ee/volume/docutils_1620827978243/work
ecdsa==0.16.1
entrypoints==0.3
esprima==4.0.1
eth-hash==0.3.1
eth-typing==2.2.2
eth-utils==1.10.0
flake8 @ file:///tmp/build/80754af9/flake8_1615834841867/work
flow-py-sdk==0.2.0
future @ file:///opt/concourse/worker/volumes/live/f456638c-86a7-4060-7f5f-d499a051219b/volume/future_1607571337593/work
grpcio==1.38.0
grpcio-tools==1.38.0
grpclib==0.4.1
h2==4.0.0
hpack==4.0.0
hyperframe==6.0.1
idna @ file:///home/linux1/recipes/ci/idna_1610986105248/work
imagesize @ file:///home/ktietz/src/ci/imagesize_1611921604382/work
importlib-metadata @ file:///opt/concourse/worker/volumes/live/bdafb81c-7edc-4122-77fe-a69839ec3c71/volume/importlib-metadata_1617877361684/work
inflection==0.5.1
intervaltree @ file:///tmp/build/80754af9/intervaltree_1598376443606/work
ipykernel @ file:///opt/concourse/worker/volumes/live/b72ce213-516a-4998-6411-bacb2eb6d5d1/volume/ipykernel_1607452776186/work/dist/ipykernel-5.3.4-py3-none-any.whl
ipython @ file:///opt/concourse/worker/volumes/live/53a0fafb-1ff1-44d4-4ba9-874c42807e28/volume/ipython_1617120878135/work
ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work
isort @ file:///tmp/build/80754af9/isort_1616355431277/work
jedi @ file:///opt/concourse/worker/volumes/live/fb4a9bd9-ce20-4358-4d29-83b0746d57b6/volume/jedi_1606932574534/work
Jinja2==3.0.1
jinja2-time @ file:///tmp/build/80754af9/jinja2-time_1617751524098/work
jsonschema @ file:///tmp/build/80754af9/jsonschema_1602607155483/work
jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1616770841739/work
jupyter-core @ file:///opt/concourse/worker/volumes/live/d225f67f-0726-47b9-4510-c6aff5625ca4/volume/jupyter_core_1612213300495/work
jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work
keyring @ file:///opt/concourse/worker/volumes/live/23f8d94e-abc3-448f-501f-852dfe2421d6/volume/keyring_1621524572339/work
lazy-object-proxy @ file:///opt/concourse/worker/volumes/live/a169db40-97bf-4f51-6893-dc751f705b7b/volume/lazy-object-proxy_1616529067444/work
MarkupSafe==2.0.1
mccabe==0.6.1
mistune @ file:///opt/concourse/worker/volumes/live/4217afd5-dad1-438d-6f79-e4992ccda0e5/volume/mistune_1607364880245/work
multidict==5.1.0
mypy-extensions==0.4.3
nbclient @ file:///tmp/build/80754af9/nbclient_1614364831625/work
nbconvert @ file:///opt/concourse/worker/volumes/live/41c54e2d-699e-4b21-6d46-bf9dde99a677/volume/nbconvert_1607370470905/work
nbformat @ file:///tmp/build/80754af9/nbformat_1617383369282/work
nest-asyncio @ file:///tmp/build/80754af9/nest-asyncio_1613680548246/work
numpydoc @ file:///tmp/build/80754af9/numpydoc_1605117425582/work
packaging @ file:///tmp/build/80754af9/packaging_1611952188834/work
pandocfilters @ file:///opt/concourse/worker/volumes/live/d8ef4635-066d-4ffe-5341-12ebf01bd094/volume/pandocfilters_1605120459573/work
parso==0.7.0
pathspec==0.8.1
pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work
pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work
pluggy @ file:///opt/concourse/worker/volumes/live/a2630e20-8422-46fc-7347-f73294368851/volume/pluggy_1615976601840/work
poyo @ file:///tmp/build/80754af9/poyo_1617751526755/work
prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1616415428029/work
protobuf==3.17.2
psutil @ file:///opt/concourse/worker/volumes/live/da41f1b1-060b-47fa-4c17-557e069ead1d/volume/psutil_1612298011002/work
ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pycodestyle @ file:///home/ktietz/src/ci_mi/pycodestyle_1612807597675/work
pycparser @ file:///tmp/build/80754af9/pycparser_1594388511720/work
pydocstyle @ file:///tmp/build/80754af9/pydocstyle_1621600989141/work
pyflakes @ file:///home/ktietz/src/ci_ipy2/pyflakes_1612551159640/work
Pygments @ file:///tmp/build/80754af9/pygments_1621606182707/work
pyjsparser==2.7.1
pylint @ file:///opt/concourse/worker/volumes/live/900d9545-d400-4508-4ab6-012dfac53445/volume/pylint_1617135825470/work
pyls-black @ file:///tmp/build/80754af9/pyls-black_1607553132291/work
pyls-spyder @ file:///tmp/build/80754af9/pyls-spyder_1613849700860/work
pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1608057966937/work
pyparsing @ file:///home/linux1/recipes/ci/pyparsing_1610983426697/work
pyrsistent @ file:///opt/concourse/worker/volumes/live/f518b3a6-f049-4498-73a8-3d98fed23e04/volume/pyrsistent_1607365207647/work
PySocks @ file:///opt/concourse/worker/volumes/live/112288ac-9cb0-4e73-768b-13baf4ca6419/volume/pysocks_1605305820043/work
python-dateutil @ file:///home/ktietz/src/ci/python-dateutil_1611928101742/work
python-jsonrpc-server @ file:///tmp/build/80754af9/python-jsonrpc-server_1600278539111/work
python-language-server @ file:///tmp/build/80754af9/python-language-server_1607972495879/work
python-slugify @ file:///tmp/build/80754af9/python-slugify_1620405669636/work
pytz @ file:///tmp/build/80754af9/pytz_1612215392582/work
PyYAML==5.4.1
pyzmq==20.0.0
QDarkStyle @ file:///tmp/build/80754af9/qdarkstyle_1617386714626/work
qstylizer @ file:///tmp/build/80754af9/qstylizer_1617713584600/work/dist/qstylizer-0.1.10-py2.py3-none-any.whl
QtAwesome @ file:///tmp/build/80754af9/qtawesome_1615991616277/work
qtconsole @ file:///tmp/build/80754af9/qtconsole_1616775094278/work
QtPy==1.9.0
regex==2021.4.4
requests @ file:///tmp/build/80754af9/requests_1608241421344/work
rlp==2.0.1
rope @ file:///tmp/build/80754af9/rope_1602264064449/work
Rtree @ file:///opt/concourse/worker/volumes/live/18283f9b-719e-45b1-7f3a-937f49358be4/volume/rtree_1618420836397/work
sip==4.19.13
six==1.16.0
snowballstemmer @ file:///tmp/build/80754af9/snowballstemmer_1611258885636/work
sortedcontainers @ file:///tmp/build/80754af9/sortedcontainers_1606865132123/work
Sphinx @ file:///tmp/build/80754af9/sphinx_1620777493457/work
sphinxcontrib-applehelp @ file:///home/ktietz/src/ci/sphinxcontrib-applehelp_1611920841464/work
sphinxcontrib-devhelp @ file:///home/ktietz/src/ci/sphinxcontrib-devhelp_1611920923094/work
sphinxcontrib-htmlhelp @ file:///home/ktietz/src/ci/sphinxcontrib-htmlhelp_1611920974801/work
sphinxcontrib-jsmath @ file:///home/ktietz/src/ci/sphinxcontrib-jsmath_1611920942228/work
sphinxcontrib-qthelp @ file:///home/ktietz/src/ci/sphinxcontrib-qthelp_1611921055322/work
sphinxcontrib-serializinghtml @ file:///home/ktietz/src/ci/sphinxcontrib-serializinghtml_1611920755253/work
spyder @ file:///opt/concourse/worker/volumes/live/8da9378f-8560-4583-686a-bad27d48ab90/volume/spyder_1618327892352/work
spyder-kernels @ file:///opt/concourse/worker/volumes/live/967a0f62-ff81-4895-70fc-cde98a9527b9/volume/spyder-kernels_1617396560335/work
stringcase==1.2.0
testpath @ file:///home/ktietz/src/ci/testpath_1611930608132/work
text-unidecode==1.3
textdistance @ file:///tmp/build/80754af9/textdistance_1612461398012/work
three-merge @ file:///tmp/build/80754af9/three-merge_1607553261110/work
tinycss @ file:///tmp/build/80754af9/tinycss_1617713798712/work
toml==0.10.2
toolz==0.11.1
tornado @ file:///opt/concourse/worker/volumes/live/2c1a63a2-006b-48ee-56b9-0cfe8b4927f9/volume/tornado_1606942321278/work
traitlets @ file:///home/ktietz/src/ci/traitlets_1611929699868/work
ujson @ file:///opt/concourse/worker/volumes/live/258fa87e-ec76-445c-5f9c-fc9523993cd7/volume/ujson_1611259511951/work
Unidecode @ file:///tmp/build/80754af9/unidecode_1614712377438/work
urllib3 @ file:///tmp/build/80754af9/urllib3_1615837158687/work
watchdog @ file:///opt/concourse/worker/volumes/live/538065de-0b5c-490f-436a-1d4b6eeb9b34/volume/watchdog_1612471132539/work
wcwidth @ file:///tmp/build/80754af9/wcwidth_1593447189090/work
webencodings==0.5.1
whichcraft @ file:///tmp/build/80754af9/whichcraft_1617751293875/work
wrapt @ file:///opt/concourse/worker/volumes/live/1381ca3b-f984-4f5c-4f46-a67ca4eeffa5/volume/wrapt_1607574524589/work
wurlitzer @ file:///opt/concourse/worker/volumes/live/5d136bcd-c1ff-4f16-7406-fd203f8b08d6/volume/wurlitzer_1617224651834/work
yapf @ file:///tmp/build/80754af9/yapf_1615749224965/work
zipp @ file:///tmp/build/80754af9/zipp_1615904174917/work
chrfla commented 3 years ago

I reinstalled the environment and downgraded grpcio-tools to version 1.33.2 with pip install grpcio-tools==1.33.2. Now it works :) But I don't know if it was because of the version downgrade or the reinstallation of the environment. Nevertheless, thanks a lot!

janezpodhostnik commented 3 years ago

I'll give replicating this problem another go on a fresh pc. Which OS are you using @chrfla if you don't mind me asking.

chrfla commented 3 years ago

Great! I'm using MacOs 11.2.3.