You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When repeatedly reloading a Streamlit application, classes should not be registered multiple times in the neomodel library in order to avoid a NodeClassAlreadyDefined exception. The application should be executed without errors, even if it is reloaded several times.
Actual Behavior (Mandatory)
When the Streamlit page is reloaded, a NodeClassAlreadyDefined exception occurs because the classes are registered again. This leads to an error and prevents the application from continuing to run.
How to Reproduce the Problem
Create a simple Streamlit application that uses neomodel classes.
Reload the Streamlit page several times.
Observe that a NodeClassAlreadyDefined exception is thrown on each reload.
Simple Example
import streamlit as st
from neomodel import StructuredNode, StringProperty, UniqueIdProperty, config
config.DATABASE_URL = 'bolt://neo4j:neo4j@localhost:7687'
class Component(StructuredNode):
uid = UniqueIdProperty()
name = StringProperty(unique_index=True)
version = StringProperty()
st.write("This is a test application")
Screenshots (where it's possibile)
Specifications (Mandatory)
Currently used versions
Versions
OS: Microsoft Windows 10
Library: 5.3.2
Neo4j: 5.22.0
The text was updated successfully, but these errors were encountered:
with a little help from GPT4 i found this workaround that seems to work on mine
fromneomodel.sync_.coreimportdb# Import the Neo4j Database singleton instancedefget_or_create_entity_node_class():
""" Retrieve the EntityNode class from the registry or define it if not present. """# Check if 'EntityNode' is already registered in the registryregistry=db._NODE_CLASS_REGISTRY# Access the internal registryforlabels, node_classinregistry.items():
if'EntityNode'inlabels:
print("EntityNode found in registry.")
returnnode_class# If not found, define and register the EntityNode classclassEntityNode(StructuredNode):
"""Top-level Neo4j node class for storing UUIDs and relationships."""uuid=UniqueIdProperty()
related_to=RelationshipTo('EntityNode', 'RELATED_TO')
# Register the new class in the registrydb._NODE_CLASS_REGISTRY[frozenset(['EntityNode'])] =EntityNodeprint("EntityNode registered.")
returnEntityNode# Usage:EntityNode=get_or_create_entity_node_class()
Expected Behavior (Mandatory)
When repeatedly reloading a Streamlit application, classes should not be registered multiple times in the neomodel library in order to avoid a
NodeClassAlreadyDefined
exception. The application should be executed without errors, even if it is reloaded several times.Actual Behavior (Mandatory)
When the Streamlit page is reloaded, a
NodeClassAlreadyDefined
exception occurs because the classes are registered again. This leads to an error and prevents the application from continuing to run.How to Reproduce the Problem
Create a simple Streamlit application that uses neomodel classes.
Reload the Streamlit page several times.
Observe that a NodeClassAlreadyDefined exception is thrown on each reload.
Simple Example
Screenshots (where it's possibile)
Specifications (Mandatory)
Currently used versions
Versions
The text was updated successfully, but these errors were encountered: