Skip to content

Commit

Permalink
Bugs fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocavalcante committed Nov 20, 2019
1 parent a735e07 commit 6e6080c
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ VERSION
README.md
Changelog.md
Makefile
venv
/venv
venv/
venv/
__pycache__/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ venv.bak/
.dmypy.json
dmypy.json

.vscode/
.devcontainer/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN apt-get update && apt-get install -y \
COPY . /app
ENV HOME=/app
RUN chmod a+rwx app

WORKDIR /app
RUN mkdir -p workspace
RUN chmod a+rwx workspace
Expand Down
6 changes: 4 additions & 2 deletions compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
echo "Building Application.."
export COMPOSE_PROJECT_NAME=mustache
export MUSTACHE_WORKSPACE=$1

mkdir -p $1
chmod a+rwx $1
chmod -R a+rwx $1

> run.sh
echo "#!/bin/bash" >> run.sh
echo "export COMPOSE_PROJECT_NAME=mustache" >> run.sh
echo "export MUSTACHE_WORKSPACE=$1" >> run.sh
echo "docker-compose up -d" >> run.sh
echo "sleep 3" >> run.sh
echo "xdg-open http://127.0.0.01:5000" >> run.sh

chmod +x run.sh

docker-compose build --compress
25 changes: 14 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:

flask:
build: .
container_name: flask
command: >
gunicorn -b 0.0.0.0:5000
-w 4
Expand All @@ -18,16 +19,18 @@ services:
- celery

celery:
build: .
command: "celery -A mustache.celery worker --loglevel=info"
user: nobody
links:
- redis
volumes:
- '$MUSTACHE_WORKSPACE:/app/workspace'
- '.:/usr/src/app:ro'
build: .
container_name: celery
command: "celery -A mustache.celery worker --loglevel=info"
user: nobody
links:
- redis
volumes:
- '$MUSTACHE_WORKSPACE:/app/workspace'
- '.:/usr/src/app:ro'

redis:
image: redis
ports:
- '6378:6379'
container_name: redis
image: redis
ports:
- '6378:6379'
2 changes: 1 addition & 1 deletion mustache/resources/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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
# rm $8/visualization/*.tree

# Runs the meta-clustering.
python hierarchies.py "$8/visualization" $FILE_NAME 2 $MPTS
Expand Down
4 changes: 2 additions & 2 deletions mustache/static/gen/home.js

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

5 changes: 4 additions & 1 deletion mustache/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def createDatasetPath(workspace, directory):
@celery.task(bind=True)
def process(self, workspace, root, files, settings):
task_id = self.request.id.__str__()

print("task {} queued!".format(task_id))

settings['date_added'] = str(dt.datetime.now().timestamp())

path = createDatasetPath(workspace, task_id)
if path:
for file in files:
Expand All @@ -33,7 +36,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
7 changes: 5 additions & 2 deletions mustache/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ def submit():
data.append({"name": files['file-dataset'].filename,
"data": files['file-dataset'].read()})
except Exception as e:
print("file datatset error!")
print("Error loading data file:", e)

try:
data.append({"name": files['file-labels'].filename,
"data": files['file-labels'].read()})

result['labels-file'] = files['file-labels'].filename

except Exception as e:
print("file labels error!")
print("Error loading labels file:", e)

process.apply_async(
args=[app.config['WORKSPACE'], base, data, result])
Expand Down
20 changes: 9 additions & 11 deletions mustache/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,33 @@

home = Blueprint('home', __name__)


def get_datasets():
root = app.config['WORKSPACE']
datasets = {}

dirlist = [item for item in os.listdir(
root) if os.path.isdir(os.path.join(root, item))]
dirlist = [item for item in os.listdir(root) if os.path.isdir(os.path.join(root, item))]

for dir in dirlist:

file = glob.glob(os.path.join(
settingsFile = glob.glob(os.path.join(
os.path.join(root, dir), "settings"))[0]

file2 = glob.glob(os.path.join(
progressFile = glob.glob(os.path.join(
os.path.join(root, dir), "progress.json"))[0]

with open(file) as f:
data = json.load(f)
with open(settingsFile) as f:
settings = json.load(f)

with open(file2) as f:
with open(progressFile) as f:
progress = json.load(f)

if progress['stage'] == 'meta-clustering' and progress['state']['current'] == 1:
data['state'] = {'stage': 'done', 'message': '',
settings['state'] = {'stage': 'done', 'message': '',
'state': {'current': 1, 'end': 1}}
else:
data['state'] = progress
settings['state'] = progress

datasets[dir] = data
datasets[dir] = settings

return OrderedDict(sorted(datasets.items(), key=lambda x: float(x[1]['date_added']), reverse=True))

Expand Down
1 change: 0 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ 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

0 comments on commit 6e6080c

Please sign in to comment.