Skip to content
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

Minor fixes #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Binary file removed DataProfileViewer/.DS_Store
Binary file not shown.
84 changes: 40 additions & 44 deletions DataProfileViewer/_plot_metadata_table.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import pkg_resources
import string
import numpy as np
from dateutil.parser import parse
import json
import networkx as nx
from ._comm_api import setup_comm_api
from collections import defaultdict
import copy
import random
import datamart_profiler
Expand Down Expand Up @@ -40,57 +36,57 @@ def id_generator(size=15):
"""Helper function to generate random div ids. This is useful for embedding
HTML into ipython notebooks."""
chars = list(string.ascii_uppercase)
return ''.join(np.random.choice(chars, size, replace=True))
return ''.join(random.choices(chars, k=size))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only use of numpy, so I thought I'd remove it, even though datamart-profiler depends on numpy anyway.



def make_html(data_dict, id):
lib_path = pkg_resources.resource_filename(__name__, "build/dataProfileVis.js")
bundle = open(lib_path, "r", encoding="utf8").read()
html_all = """
<html>
<head>
</head>
<body>
<script>
{bundle}
</script>
<div id="{id}">
</div>
<script>
dataProfileVis.renderProfilerViewBundle("#{id}", {data_dict});
</script>
</body>
</html>
""".format(bundle=bundle, id=id, data_dict=json.dumps(data_dict))
return html_all
lib_path = pkg_resources.resource_filename(__name__, "build/dataProfileVis.js")
bundle = open(lib_path, "r", encoding="utf8").read()
html_all = """
<html>
<head>
</head>
<body>
<script>
{bundle}
</script>
<div id="{id}">
</div>
<script>
dataProfileVis.renderProfilerViewBundle("#{id}", {data_dict});
</script>
</body>
</html>
""".format(bundle=bundle, id=id, data_dict=json.dumps(data_dict))
return html_all

def edit_profiler_make_html(data_dict, id):
lib_path = pkg_resources.resource_filename(__name__, "build/dataProfileVis.js")
bundle = open(lib_path, "r", encoding="utf8").read()
html_all = """
<html>
<head>
</head>
<body>
<script>
{bundle}
</script>
<div id="{id}">
</div>
<script>
dataProfileVis.renderEditProfilerViewBundle("#{id}", {data_dict});
</script>
</body>
</html>
""".format(bundle=bundle, id=id, data_dict=json.dumps(data_dict))
return html_all
lib_path = pkg_resources.resource_filename(__name__, "build/dataProfileVis.js")
bundle = open(lib_path, "r", encoding="utf8").read()
html_all = """
<html>
<head>
</head>
<body>
<script>
{bundle}
</script>
<div id="{id}">
</div>
<script>
dataProfileVis.renderEditProfilerViewBundle("#{id}", {data_dict});
</script>
</body>
</html>
""".format(bundle=bundle, id=id, data_dict=json.dumps(data_dict))
return html_all

def getSample(text):
df = pandas.read_csv(StringIO(text))
result = [df.columns.values.tolist()] + df.values.tolist()
return result

def prepare_data_profiler(metadata, enet_alpha=0.001, enet_l1=0.1):
def prepare_data_profiler(metadata):
metadata = copy.deepcopy(metadata)

metadataJSON = {
Expand Down
12 changes: 6 additions & 6 deletions DataProfileViewer/js/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {EditProfilerView} from './EditProfilerView/EditProfilerView';
import "regenerator-runtime/runtime";

export function renderProfilerViewBundle(divName, data){
ReactDOM.render(
<ProfilerView data={data}/>
, select(divName).node());
ReactDOM.render(
<ProfilerView data={data}/>
, select(divName).node());
}

export function renderEditProfilerViewBundle(divName, data){
ReactDOM.render(
<EditProfilerView hit={data}/>
, select(divName).node());
ReactDOM.render(
<EditProfilerView hit={data}/>
, select(divName).node());
}
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
],
python_requires='>=3.6',
install_requires=[
"python-dateutil",
"numpy",
"scipy",
"scikit-learn",
"networkx",
"notebook",
"datamart-profiler>=0.8",
"pandas"
Expand Down