Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jalakoo committed May 2, 2023
1 parent 47498ba commit f988edb
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 3,327 deletions.
36 changes: 2 additions & 34 deletions mock_generators/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,20 @@
from constants import *
from tabs.importing_tab import import_tab
from tabs.design_tab import design_tab
# from tabs.integrated_design_tab import integrated_design_tab
from tabs.data_importer import data_importer_tab
from tabs.tutorial import tutorial_tab
from config import load_generators
from config import preload_state, load_generators

# TODO: Move this stuff into the config class
# SETUP
st.set_page_config(layout="wide")

# Default state
if ZIPS_PATH not in st.session_state:
st.session_state[ZIPS_PATH] = DEFAULT_ZIPS_PATH
if GENERATORS not in st.session_state:
st.session_state[GENERATORS] = None
if SPEC_FILE not in st.session_state:
st.session_state[SPEC_FILE] = DEFAULT_GENERATORS_SPEC_FILE
if CODE_FILE not in st.session_state:
st.session_state[CODE_FILE] = DEFAULT_GENERATORS_CODE_PATH
if SAMPLE_ARROWS_FILE not in st.session_state:
st.session_state[SAMPLE_ARROWS_FILE] = DEFAULT_ARROWS_SAMPLE_PATH
if IMPORTED_FILENAME not in st.session_state:
st.session_state[IMPORTED_FILENAME] = ""
if IMPORTS_PATH not in st.session_state:
st.session_state[IMPORTS_PATH] = DEFAULT_IMPORTS_PATH
# TODO: Replace with reference to selected import file
if IMPORTED_FILE not in st.session_state:
st.session_state[IMPORTED_FILE] = None
if IMPORTED_NODES not in st.session_state:
st.session_state[IMPORTED_NODES] = []
if IMPORTED_RELATIONSHIPS not in st.session_state:
st.session_state[IMPORTED_RELATIONSHIPS] = []
if EXPORTS_PATH not in st.session_state:
st.session_state[EXPORTS_PATH] = DEFAULT_EXPORTS_PATH
if CODE_TEMPLATE_FILE not in st.session_state:
st.session_state[CODE_TEMPLATE_FILE] = DEFAULT_CODE_TEMPLATES_FILE
if MAPPINGS not in st.session_state:
st.session_state[MAPPINGS] = None

preload_state()
load_generators()

# UI
st.title("Mock Graph Data Generator")
st.markdown("This is a collection of tools to generate mock graph data for [Neo4j](https://neo4j.com) graph databases. NOTE: Chromium browser recommended for best experience.")



generators = None
imported_file = None

Expand Down
39 changes: 31 additions & 8 deletions mock_generators/config.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
import streamlit as st
from constants import *
from file_utils import load_json, load_string
from models.generator import Generator, generators_from_json
import os
import sys
import logging
from widgets.folder_files import folder_files_expander
from file_utils import load_json
from models.generator import generators_from_json

def load_generators():
def preload_state():
if ZIPS_PATH not in st.session_state:
st.session_state[ZIPS_PATH] = DEFAULT_ZIPS_PATH
if GENERATORS not in st.session_state:
st.session_state[GENERATORS] = None
if SPEC_FILE not in st.session_state:
st.session_state[SPEC_FILE] = DEFAULT_GENERATORS_SPEC_FILE
if CODE_FILE not in st.session_state:
st.session_state[CODE_FILE] = DEFAULT_GENERATORS_CODE_PATH
if SAMPLE_ARROWS_FILE not in st.session_state:
st.session_state[SAMPLE_ARROWS_FILE] = DEFAULT_ARROWS_SAMPLE_PATH
if IMPORTED_FILENAME not in st.session_state:
st.session_state[IMPORTED_FILENAME] = ""
if IMPORTS_PATH not in st.session_state:
st.session_state[IMPORTS_PATH] = DEFAULT_IMPORTS_PATH
# TODO: Replace with reference to selected import file
if IMPORTED_FILE not in st.session_state:
st.session_state[IMPORTED_FILE] = None
if IMPORTED_NODES not in st.session_state:
st.session_state[IMPORTED_NODES] = []
if IMPORTED_RELATIONSHIPS not in st.session_state:
st.session_state[IMPORTED_RELATIONSHIPS] = []
if EXPORTS_PATH not in st.session_state:
st.session_state[EXPORTS_PATH] = DEFAULT_EXPORTS_PATH
if CODE_TEMPLATE_FILE not in st.session_state:
st.session_state[CODE_TEMPLATE_FILE] = DEFAULT_CODE_TEMPLATES_FILE
if MAPPINGS not in st.session_state:
st.session_state[MAPPINGS] = None

def load_generators():
spec_filepath = st.session_state[SPEC_FILE]
generators = st.session_state[GENERATORS]
try:
with open(spec_filepath) as input:
# generators_file = input.read()
generators_json = load_json(spec_filepath)
new_generators = generators_from_json(generators_json)
if generators != new_generators:
Expand Down
Loading

0 comments on commit f988edb

Please sign in to comment.