Skip to content

Commit

Permalink
Fixing availabale distances.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocavalcante committed Nov 15, 2019
1 parent a4ce1bd commit 8c324d0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 659 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:latest
USER root
RUN apt-get update -y
#RUN apt-get install -y apt-utils
RUN apt-get install -y apt-utils
RUN apt-get install -y python3-dev python3-pip build-essential
RUN apt-get install -y python-dev python-pip

Expand Down
17 changes: 9 additions & 8 deletions mustache/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from flask import Flask, request, Config
from celery import Celery
import uuid
import datetime as dt
import uuid

from celery import Celery
from flask import Config, Flask, request

from .util.assests import assets
from .views.api import api
from .views.dashboard import dashboard
from .views.home import home

app = Flask(__name__)
app.config.from_json("settings.json")
Expand All @@ -17,12 +23,7 @@ def format_datetime(value):
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)

from .views.dashboard import dashboard
from .views.home import home
from .views.api import api

app.register_blueprint(home, url_prefix="/")
app.register_blueprint(dashboard, url_prefix="/dashboard")
app.register_blueprint(api)

from .util.assests import assets
1 change: 0 additions & 1 deletion mustache/resources/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ FILE_NAME=$(basename "$1")
java -jar -Xmx12G IHDBSCAN.jar file=$8/$FILE_NAME minPts=$2 minClSize=$3 filter=$4 output=$5 dist_function=$6 compact=$7 separator=","

mv $8/visualization/*.mst $8/msts
rm $8/visualization/*.tree

# Runs the meta-clustering.
python hierarchies.py "$8/visualization" $FILE_NAME 2 $MPTS
Expand Down
2 changes: 1 addition & 1 deletion mustache/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def process(self, workspace, root, files, settings):
json.dump(settings, fp)

root = str(os.path.dirname(root))
venv = str(os.path.join(root, 'resources/run.sh'))

sh = str(os.path.join(root, 'resources/run.sh'))
in_file = str(os.path.join(path, files[0]['name']))

Expand Down
635 changes: 0 additions & 635 deletions mustache/templates/dashboard/index2.html

This file was deleted.

25 changes: 13 additions & 12 deletions mustache/views/api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from flask import Blueprint, request, jsonify, current_app as app, Response, redirect, url_for, send_file, send_from_directory
import datetime as dt
import json
import os
import shutil
import time
import datetime as dt
# import hdbscan
import tkinter as tk
import os
import zipfile
from io import BytesIO
from tkinter import filedialog

from flask import Blueprint, Response
from flask import current_app as app
from flask import (jsonify, redirect, request, send_file, send_from_directory,
url_for)

from .. import __file__ as base
from ..tasks.tasks import process
from ..util.helpers import rngl
Expand Down Expand Up @@ -41,8 +45,7 @@ def workspace():
@api.route("/directory")
def directory():
root = tk.Tk()
# root.iconbitmap(os.path.join(
# os.path.dirname(base), 'static/icon/favicon.ico'))

root.attributes("-topmost", True)
root.withdraw()
dirStr = filedialog.askdirectory()
Expand All @@ -56,9 +59,7 @@ def directory():

@api.route('/distance')
def distance():
# list(dict(hdbscan.dist_metrics.METRIC_MAPPING).keys())
d = ["euclidean", "cosine", "pearson", "manhattan", "supremum"]
return jsonify(d)
return jsonify(["euclidean", "cosine", "pearson", "manhattan", "supremum", "angular", "sqeuclidean"])


@api.route('/rng')
Expand All @@ -77,13 +78,13 @@ def submit():
data.append({"name": files['file-dataset'].filename,
"data": files['file-dataset'].read()})
except Exception as e:
print("file datatset error!")
print("file datatset error!", e)

try:
data.append({"name": files['file-labels'].filename,
"data": files['file-labels'].read()})
except Exception as e:
print("file labels error!")
print("file labels error!", e)

process.apply_async(
args=[app.config['WORKSPACE'], base, data, result])
Expand Down Expand Up @@ -113,7 +114,7 @@ def delete(id):
shutil.rmtree(os.path.join(root, id))
return Response("{}", status=200, mimetype='application/json')
except OSError as e:
print("Error:")
print("Error:", e)
return Response("{}", status=404, mimetype='application/json')
else:
print("Sorry, I can not find %s file.")
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export COMPOSE_PROJECT_NAME=mustache
export MUSTACHE_WORKSPACE=/home/toni/workspace
docker-compose up -d
sleep 3
xdg-open http://127.0.0.01:5000
# xdg-open http://127.0.0.01:5000

0 comments on commit 8c324d0

Please sign in to comment.