Skip to content

Commit

Permalink
Fixing file extension and lower case problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniocavalcante committed Nov 18, 2019
1 parent 8c324d0 commit 77dc798
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
23 changes: 7 additions & 16 deletions mustache/static/js/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ function startStep() {

function nextStep() {

var filename = $("#file-dataset")[0].files[0].name.split(".")[0]
// GETS THE FILE NAME FROM THE FILE JUST READ.
var filename = $("#file-dataset")[0].files[0].name

$("input[name='datasetName']").val(filename[0].toUpperCase() + filename.substring(1));
// INITIALIZES THE NAME AND NUMBER OF POINTS FIELDS WITH THE NAME OF THE FILE.
$("input[name='datasetName']").val(filename);
$("input[name='datasetPoints']").val(checkSum[0]);
if (checkSum[0] < 100) {
$("input[name='datasetMaxMpts']").attr("value", checkSum[0]);
} else {
$("input[name='datasetMaxMpts']").attr("value", 100);
}

$("input[name='datasetMaxMpts']").attr("value", Math.min(checkSum[0], 100));

// FORCES MAXMPTS TO BE AT LEAST ONE AND AT MOST THE NUMBER OF POINTS IN THE DATASET.
$("input[name='datasetMaxMpts']").attr("data-validation-allowing", "range[" + 1 + ";" + (checkSum[0] - 1) + "]")

$("input[name='datasetMaxMpts']").on("input", function () {
Expand All @@ -335,7 +335,6 @@ function nextStep() {
$("input[name='datasetMaxMpts']").attr("data-validation-allowing", "range[" + $(this).val() + ";" + (checkSum[0] - 1) + "]")
})


$.validate({
form: '#submitDataForm',
modules: 'logic,toggleDisabled',
Expand All @@ -362,7 +361,6 @@ function nextStep() {
}
})


$("#next1").attr("disabled", true);

}
Expand All @@ -380,7 +378,6 @@ var modal = $('#addDataModal').modalSteps({

$("#next1").attr("disabled", true);


function check(selection) {
var labels = selection[0].files[0]
Papa.parse(labels, {
Expand All @@ -406,12 +403,6 @@ function check(selection) {
$('.dropify-wrapper').has("#" + id).toggleClass("has-error")
}

// if (errors.length > 0) {
// resetFile(id);
// console.log(errors);
// return false;
// }

if (checkSum.length == 2) {
if (checkSum[0] != checkSum[1]) {
alert("Label Index Error: number of labels does not match number of dataset. ")
Expand Down
11 changes: 8 additions & 3 deletions mustache/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ 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())

settings['date-added'] = str(dt.datetime.now().timestamp())

settings['labels-file'] = str()

path = createDatasetPath(workspace, task_id)

if path:
for file in files:
f = open(os.path.join(path, file['name']), 'wb')
Expand All @@ -48,7 +53,7 @@ def process(self, workspace, root, files, settings):
outp = True
distance = str(settings['datasetDistance'])
com = False

subprocess.check_call([sh, in_file, mpts, minCluster,
rng, str(outp), distance, str(com), path], cwd=os.path.join(root, 'resources'))
else:
Expand Down
10 changes: 5 additions & 5 deletions mustache/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def directory():

@api.route('/distance')
def distance():
return jsonify(["euclidean", "cosine", "pearson", "manhattan", "supremum", "angular", "sqeuclidean"])
return jsonify(["euclidean", "cosine", "pearson", "manhattan", "supremum", "angular"])


@api.route('/rng')
Expand All @@ -70,24 +70,24 @@ def rng():
@api.route("/submit", methods=['GET', 'POST'])
def submit():
if request.method == 'POST':
result = request.form.to_dict()
form = request.form.to_dict()
files = request.files
data = []

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

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

process.apply_async(
args=[app.config['WORKSPACE'], base, data, result])
args=[app.config['WORKSPACE'], base, data, form])

time.sleep(1)

Expand Down

0 comments on commit 77dc798

Please sign in to comment.