neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
939 stars 231 forks source link

NodeClassAlreadyDefined Exception in Streamlit Application due to Repeated Class Registration #826

Open muelldlr opened 3 weeks ago

muelldlr commented 3 weeks ago

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

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)

grafik

Specifications (Mandatory)

Currently used versions

Versions