PyCorda: Python Node Analytics


Jamiel Sheikh
 

If you love analytics, please check out PyCorda (PyCorda.com), an experimental open source Corda node analytics framework for Python 3. Currently, PyCorda uses pandas DataFrames to wrap a node's database for querying. Works only with H2 and should be used only in dev at this moment. What do you think about it? Any suggestions for improvements?

Here's how quickly you can pull node data into Python:

import pycorda as pyc
url = 'jdbc:h2:tcp://localhost:55555/node'
username = 'sa'
password = ''
partyA = pyc.Node(url,username,password)
print(partyA.get_node_infos())

Results:

   NODE_INFO_ID                                     NODE_INFO_HASH  PLATFORM_VERSION         SERIAL
0             1  E5868B2E88D3970E2377916C4D34074971C907CA6B3D40...                 4  1568332664588
1             3  4FDDFBA5BA3C78A98376C1F9396B0607D5E8C200CFA83B...                 4  1568332660427
2             5  147A7E875EB2B5C6D1C955D7EAC337D4F37AED9372250C...                 4  1568332664726
3             7  5B2C3C91AAB0262C59C646A02AD10A25DE4661C5101BD4...                 4  1568332664602


I've also thrown in some charting, with a few lines,

plotter = pyc.Plotter(partyA)
plotter.vault_states_ts()
plotter.show()

You can get this beauty, which depicts the times two UTXOs were consumed:

image.png



--
Jamiel Sheikh, CEO
54 W 40th Street
New York, NY 10018


Mike Hearn
 

Thanks Jamiel, looks good!

One thing you might want to play with is GraalPython. That would let you access the Corda APIs directly from an optimising Python 3 implementation that can use native modules.

https://github.com/graalvm/graalpython

Then you can use the vault query API, but direct query via JDBC and JPA would also work of course.


Charles Monteiro
 

Mike 

would anything that runs on Graal enjoy the same benefits? Groovy , Jruby?

Thanks

Charles 
On Sep 16, 2019, 9:17 AM -0400, Mike Hearn via Groups.Io <mike@...>, wrote:

Thanks Jamiel, looks good!

One thing you might want to play with is GraalPython. That would let you access the Corda APIs directly from an optimising Python 3 implementation that can use native modules.

https://github.com/graalvm/graalpython

Then you can use the vault query API, but direct query via JDBC and JPA would also work of course.


Charles Monteiro
 

Or let’s put it another way when I had in the past asked You about using languages such as jruby or groovy to code smart contracts if I recall you stated that because the byte code generated and your notion of the deterministic Jvm that they would not be suitable 

So I wonder if it’s just the fact that a Lang can run on graal which groovy can , which will make corda accessible or is it also necessary that a language was built on Truffle e.g truffle ruby, truffle python implementation etc

Thanks for the feedback 
On Sep 16, 2019, 12:36 PM -0400, Charles Monteiro via Groups.Io <charles.monteiro@...>, wrote:

Mike 

would anything that runs on Graal enjoy the same benefits? Groovy , Jruby?

Thanks

Charles 
On Sep 16, 2019, 9:17 AM -0400, Mike Hearn via Groups.Io <mike@...>, wrote:
Thanks Jamiel, looks good!

One thing you might want to play with is GraalPython. That would let you access the Corda APIs directly from an optimising Python 3 implementation that can use native modules.

https://github.com/graalvm/graalpython

Then you can use the vault query API, but direct query via JDBC and JPA would also work of course.


Mike Hearn
 

Sorry, by "Corda API" I meant the RPC API.

We might be able to support non-bytecode languages inside smart contracts one day using Truffle, yes. It'd mean a partial rewrite of the DJVM and of course, Corda would have to run on a JVM supporting Truffle. Today that means GraalVM which isn't quite the same as OpenJDK, but my understanding is that they're merging over time. Current OpenJDKs can run Truffle languages but, not at any kind of reasonable speed because the JIT compiler doesn't kick in for them.


Jamiel Sheikh
 

Thanks Mike, will explore Graal this weekend, last I looked at it was not production-grade but that may have changed now


On Mon, Sep 16, 2019 at 9:17 AM Mike Hearn via Groups.Io <mike=r3.com@groups.io> wrote:
Thanks Jamiel, looks good!

One thing you might want to play with is GraalPython. That would let you access the Corda APIs directly from an optimising Python 3 implementation that can use native modules.

https://github.com/graalvm/graalpython

Then you can use the vault query API, but direct query via JDBC and JPA would also work of course.



--
Jamiel Sheikh, CEO
54 W 40th Street
New York, NY 10018


Mike Hearn
 

The core Graal tech is in production at Twitter, at least.

GraalPython specifically is still pretty new and isn't really production grade yet. However it may well suffice for the tasks you want to do.


Nitesh Solanki
 

I had tried to do same for node.js environment around 1 year back with some RC version of GraalVM where node.js client would directly talk to corda nodes over RPC without any proxy/binding layer.

code: https://github.com/nitesh7sid/cordapp-example-nodejs-server-graalvm


I guess
GraalPython should be able to at least import corda rpc library and talk to corda nodes directly.

 

Thanks

Nitesh

From: corda-dev@groups.io <corda-dev@groups.io> On Behalf Of Mike Hearn via Groups.Io
Sent: 20 September 2019 14:53
To: corda-dev@groups.io
Subject: Re: [corda-dev] PyCorda: Python Node Analytics

 

The core Graal tech is in production at Twitter, at least.

GraalPython specifically is still pretty new and isn't really production grade yet. However it may well suffice for the tasks you want to do.

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.