in src/persistence/load.ts [59:133]
function _loadExecutionFromJson(executionJson: JSONObject): CellExecution<LogCell> {
function _getString(json: JSONObject, key: string): string {
if (!json.hasOwnProperty(key) || typeof json[key] != "string") {
log("Could not find key " + key + "in object " + json);
return null;
}
return json[key] as string;
}
function _getNumber(json: JSONObject, key: string): number {
if (!json.hasOwnProperty(key) || typeof json[key] != "number") {
log("Could not find key " + key + "in object " + json);
return null;
}
return json[key] as number;
}
function _getBoolean(json: JSONObject, key: string): boolean {
if (!json.hasOwnProperty(key) || typeof json[key] != "boolean") {
log("Could not find key " + key + "in object " + json);
return null;
}
return json[key] as boolean;
}
function _getOutputs(json: JSONObject): nbformat.IOutput[] {
if (!json.hasOwnProperty("outputs") || !JSONExt.isArray(json["outputs"])) {
log("Could not find outputs in object " + json);
return null;
}
return json["outputs"] as nbformat.IOutput[];
}
if (!executionJson.hasOwnProperty("cell") || !JSONExt.isObject(executionJson["cell"])) {
log("Unexpected cell data format: cell is not an object");
return null;
}
let cellJson = executionJson["cell"] as JSONObject;
let id = _getString(cellJson, "id");
let executionCount = _getNumber(cellJson, "executionCount");
let persistentId = _getString(cellJson, "persistentId");
let executionEventId = _getString(cellJson, "executionEventId");
let hasError = _getBoolean(cellJson, "hasError");
let text = _getString(cellJson, "text");
let outputs = _getOutputs(cellJson);
let executionTimeString = _getString(executionJson, "executionTime");
let executionTime = new Date(executionTimeString);
if (
id == null ||
executionCount == null ||
hasError == null ||
persistentId == null ||
executionEventId == null ||
text == null ||
executionTime == null ||
outputs == null
) {
log("Cell could not be loaded, as it's missing a critical field.");
return null;
}
let cell = new LogCell({
id,
executionCount,
hasError,
text,
persistentId,
executionEventId,
outputs
});
return new CellExecution(cell, executionTime);
}