Skip to content
Permalink
Browse files

fixed custom fields, live update. fixed queries. fixed refresh button

  • Loading branch information...
henripal committed Mar 28, 2018
1 parent 6184d74 commit dffe4f0a6321b72f8b7eb9e08fb3c4eae39f9a3b
Showing with 36 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 frontend/src/App.vue
  3. +21 −11 frontend/src/components/chartCard.vue
  4. +12 −2 labnotebook/backend/api.py
@@ -16,3 +16,4 @@ wheels/
.ropeproject/
node_modules/
nbs/data/
.vscode/
@@ -14,8 +14,8 @@
v-model="selectedExperiment"
label="Add Experiment" min-width="300px" class="pr-5">
</v-select>
<v-btn flat icon>
<v-icon @click="getExperiments()">cached</v-icon>
<v-btn flat icon @click="getExperiments()">
<v-icon>cached</v-icon>
</v-btn>
</v-list-tile>
<transition-group name="list-complete" tag="div">
@@ -72,6 +72,7 @@ export default {
data () {
return {
liveUpdate: false,
lastUpdate: {},
possibleStandardFields: ['trainacc', 'valacc', 'trainloss'],
possibleCustomFields: {},
possibleCustomFieldsList: [],
@@ -192,34 +193,43 @@ export default {
}
},
updateSeries: function(xp_index, variableName) {
var last_timestep = this.lastUpdate[xp_index]
if (this.possibleStandardFields.includes(variableName)) {
var url = 'steps/' + xp_index
if (last_timestep) { url = url + '?start_timestep=' + last_timestep}
} else {
var url = 'customfields/' + xp_index + '?fieldname=' + variableName
if (last_timestep) { url = url + '&start_timestep=' + last_timestep}
}
this.$http.get('steps/' + xp_index).then(function(response) {
this.$http.get(url).then(function(response) {
if (Object.keys(response.body).length > 0) {
// store last timestep
this.lastUpdate['xp_index'] = response.body.timestep[response.body.timestep.length-1]
var newData = this.responseToData(response, variableName);
var oldData = this.$refs.chart.chart.get(xp_index + ',' + variableName).data
if (newData.length > oldData.length) {
var newPoints = newData.slice(oldData.length)
for (var point of newPoints) {
// maybe here don't redraw all points
this.$refs.chart.chart.get(xp_index + ',' + variableName).addPoint(point, true);
}
this.$refs.chart.chart.reflow();
// var oldData = this.$refs.chart.chart.get(xp_index + ',' + variableName).data
// if (newData.length > oldData.length) {
// var newPoints = newData.slice(oldData.length)
var i = 0
for (var point of newData) {
// maybe here don't redraw all points
var redraw = i == newData.length - 1
i += 1
this.$refs.chart.chart.get(xp_index + ',' + variableName).addPoint(point, redraw);
}
if (newData) { this.$refs.chart.chart.reflow(); }
}
})
},
runLiveUpdate: function() {
this.intervalControl = setInterval(() => {
for (var xp of this.selectedExperiments) {
for (var varname of this.standardFields) {
for (var varname of this.computedAllFields) {
this.updateSeries(xp, varname)
}
}
}, 2000);
}, 3000);
},
stopLiveUpdate: function() {
clearInterval(this.intervalControl);
@@ -37,12 +37,17 @@ def flip_dict(dict_list):

class Steps(Resource):
def get(self, run_id):
parser = reqparse.RequestParser()
parser.add_argument('start_timestep', type=int, default=0)
start_timestep = parser.parse_args()['start_timestep']

query = labnotebook.session.query(ts.step_id,
ts.timestep,
ts.run_id,
ts.trainacc,
ts.valacc,
ts.trainloss).filter(ts.run_id == run_id).all()
ts.trainloss).filter(ts.run_id == run_id).filter(
ts.timestep>start_timestep).all()
result = labnotebook.runs_schema.dump(query)[0]

return jsonify(flip_dict(result))
@@ -77,10 +82,15 @@ class CustomFields(Resource):
def get(self, run_id):
parser = reqparse.RequestParser()
parser.add_argument('fieldname', type=str)
parser.add_argument('start_timestep', type=int, default=0)

fieldname = parser.parse_args()['fieldname']
start_timestep = parser.parse_args()['start_timestep']

query = labnotebook.session.query(ts.timestep, ts.custom_fields[fieldname].label('cf')).filter(ts.run_id == run_id).all()
query = labnotebook.session.query(
ts.timestep, ts.custom_fields[fieldname].label('cf')).filter(
ts.run_id == run_id).filter(
ts.timestep>start_timestep).all()

result = labnotebook.cfs_schema.dump(query)[0]

0 comments on commit dffe4f0

Please sign in to comment.
You can’t perform that action at this time.