cancel
Showing results for 
Search instead for 
Did you mean: 

embedPy inside q (kdb+) process fails to import a module

Kovacsi
New Contributor III

Hi community

    I must learn how to use python modules inside q kdb+ process. 

at the process of learning :

1.  using windows 10 x64 q , kdb+ , anaconda virtual environment 

on python 3.8.10, and KX Developer IDE.

2. learned how to use embedPy and successfully loaded some 

python modules like 'os' in to q using reflections.

 

now …

I try to use qoinbase-q to learn integrating embedPy with web-sockets
on q kdb+ database.

this code use an other project to extend q language using python modules
extend .it fail on a point attempting to get functions of coin-pro python
library.

q)pc:.cbpro.PublicClient[]
'cxt
[4] C:\Users\srv\.conda\envs\qenv\q\extend.q:181: .py.reflection.priv.context@:{.py.reflection.priv[y;`cxt][x;z]}


can you help me fined how to debug it and resolve the problem?

thanks
Ori

 

the function is:

.py.reflection.priv.context:{[obj; atr; arg]
  init: atr[`functions][`$"__init__"];
  params: init[`parameters];
  required: params[::;`required];

  if[(arg~(::)) and (any required);
    '"Missing required parameters: ",", " sv string where required];

  blk: .ut.blankNS;
  arg: .py.reflection.priv.args[arg];
  ins: $[1<count arg;.;@][obj;arg];

  atr[`vars]: .py.vars[ins];
  atr: @[atr;`functions;{x _ `$"__init__"}];

  cxt: blk,(,/)value .ut.eachKV[`doc _ atr;{.py.reflection.priv[y;`cxt][x;z]}[ins]];

  cxt};
4 REPLIES 4

davidcrossey
Moderator Moderator
Moderator

Hi Ori,

Interesting to see if anyone else in the Community has tried using this library who may be able to assist 🤞

Just in case anyone else is interesting in looking at this issue, can I check you are referring to these projects?

Thanks for sharing with the Community.

Kind regards,

David

David

Kovacsi
New Contributor III

Thanks David

   Do you know how to debug such cases? I try to display contents 

of the python library and understand what is the problem there,

I can't get it working the output is not clear and I can't understand

whet is the problem?

Ori 

The error is that a variable "cxt" is not being found. 

https://code.kx.com/q/basics/errors/#runtime-errors 

 

General debugging tips included on: https://code.kx.com/q/basics/debug/ 

 

As this is a third party project you will get better support by raising an issue with the developer directly:

The developer does not document the supported embedPy versions which would be important to know.

 

One difference I see is you are calling

pc:.cbpro.PublicClient[]

But the developer passes a string - this could be your issue

https://github.com/michaelsimonelli/qoinbase-q/blob/359653d9e45b6319d897f5ae50af048225605ae2/cbpro.q... 

cli: .cli.priv.addFuncs .cbpro.PublicClient[url];

 

 

Thanks Rian

    I am already in contact with Michael on this issue.

He is busy with other things so I try to resolve problem myself.

    Will try to insert the url, will you be able to help me debug this problem?

I'm  stack with it since last week....

Ori