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 d6711ce commit a609653
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 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
8 changes: 4 additions & 4 deletions mustache/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 a609653

Please sign in to comment.