Skip to content

JSON import defaults to string #31

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 2 commits into from
Feb 7, 2024
Merged
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
27 changes: 15 additions & 12 deletions graph_data_generator_streamlit/ui/export_ui.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import streamlit as st
from graph_data_generator import generators
import graph_data_generator as gdg
from neo4j_uploader import upload, start_logging, stop_logging
from neo4j_uploader import upload, start_logging, stop_logging, UploadResult
import json

def export_ui():
@@ -20,7 +20,7 @@ def export_ui():
data = gdg.generate_dictionaries(mapping)

with st.expander('Generated Data'):
pretty = json.dumps(data, indent=4)
pretty = json.dumps(data, indent=4, default=str)
st.code(pretty)

# Display node and relationship counts
@@ -83,13 +83,16 @@ def on_download():
if uri is None or user is None or password is None:
st.error("Please specify the Neo4j instance credentials in the Configuration tab")
return

# Enable uploader logging
start_logging()

try:
time, nodes, rels, props = upload(neo4j_creds=(uri, user, password), data=data, should_overwrite=should_overwrite)
except Exception as e:
st.error(f"Upload failed. Please check your credentials and try again. Error encountered: {e}")

st.info(f"Upload completed in {time} seconds, {nodes} nodes created, {rels} relationships created, {props} properties set.")
else:
# Enable uploader logging
start_logging()

try:
result = upload(neo4j_creds=(uri, user, password), data=data, should_overwrite=should_overwrite)
if result.was_successful == False:
st.error(f'Upload failed. Error encountered: {result.error_message}')
else:
st.info(f"Upload completed in {result.seconds_to_complete} seconds, {result.nodes_created} nodes created, {result.relationships_created} relationships created, {result.properties_set} properties set.")
except Exception as e:
st.error(f"Upload failed. Please check your credentials and try again. Error encountered: {e}")

4 changes: 2 additions & 2 deletions graph_data_generator_streamlit/ui/generate_ui.py
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@ def generate_ui():

if st.session_state["ARROWS_DICT"] is not None:
dict = st.session_state.get("ARROWS_DICT", {}).get('graph', None)
string = json.dumps(dict, indent=4)
string = json.dumps(dict, indent=4, default=str)
st.session_state["JSON_CONFIG"] = string
if st.button('Load Sample'):
sample_raw = json.load(open("graph_data_generator_streamlit/samples/minimal.json"))
prior = json.dumps(sample_raw, indent=4)
prior = json.dumps(sample_raw, indent=4, default=str)
st.session_state["JSON_CONFIG"] = prior

txt = st.text_area("Enter .JSON config below", height=500, help="Click out of the text area to generate the .zip file.", value=st.session_state.JSON_CONFIG)
2 changes: 1 addition & 1 deletion graph_data_generator_streamlit/ui/ideate_ui.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ def arrows_uri(input: str | dict) -> str:

# Convert dict to string if needed
if isinstance(input, dict):
input = json.dumps(input)
input = json.dumps(input, default=str)

# Convert the diction object into a base 64 json string
b = input.encode('utf-8')
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mock-graph-data-generator-streamlit"
version = "0.7.6"
version = "0.7.7"
description = ""
authors = ["Jason Koo <jalakoo@gmail.com>"]
readme = "README.md"