Hi Kyle, I think you need to convert `capnp_path` back into a string before passing it to `capnp.load()`. Currently it appears you are passing a `Path` object that you constructed using pathlib, but `capnp.load` doesn't know how to deal with those, it wants a plain string.
-Kenton On Tue, Jun 1, 2021 at 9:35 AM Kyle Downey <[email protected]> wrote: > I have the following simple schema: > > @0x8fe87a03768154e9; > > enum Side { > buy @0; > sell @1; > } > > struct TradeMessage { > time @0 : Float64; > tradeId @1 : Int64; > side @2 : Side; > size @3 : Float64; > price @4 : Float64; > } > > struct Level1BookUpdateMessage { > time @0 : Float64; > best_bid_qty @1 : Float64; > best_bid_px @2 : Float64; > best_ask_qty @3 : Float64; > best_ask_px @4 : Float64; > } > > which I am loading as follows using pycapnp 1.0.0 on MacOS 11.4 running > Python 3.8: > > import capnp > > from pathlib import Path > > capnp_path = Path(__file__).parent / '../../../../capnp/serenity-fh.capnp' > capnp_def = capnp.load(capnp_path) > > It fails on load with the following error. Any ideas on what I might be > doing wrong? > > Connected to pydev debugger (build 202.6397.98) > Traceback (most recent call last): > File "<frozen importlib._bootstrap>", line 991, in _find_and_load > File "<frozen importlib._bootstrap>", line 975, in > _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 671, in _load_unlocked > File "<frozen importlib._bootstrap_external>", line 783, in exec_module > File "<frozen importlib._bootstrap>", line 219, in > _call_with_frames_removed > File > "/Users/kdowney/dev/shadows/serenity/src/serenity/marketdata/fh/txlog.py", > line 6, in <module> > capnp_def = capnp.load(capnp_path) > File "capnp/lib/capnp.pyx", line 4030, in capnp.lib.capnp.load > File "capnp/lib/capnp.pyx", line 3276, in > capnp.lib.capnp.SchemaParser.load > AttributeError: 'PosixPath' object has no attribute 'endswith' > > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/capnproto/26dda48a-5ca0-4b0c-a42f-930d96b388a4n%40googlegroups.com > <https://groups.google.com/d/msgid/capnproto/26dda48a-5ca0-4b0c-a42f-930d96b388a4n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/CAJouXQm9k_WpM%3DGhXinfzm1vv8BDr7%2BHTtWeGpLDkkrcXUGR9w%40mail.gmail.com.
