diff --git a/Makefile b/Makefile index e1da38cd1..2c76b6d08 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,16 @@ start-worker: upstream-sync: . ./venv/bin/activate && python cre.py --upstream_sync +generate-synthetic: + python3 -m application.scripts.generate_synthetic_graph + +populate-neo4j: + python cre.py --populate_neo4j_db + +sync-and-populate: + make upstream-sync + make populate-neo4j + dev-flask: . ./venv/bin/activate && INSECURE_REQUESTS=1 FLASK_APP=`pwd`/cre.py FLASK_CONFIG=development flask run @@ -70,7 +80,7 @@ install-python: . ./venv/bin/activate &&\ make install-deps-python &&\ playwright install - + install-typescript: yarn add webpack && cd application/frontend && yarn build @@ -104,8 +114,8 @@ clean: migrate-upgrade: [ -d "./venv" ] && . ./venv/bin/activate &&\ - export FLASK_APP=$(CURDIR)/cre.py - flask db upgrade + export FLASK_APP=$(CURDIR)/cre.py + flask db upgrade migrate-downgrade: [ -d "./venv" ] && . ./venv/bin/activate &&\ diff --git a/application/scripts/generate_synthetic_graph.py b/application/scripts/generate_synthetic_graph.py new file mode 100644 index 000000000..2df5fefc0 --- /dev/null +++ b/application/scripts/generate_synthetic_graph.py @@ -0,0 +1,55 @@ +from application.defs import cre_defs as defs +from application.cmd import cre_main as main +from application.database import db +from application import create_app, sqla # ✅ use sqla like in db_test.py + + +def generate_synthetic_cre_standard_graph(n_cres=200, n_standards=10): + collection = db.Node_collection().with_graph() + + standards = [ + defs.Standard( + name=f"Standard_{i}", + section=f"Section_{i}", + ) + for i in range(n_standards) + ] + + for standard in standards: + main.register_node(standard, collection) + + for i in range(n_cres): + linked_standards = [ + defs.Link(document=standards[i % n_standards], + ltype=defs.LinkTypes.LinkedTo) + ] + cre = defs.CRE( + id=f"{i // 1000:03}-{i % 1000:03}", + name=f"CRE_Name_{i}", + description="Synthetic CRE for benchmarking", + links=linked_standards, + ) + main.register_cre(cre, collection) + + print(f"Generated {n_cres} CREs and {n_standards} Standards.") + return collection + + +if __name__ == "__main__": + print("Starting synthetic graph generation...") + + app = create_app(mode="test") + with app.app_context(): + sqla.create_all() + collection = generate_synthetic_cre_standard_graph( + n_cres=200, n_standards=10) + + # Save collection to SQLite cache + # <-- Confirm if this method exists for Node_collection or find the right save method + # collection.save() + + # Now populate Neo4j from SQLite cache + main.populate_neo4j_db( + "/path/to/standards_cache.sqlite") # Use correct path + + print("Finished synthetic graph generation.") diff --git a/tsconfig.json b/tsconfig.json index 9a18502f2..cf3b91275 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,12 +9,26 @@ "allowSyntheticDefaultImports": true, "allowJs": true, "checkJs": false, - "lib": ["esnext", "dom"], + "lib": [ + "esnext", + "dom" + ], "outDir": "dist", "moduleResolution": "node", "keyofStringsOnly": true, "skipLibCheck": true }, - "include": ["**/*.ts", "**/*.tsx", "**/*.js", "src/**/*"], - "exclude": ["dist", "node_modules", "build", "scripts"] + "include": [ + "**/*.ts", + "**/*.tsx", + "**/*.js", + "src/**/*" + ], + "exclude": [ + "venv", + "dist", + "node_modules", + "build", + "scripts" + ] }