-
Notifications
You must be signed in to change notification settings - Fork 950
Conversation
* Allows model artifacts to be sent via a multipart/form-data HTTP request Towards: tensorflow/tfjs#13
Here's a first set of comments. Broadly I'm confused about the expected usage pattern for this and IOHandler generally (sorry I missed the prior reviews). It seems unlikely to me that users want to specify a location once and then write to it repeatedly (overwriting, presumably). But the API seems specifically designed for that use case, and the code requires some extra complexity to handle it safely. What am I missing? Review status: 0 of 3 files reviewed at latest revision, all discussions resolved. src/io/browser_http.ts, line 30 at r1 (raw file):
Does this need to be exported, given that users should use the factory function anyway? src/io/browser_http.ts, line 53 at r1 (raw file):
typo, but also I think you meant BrowserHTTPRequest.save() src/io/browser_http.ts, line 57 at r1 (raw file):
Unless I'm misunderstanding something, this is adding an unnecessary layer of Promise, and mixing async/await syntax with callback syntax is confusing in any case. I think you can just delete this line and make the corresponding minor tweaks below. src/io/browser_http.ts, line 58 at r1 (raw file):
Don't shadow the field name src/io/browser_http.ts, line 60 at r1 (raw file):
But if the user passed in a body, then each call to save() uses the same one (because Object.assign makes a shallow copy). Thus the formData.append calls below will accumulate artifacts in the same body. src/io/browser_http.ts, line 73 at r1 (raw file):
I think you could avoid the cast here by preparing formData in the constructor and/or in the conditional above where its type is unambiguous. src/io/browser_http.ts, line 92 at r1 (raw file):
return src/io/browser_http.ts, line 97 at r1 (raw file):
throw src/io/browser_http.ts, line 134 at r1 (raw file):
typo src/io/browser_http.ts, line 233 at r1 (raw file):
The declared return type is IOHandler; the concrete class is an implementation detail that the caller doesn't care about. Comments from Reviewable |
As David and I discussed offline, this API that involves calling
Review status: 0 of 3 files reviewed at latest revision, 10 unresolved discussions. src/io/browser_http.ts, line 30 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Good question. It doesn't need to be exported. I fixed it. Did the same fix with other IOHandler subtypes we have so far. src/io/browser_http.ts, line 53 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. src/io/browser_http.ts, line 57 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. Good point. Thanks. src/io/browser_http.ts, line 58 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. src/io/browser_http.ts, line 60 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Good catch. I decided to not allow an existing FormData passed in. The reason is that FormData is not enumerable across all browsers: Chrome has a method FormData.entries() since 2016. But I don't want to do a Chrome-only thing. I update the code and the doc. src/io/browser_http.ts, line 73 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
See my comment above. src/io/browser_http.ts, line 92 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. src/io/browser_http.ts, line 97 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. src/io/browser_http.ts, line 134 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Done. src/io/browser_http.ts, line 233 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Fixed the doc. Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 10 unresolved discussions. src/io/browser_http.ts, line 102 at r1 (raw file):
instead of a TODO, file an issue? src/io/browser_http.ts, line 128 at r1 (raw file):
nit: domain isn't the right name here Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 12 unresolved discussions, all commit checks successful. src/io/browser_http.ts, line 50 at r2 (raw file):
should you require the path be of some REST format that take the name of the model? src/io/browser_http.ts, line 84 at r2 (raw file):
this uses browser fetch, it won't be available in node, might be more compatible by using node-fetch directly. src/io/browser_http.ts, line 128 at r2 (raw file):
I would think a node server example might be more relevant here. Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 15 unresolved discussions, some commit checks pending. src/io/browser_http.ts, line 57 at r1 (raw file): Previously, caisq (Shanqing Cai) wrote…
Now that we don't allow passing in an existing src/io/browser_http.ts, line 102 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
Done. tensorflow/tfjs#290 src/io/browser_http.ts, line 128 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
But indeed that's not necessary. So I removed it. src/io/browser_http.ts, line 50 at r2 (raw file): Previously, pyu10055 (Ping Yu) wrote…
The design is to leave metadata information such as name, version etc. of the model up to the client. They can send them in headers. This keeps the API simple. Users have various constraints and requirements that I don't want to anticipate at this point. Let me know if that sounds good to you. src/io/browser_http.ts, line 84 at r2 (raw file): Previously, pyu10055 (Ping Yu) wrote…
Right, this is why we call the method When we implement HTTP for node, we'll do the following in tfjs-node: use the IOHandler interface from core and import node-fetch to implement an IOHandler. Let me know if that sounds good to you. src/io/browser_http.ts, line 128 at r2 (raw file): Previously, pyu10055 (Ping Yu) wrote…
We can add a node.js server later. The nice thing about a Python server is like this is that you can directly import keras and reconstitute a keras Model object, ready fir Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 14 unresolved discussions, some commit checks failed. src/io/browser_http.ts, line 50 at r2 (raw file): Previously, caisq (Shanqing Cai) wrote…
sounds good, still be good to have the metadata (name, version) in the ModelArtifacts, we might need to add a meta file for storage. src/io/browser_http.ts, line 84 at r2 (raw file): Previously, caisq (Shanqing Cai) wrote…
sgtm Comments from Reviewable |
Review status: 0 of 6 files reviewed at latest revision, 14 unresolved discussions, some commit checks pending. src/io/browser_http.ts, line 50 at r2 (raw file):
Agreed that metadata is useful. If you look at the existing saving modalities:
Comments from Reviewable |
HTTP request
Towards: tensorflow/tfjs#13
This change is