Skip to content

Commit

Permalink
Cloud updates (#10)
Browse files Browse the repository at this point in the history
* Basic literal support added - ints, floats, ranges, lists

* Datetime generator fix + keywords generator support added

* Default count and key assignments added + missing generator updates

* Random image url added and string_from_csv fixed

* ADDRESS keyword literal and mock address data generation added
  • Loading branch information
jalakoo authored May 10, 2023
1 parent f988edb commit 72b38d2
Show file tree
Hide file tree
Showing 55 changed files with 1,368 additions and 1,082 deletions.
4 changes: 4 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ streamlit-agraph = "*"
lorem-text = "*"
faker = "*"
streamlit-player = "*"
requests = "*"
pandas = "*"
random-address = "*"

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

[requires]
python_version = "3.11"
129 changes: 71 additions & 58 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

0 comments on commit 72b38d2

Please sign in to comment.