Skip to content

Literals #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ faker = "*"
streamlit-player = "*"

[dev-packages]
mock-generators = {editable = true, path = "."}

[requires]
python_version = "3.11"
67 changes: 36 additions & 31 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion mock_generators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

import sys
sys.path.append('.')
__version__ = "0.1.0"
5 changes: 3 additions & 2 deletions mock_generators/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from tabs.design_tab import design_tab
from tabs.data_importer import data_importer_tab
from tabs.tutorial import tutorial_tab
from config import preload_state, load_generators
from config import setup_logging, preload_state, load_generators_to_streamlit

# SETUP
st.set_page_config(layout="wide")
setup_logging()
preload_state()
load_generators()
load_generators_to_streamlit()

# UI
st.title("Mock Graph Data Generator")
Expand Down
22 changes: 20 additions & 2 deletions mock_generators/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
from constants import *
from file_utils import load_json
from models.generator import generators_from_json
import logging

def setup_logging():
logger = logging.getLogger(__name__)
FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(format=FORMAT)
logger.setLevel(logging.DEBUG)

def preload_state():
if ZIPS_PATH not in st.session_state:
st.session_state[ZIPS_PATH] = DEFAULT_ZIPS_PATH
Expand All @@ -18,7 +25,6 @@ def preload_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:
Expand All @@ -32,7 +38,19 @@ def preload_state():
if MAPPINGS not in st.session_state:
st.session_state[MAPPINGS] = None

def load_generators():
def load_generators(
folderpath = str
):
try:
with open(folderpath) as input:
generators_json = load_json(folderpath)
new_generators = generators_from_json(generators_json)
return new_generators
except FileNotFoundError:
raise Exception('Generator JSONs not found.')


def load_generators_to_streamlit():
spec_filepath = st.session_state[SPEC_FILE]
generators = st.session_state[GENERATORS]
try:
Expand Down
2 changes: 0 additions & 2 deletions mock_generators/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@
CODE_TEMPLATE_FILE = "templates_file"
DEFAULT_DATA_IMPORTER_FILENAME = "neo4j_importer_model"
NEW_GENERATOR_ARGS = "new_generator_args"

# TODO: Can Streamlit's st.session hold all the data we'll be generating?
MAPPINGS = "mappings"
Loading