Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-gricourt committed Oct 8, 2023
2 parents b298814 + 7190808 commit 0dbc310
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.11.1](https://github.com/brsynth/neo4jsbml/tree/0.11.1) (2023-09-22)

[Full Changelog](https://github.com/brsynth/neo4jsbml/compare/0.11.0...0.11.1)

**Merged pull requests:**

- Add `dry-run` argument [\#10](https://github.com/brsynth/neo4jsbml/pull/10) ([guillaume-gricourt](https://github.com/guillaume-gricourt))
- chore\(deps\): bump actions/checkout from 3 to 4 [\#9](https://github.com/brsynth/neo4jsbml/pull/9) ([dependabot[bot]](https://github.com/apps/dependabot))
- chore\(deps\): bump github/super-linter from 4 to 5 [\#8](https://github.com/brsynth/neo4jsbml/pull/8) ([dependabot[bot]](https://github.com/apps/dependabot))

## [0.11.0](https://github.com/brsynth/neo4jsbml/tree/0.11.0) (2023-03-28)

[Full Changelog](https://github.com/brsynth/neo4jsbml/compare/0.10.1...0.11.0)
Expand Down
34 changes: 27 additions & 7 deletions docs/CHANGELOG.data.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
Changelog
=========

`0.11.1 <https://github.com/brsynth/neo4jsbml/tree/0.11.1>`__ (2023-09-22)
--------------------------------------------------------------------------

`Full
Changelog <https://github.com/brsynth/neo4jsbml/compare/0.11.0...0.11.1>`__

**Merged pull requests:**

- Add ``dry-run`` argument
`#10 <https://github.com/brsynth/neo4jsbml/pull/10>`__
(`guillaume-gricourt <https://github.com/guillaume-gricourt>`__)
- chore(deps): bump actions/checkout from 3 to 4
`#9 <https://github.com/brsynth/neo4jsbml/pull/9>`__
(`dependabot[bot] <https://github.com/apps/dependabot>`__)
- chore(deps): bump github/super-linter from 4 to 5
`#8 <https://github.com/brsynth/neo4jsbml/pull/8>`__
(`dependabot[bot] <https://github.com/apps/dependabot>`__)

.. _section-1:

`0.11.0 <https://github.com/brsynth/neo4jsbml/tree/0.11.0>`__ (2023-03-28)
--------------------------------------------------------------------------

Expand All @@ -13,15 +33,15 @@ Changelog <https://github.com/brsynth/neo4jsbml/compare/0.10.1...0.11.0>`__
`#7 <https://github.com/brsynth/neo4jsbml/pull/7>`__
(`guillaume-gricourt <https://github.com/guillaume-gricourt>`__)

.. _section-1:
.. _section-2:

`0.10.1 <https://github.com/brsynth/neo4jsbml/tree/0.10.1>`__ (2023-03-17)
--------------------------------------------------------------------------

`Full
Changelog <https://github.com/brsynth/neo4jsbml/compare/0.10.0...0.10.1>`__

.. _section-2:
.. _section-3:

`0.10.0 <https://github.com/brsynth/neo4jsbml/tree/0.10.0>`__ (2023-03-17)
--------------------------------------------------------------------------
Expand All @@ -37,23 +57,23 @@ Changelog <https://github.com/brsynth/neo4jsbml/compare/0.9.2...0.10.0>`__
- Read the docs `#5 <https://github.com/brsynth/neo4jsbml/pull/5>`__
(`guillaume-gricourt <https://github.com/guillaume-gricourt>`__)

.. _section-3:
.. _section-4:

`0.9.2 <https://github.com/brsynth/neo4jsbml/tree/0.9.2>`__ (2023-02-23)
------------------------------------------------------------------------

`Full
Changelog <https://github.com/brsynth/neo4jsbml/compare/0.9.1...0.9.2>`__

.. _section-4:
.. _section-5:

`0.9.1 <https://github.com/brsynth/neo4jsbml/tree/0.9.1>`__ (2023-02-21)
------------------------------------------------------------------------

`Full
Changelog <https://github.com/brsynth/neo4jsbml/compare/0.9.0...0.9.1>`__

.. _section-5:
.. _section-6:

`0.9.0 <https://github.com/brsynth/neo4jsbml/tree/0.9.0>`__ (2023-01-27)
------------------------------------------------------------------------
Expand All @@ -67,15 +87,15 @@ Changelog <https://github.com/brsynth/neo4jsbml/compare/0.8.3...0.9.0>`__
`#4 <https://github.com/brsynth/neo4jsbml/pull/4>`__
(`dependabot[bot] <https://github.com/apps/dependabot>`__)

.. _section-6:
.. _section-7:

`0.8.3 <https://github.com/brsynth/neo4jsbml/tree/0.8.3>`__ (2023-01-16)
------------------------------------------------------------------------

`Full
Changelog <https://github.com/brsynth/neo4jsbml/compare/0.8.0...0.8.3>`__

.. _section-7:
.. _section-8:

`0.8.0 <https://github.com/brsynth/neo4jsbml/tree/0.8.0>`__ (2023-01-16)
------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions src/neo4jsbml/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ def main():
logging.info("Connection to database")
con = None
if args.input_config_file:
if not os.path.isfile(args.input_config_file):
logging.error(
"File provided does not exist: %s" % (args.input_config_file,)
)
parser.exit(1)
logging.warning("Configuration file is provided, ignore indiviual arguments")
con = connect.Connect.from_config(path=args.input_config_file)
elif args.input_auradb_file:
if not os.path.isfile(args.input_auradb_file):
logging.error(
"File provided does not exist: %s" % (args.input_auradb_file,)
)
parser.exit(1)
logging.warning(
"Configuration file AuraDB is provided, ignore indiviual arguments"
)
Expand Down
2 changes: 1 addition & 1 deletion src/neo4jsbml/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__app_name__ = "neo4jsbml"
__version__ = "0.11.1"
__version__ = "0.11.2"
24 changes: 24 additions & 0 deletions src/neo4jsbml/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,27 @@ def from_auradb(cls, path: str) -> "Connect":
elif var == "AURA_INSTANCENAME":
data["database"] = value
return Connect(**data)

def __repr__(self):
msg = []
msg.append("Url: %s" % (self.url,))
msg.append("Protocol: %s" % (self.protocol,))
msg.append("Database: %s" % (self.database,))
user = "<empty>"
if self.user:
user = self.user
msg.append("User: %s" % (user,))
port = "<empty>"
if self.port:
port = self.port
msg.append("Port: %s" % (port,))
password = "<empty>"
if self.password:
password = "initialized"
msg.append("Password: " + password)
msg.append("Uri: " + self.uri)
is_connected = "false"
if self.is_connected():
is_connected = "true"
msg.append("Connected: " + is_connected)
return "\n".join(msg)
17 changes: 12 additions & 5 deletions src/neo4jsbml/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,24 @@ def __init__(self, id: str, properties: Dict[str, str], *args, **kwargs) -> None

def clean_properties(self):
"""Remove empty values.
Sanitize string:
- remove return line
- append a backslash in front of double quotes
Return
------
None
"""
keys = []
for k, v in self.properties.items():
if v is None or v == "":
keys.append(k)
for k in keys:
del self.properties[k]
for key, value in self.properties.items():
if value is None or value == "":
keys.append(key)
elif isinstance(value, str):
value = value.replace('"', '\\"')
value = value.replace("\n", "")
self.properties[key] = value
for key in keys:
del self.properties[key]

def has_property(self, label: str) -> bool:
"""Check if a node has a property.
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

import pytest
from neo4jsbml import connect, sbml
from neo4jsbml import connect, sbml, singleton

cur_dir = os.path.abspath(os.path.dirname(__file__))
data_dir = os.path.join(cur_dir, "dataset")
Expand Down Expand Up @@ -148,6 +148,7 @@ def rel_two_arrow():

@pytest.fixture(scope="function")
def init_driver():
singleton.Singleton.clean()
return connect.Connect(
protocol="neo4j",
url="localhost",
Expand Down
1 change: 1 addition & 0 deletions tests/dataset/database/localhost.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[connection]
protocol = neo4j
url = localhost
port = 7687
4 changes: 0 additions & 4 deletions tests/test_neo4jsbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def load_iAF1260(init_driver, config_path, pathway_two_path, iaf1260_path):
class TestiML1515:
def test_nodes(self, init_driver, load_iML1515):
query = "CALL db.labels() YIELD label CALL apoc.cypher.run('MATCH (:`'+label+'`) RETURN count(*) as count',{}) YIELD value RETURN label, value.count"
singleton.Singleton.clean()
data = init_driver.query(value=query, expect_data=True)

assert data == [
Expand All @@ -61,7 +60,6 @@ def test_nodes(self, init_driver, load_iML1515):

def test_relationships(self, init_driver, load_iML1515):
query = "CALL db.relationshipTypes() YIELD relationshipType as type CALL apoc.cypher.run('MATCH ()-[:`'+type+'`]->() RETURN count(*) as count',{}) YIELD value RETURN type, value.count"
singleton.Singleton.clean()
data = init_driver.query(value=query, expect_data=True)

assert data == [
Expand All @@ -80,7 +78,6 @@ def test_relationships(self, init_driver, load_iML1515):
class TestiAF1260:
def test_nodes(self, init_driver, load_iAF1260):
query = "CALL db.labels() YIELD label CALL apoc.cypher.run('MATCH (:`'+label+'`) RETURN count(*) as count',{}) YIELD value RETURN label, value.count"
singleton.Singleton.clean()
data = init_driver.query(value=query, expect_data=True)

assert data == [
Expand All @@ -95,7 +92,6 @@ def test_nodes(self, init_driver, load_iAF1260):

def test_relationships(self, init_driver, load_iAF1260):
query = "CALL db.relationshipTypes() YIELD relationshipType as type CALL apoc.cypher.run('MATCH ()-[:`'+type+'`]->() RETURN count(*) as count',{}) YIELD value RETURN type, value.count"
singleton.Singleton.clean()
data = init_driver.query(value=query, expect_data=True)

assert data == [
Expand Down

0 comments on commit 0dbc310

Please sign in to comment.