rx-jupyter
Advanced tools
Comparing version 5.5.9 to 5.5.10
@@ -97,3 +97,3 @@ import { JupyterContentProvider } from "../src/contents"; | ||
const create$ = JupyterContentProvider.save(serverConfig, "/path/to/content", model); | ||
const request = (create$ as AjaxObservable).request; | ||
const request = (create$.source as AjaxObservable).request; // Because of a workaround the AjaxObservable is source | ||
expect(request.url).toBe( | ||
@@ -100,0 +100,0 @@ "http://localhost:8888/api/contents/path/to/content" |
@@ -10,2 +10,3 @@ "use strict"; | ||
const base_1 = require("./base"); | ||
const operators_1 = require("rxjs/operators"); | ||
const formURI = (path) => url_join_1.default("/api/contents/", path); | ||
@@ -174,3 +175,26 @@ const formCheckpointURI = (path, checkpointID) => url_join_1.default("/api/contents/", path, "checkpoints", checkpointID); | ||
save(serverConfig, path, model) { | ||
return save(serverConfig, path, model); | ||
return save(serverConfig, path, model) | ||
.pipe(operators_1.mergeMap(async (saveXhr) => { | ||
if (saveXhr.response.errno) { | ||
return saveXhr; | ||
} | ||
const pollIntervalMs = 500; | ||
const maxPollNb = 4; | ||
// Last_modified value from jupyter server is unreliable: | ||
// https://github.com/nteract/nteract/issues/4583 | ||
// Check last-modified until value is stable. | ||
for (let i = 0; i < maxPollNb; ++i) { | ||
await new Promise(resolve => setTimeout(resolve, pollIntervalMs)); | ||
const getXhr = await get(serverConfig, path, { content: 0 }).toPromise(); | ||
if (getXhr.status === 200 && | ||
typeof getXhr.response !== "string" && | ||
getXhr.response.last_modified && | ||
Date.parse(getXhr.response.last_modified) > Date.parse(saveXhr.response.last_modified)) { | ||
// Found a newer last_modified | ||
saveXhr.response.last_modified = getXhr.response.last_modified; | ||
return saveXhr; | ||
} | ||
} | ||
return saveXhr; | ||
})); | ||
}, | ||
@@ -177,0 +201,0 @@ listCheckpoints(serverConfig, path) { |
{ | ||
"name": "rx-jupyter", | ||
"version": "5.5.9", | ||
"version": "5.5.10", | ||
"description": "RxJS 5 bindings for the Jupyter Notebook API", | ||
@@ -21,4 +21,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@nteract/commutable": "^7.2.12", | ||
"@nteract/messaging": "^7.0.7", | ||
"@nteract/commutable": "^7.3.0", | ||
"@nteract/messaging": "^7.0.8", | ||
"@types/ungap__url-search-params": "^0.1.0", | ||
@@ -31,7 +31,7 @@ "@ungap/url-search-params": "^0.2.0", | ||
"devDependencies": { | ||
"@nteract/types": "^6.0.7", | ||
"@nteract/types": "^7.0.0", | ||
"@types/js-cookie": "^2.2.0", | ||
"@types/url-join": "^4.0.0" | ||
}, | ||
"gitHead": "48e287db3d8fe3d6b8c078dc06b6cd8dfcc9ea96" | ||
"gitHead": "6effa2f8b46213616b5096b6a451947a3d8c054c" | ||
} |
@@ -7,2 +7,3 @@ import querystring from "querystring"; | ||
import { createAJAXSettings, JupyterAjaxResponse } from "./base"; | ||
import { mergeMap } from "rxjs/operators"; | ||
@@ -235,3 +236,32 @@ const formURI = (path: string) => urljoin("/api/contents/", path); | ||
save<FT extends FileType>(serverConfig: ServerConfig, path: string, model: Partial<IContent<FT>>) { | ||
return save(serverConfig, path, model); | ||
return save(serverConfig, path, model) | ||
.pipe( | ||
mergeMap(async (saveXhr: AjaxResponse) => { | ||
if (saveXhr.response.errno) { | ||
return saveXhr; | ||
} | ||
const pollIntervalMs = 500; | ||
const maxPollNb = 4; | ||
// Last_modified value from jupyter server is unreliable: | ||
// https://github.com/nteract/nteract/issues/4583 | ||
// Check last-modified until value is stable. | ||
for (let i = 0; i < maxPollNb; ++i) { | ||
await new Promise(resolve => setTimeout(resolve, pollIntervalMs)); | ||
const getXhr: AjaxResponse = await get(serverConfig, path, { content: 0 }).toPromise(); | ||
if ( | ||
getXhr.status === 200 && | ||
typeof getXhr.response !== "string" && | ||
getXhr.response.last_modified && | ||
Date.parse(getXhr.response.last_modified) > Date.parse(saveXhr.response.last_modified) | ||
) { | ||
// Found a newer last_modified | ||
saveXhr.response.last_modified = getXhr.response.last_modified; | ||
return saveXhr; | ||
} | ||
} | ||
return saveXhr; | ||
}) | ||
); | ||
}, | ||
@@ -238,0 +268,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
907100
2298
Updated@nteract/commutable@^7.3.0
Updated@nteract/messaging@^7.0.8