neo4j / graph-data-science-client

A Python client for the Neo4j Graph Data Science (GDS) library
https://neo4j.com/product/graph-data-science/
Apache License 2.0
190 stars 46 forks source link

Assertion of Version #765

Open ElenaKohlwey opened 1 day ago

ElenaKohlwey commented 1 day ago

Bug: The statement assert gds.version() >= 2.2.0 (e.g. in https://github.com/neo4j/graph-data-science-client/blob/main/examples/ml-pipelines-node-classification.ipynb), line , for comparing two versions only works if the first digit behind the first dot is greater than or equal to 2. That means that 2.9.0 >= 2.2.0 will pass the test but 2.11.0 >= 2.2.0 will fail.

Possible solution: Use the packaging package:

pip install packaging
from packaging.version import Version
assert Version(gds.version()) >= Version("2.2.0")
knutwalker commented 1 day ago

alternatively, one can use the server_version already available in the gds client:

from graphdatascience import GraphDataScience, ServerVersion

gds = GraphDataScience(...)

assert gds.server_version() >= ServerVersion(2, 2, 0)
Mats-SX commented 6 hours ago

Hello @ElenaKohlwey and thanks for pointing this out. We will address it in the notebook. You can ignore the check for now and view it as indicative only. It's just there to inform people that the notebook is written towards a minimum GDS version, so that people don't try it with something that's too old. At this point we hope nobody is using anything as old as 2.2 anymore :)

ElenaKohlwey commented 6 hours ago

@Mats-SX: thanks, no worries. I found a way around for me with the above described solution. Just wanted to point it out so that it can be fixed for future users :-).