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

load by index, load next, load prev, option for training and eval subset, bug fix #153

Open
wants to merge 1 commit 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
67 changes: 62 additions & 5 deletions apps/js/testing_interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ var TEST_PAIRS = new Array();
var CURRENT_TEST_PAIR_INDEX = 0;
var COPY_PASTE_DATA = new Array();

var CURRENT_TASK_INDEX = 0;

// Cosmetic.
var EDITION_GRID_HEIGHT = 500;
var EDITION_GRID_WIDTH = 500;
var MAX_CELL_SIZE = 100;

var SUBSET = "training";

function loadSubset() {
var subsetSelect = document.getElementById("subset_select");
var value = subsetSelect.value;
if (value == "training") {
SUBSET = "training";
} else if (value == "evaluation") {
SUBSET = "evaluation";
} else {
errorMsg('Invalid subset');
}

selectTask();
}

function resetTask() {
CURRENT_INPUT_GRID = new Grid(3, 3);
Expand Down Expand Up @@ -77,6 +94,7 @@ function resetOutputGrid() {
syncFromEditionGridToDataGrid();
CURRENT_OUTPUT_GRID = new Grid(3, 3);
syncFromDataGridToEditionGrid();
$('#output_grid_size').val('3x3'); // otherwise on page refresh it will still keep the previous size (except if shift+ctrl+r)
resizeOutputGrid();
}

Expand Down Expand Up @@ -173,11 +191,19 @@ function loadTaskFromFile(e) {
reader.readAsText(file);
}

function randomTask() {
var subset = "training";
$.getJSON("https://api.github.com/repos/fchollet/ARC/contents/data/" + subset, function(tasks) {
var task_index = Math.floor(Math.random() * tasks.length)
function selectTask() {
$.getJSON("https://api.github.com/repos/fchollet/ARC/contents/data/" + SUBSET, function(tasks) {
if (CURRENT_TASK_INDEX < 0) {
CURRENT_TASK_INDEX = tasks.length - 1;
}
if (CURRENT_TASK_INDEX >= tasks.length) {
CURRENT_TASK_INDEX = 0;
}
var task_index = CURRENT_TASK_INDEX;
var task = tasks[task_index];

$('#task_index').val(CURRENT_TASK_INDEX);

$.getJSON(task["download_url"], function(json) {
try {
train = json['train'];
Expand All @@ -188,7 +214,8 @@ function randomTask() {
}
loadJSONTask(train, test);
//$('#load_task_file_input')[0].value = "";
infoMsg("Loaded task training/" + task["name"]);
// infoMsg("Loaded task training/" + task["name"]);
infoMsg("Loaded task " + SUBSET + "/" + task["name"]);
display_task_name(task['name'], task_index, tasks.length);
})
.error(function(){
Expand All @@ -200,6 +227,36 @@ function randomTask() {
});
}

function randomTask() {
$.getJSON("https://api.github.com/repos/fchollet/ARC/contents/data/" + SUBSET, function(tasks) {
var random = Math.random();
CURRENT_TASK_INDEX = Math.floor(Math.random() * tasks.length);

selectTask();
}).error(function(){
errorMsg('Error loading task list');
});
}

function nextTask() {
CURRENT_TASK_INDEX += 1;

selectTask();
}

function prevTask() {
CURRENT_TASK_INDEX -= 1;

selectTask();
}

function loadTaskFromInput() {
CURRENT_TASK_INDEX = $('#task_index').val();

selectTask();
}


function nextTestInput() {
if (TEST_PAIRS.length <= CURRENT_TEST_PAIR_INDEX + 1) {
errorMsg('No next test input. Pick another file?')
Expand Down
23 changes: 19 additions & 4 deletions apps/testing_interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@

<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">

<script>
selectTask();
</script>
</head>
<body>
<div id="modal_bg">
<!-- just uncomment below and comment out the script in the head above to add back the previous title page -->
<!-- <div id="modal_bg">
<div id="modal">
<div>Welcome to the ARC testing interface. <br /> Choose a task file to start, or click on "Random task" to load one from the ARC project on GitHub.</div>
<div>Welcome to the ARC testing interface. <br /> Choose a task file to start, or click on "Random task" or "First task" to load one from the ARC project on GitHub.</div>
<br />
<input type="file" class="load_task"/>
<button onclick="randomTask()" id="random_task_btn">Random task</button>
<button onclick="selectTask()" id="next_task_btn">First task</button>
</div>
</div>
</div> -->
<div id="workspace">

<div id="demonstration_examples_view">
<div class="text" id="task_demo_header">Task demonstration</div>
<div id="task_preview"></div>
Expand All @@ -44,10 +48,21 @@
<div id="evaluation_output_editor">

<div id="load_task_control_btns">
<label> Select Subset: </label>
<select id="subset_select" onchange="loadSubset()">
<option value="training">Train</option>
<option value="evaluation">Eval</option>
</select>
<br>
<label for="load_task_file_input">Load task JSON: </label>
<input type="file" id="load_task_file_input" class="load_task" style="display: none;"/>
<input type="button" value="Browse..." onclick="document.getElementById('load_task_file_input').click();" />
<button onclick="randomTask()" id="random_task_btn"> Random... </button>
<button onclick="prevTask()" id="prev_task_btn">Previous task</button>
<button onclick="nextTask()" id="next_task_btn">Next task</button>
<label for="task_index">Task: </label>
<input type="text" id="task_index" name="task index" value="0">
<button onclick="loadTaskFromInput()" id="select_task_button">Load</button>
<p>
<label id='task_name' for="random_task_btn"> Task name: </label>
<p>
Expand Down