From f6db0dba086aa3e52facfafdde105d3bbdd7979e Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Tue, 9 Apr 2024 07:41:25 +0200 Subject: [PATCH 1/4] remove sqlalchemy from depedencies --- environment-docs.yml | 2 -- environment.yml | 2 -- requirements.txt | 3 --- 3 files changed, 7 deletions(-) diff --git a/environment-docs.yml b/environment-docs.yml index 93cdd03..a21ba02 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -14,8 +14,6 @@ dependencies: - networkx - pandas - owlready2 - - sqlalchemy <2.0.0 - - rdflib-sqlalchemy - jupyter-book - plotly - ipywidgets diff --git a/environment.yml b/environment.yml index f88eb2c..32ab4ae 100644 --- a/environment.yml +++ b/environment.yml @@ -14,7 +14,5 @@ dependencies: - networkx - pandas - owlready2 - - sqlalchemy <2.0.0 - - rdflib-sqlalchemy - plotly - ipywidgets diff --git a/requirements.txt b/requirements.txt index 7781120..d048f6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,10 +4,7 @@ rdflib pyyaml graphviz networkx -ipycytoscape pyscal3 spglib -rdflib-sqlalchemy -sqlalchemy<2.0.0 pandas owlready2 From 2d65662dd72abe11b0768ed3c4ea76271882dd98 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Tue, 9 Apr 2024 07:57:34 +0200 Subject: [PATCH 2/4] update graph --- pyscal_rdf/graph.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pyscal_rdf/graph.py b/pyscal_rdf/graph.py index 315a34c..3b0ae0c 100644 --- a/pyscal_rdf/graph.py +++ b/pyscal_rdf/graph.py @@ -6,6 +6,7 @@ from rdflib import Graph, Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef, FOAF, SKOS, DCTERMS from rdflib.store import NO_STORE, VALID_STORE +from rdflib import plugin import os import numpy as np @@ -93,9 +94,24 @@ def __init__(self, graph_file=None, elif store=="SQLAlchemy": + #check for modules + try: + import sqlalchemy as sa + except ImportError: + raise RuntimeError('Please install the sqlalchemy package') + try: + import rdflib_sqlalchemy as rsa + except ImportError: + raise RuntimeError('Please install the rdllib-sqlalchemy package') + + if store_file is None: raise ValueError("store file is needed if store is not memory") - self.graph = Graph(store="SQLAlchemy", identifier=identifier) + try: + self.graph = Graph(store="SQLAlchemy", identifier=identifier) + except plugin.PluginException: + raise + uri = Literal(f"sqlite:///{store_file}") self.graph.open(uri, create=True) else: From a8babbb48e115b5b03fa3a70b6d23110aaf16857 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Tue, 9 Apr 2024 07:59:34 +0200 Subject: [PATCH 3/4] add checks for modules --- pyscal_rdf/graph.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pyscal_rdf/graph.py b/pyscal_rdf/graph.py index 3b0ae0c..5ffd75b 100644 --- a/pyscal_rdf/graph.py +++ b/pyscal_rdf/graph.py @@ -102,20 +102,15 @@ def __init__(self, graph_file=None, try: import rdflib_sqlalchemy as rsa except ImportError: - raise RuntimeError('Please install the rdllib-sqlalchemy package') - + raise RuntimeError('Please install the rdllib-sqlalchemy package. The development version is needed, please do pip install git+https://github.com/RDFLib/rdflib-sqlalchemy.git@develop') if store_file is None: raise ValueError("store file is needed if store is not memory") - try: - self.graph = Graph(store="SQLAlchemy", identifier=identifier) - except plugin.PluginException: - raise uri = Literal(f"sqlite:///{store_file}") self.graph.open(uri, create=True) else: - raise ValueError("store should be pyiron_project, SQLAlchemy, or Memory") + raise ValueError("Memory or SQLAlchemy") #start the storage self.structure_store = _setup_structure_store(self.structure_store) From 60bacf4be74aae9d32b2debcc23c6fcb933b738c Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Tue, 9 Apr 2024 08:15:27 +0200 Subject: [PATCH 4/4] add missing store creation statement --- pyscal_rdf/graph.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyscal_rdf/graph.py b/pyscal_rdf/graph.py index 5ffd75b..bf0cbcb 100644 --- a/pyscal_rdf/graph.py +++ b/pyscal_rdf/graph.py @@ -107,6 +107,7 @@ def __init__(self, graph_file=None, if store_file is None: raise ValueError("store file is needed if store is not memory") + self.graph = Graph(store="SQLAlchemy", identifier=identifier) uri = Literal(f"sqlite:///{store_file}") self.graph.open(uri, create=True) else: