-
Notifications
You must be signed in to change notification settings - Fork 950
Update build process: local dependencies, build in correct order #758
Conversation
High level question - what's the motivation for this change? Is there some error you were getting? A few thoughts:
Review status: 0 of 25 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. .gitignore, line 13 at r1 (raw file):
we shouldn't be ignoring .vscode - this is checked in so we share vscode settings. package.json, line 3 at r1 (raw file):
why -dev? This will mess up our versioning scripts. demos/game_of_life/game_of_life.ts, line 82 at r1 (raw file):
you shouldn't need this, array.shape is number[] models/package.json, line 1 at r1 (raw file):
why are you removing this? the other packages extend from this. models/knn_image_classifier/package.json, line 9 at r1 (raw file):
I don't think we should be doing this type of versioning. We did this on purpose so we can gradually make changes, now if we publish a new breaking version this will break out of the box. src/util.ts, line 42 at r1 (raw file):
I don't think we're quite ready to graduate this method. We're still thinking about what a GPU implementation would be. starter/es6/package.json, line 36 at r1 (raw file):
I don't totally understand what would be the difference between "prep" and "localprep" here. Comments from Reviewable |
I agree with Nikhil here. Also since this turned out to be big invasive change, how about we chat in person and figure out what problems you were facing with the current build system and gradually (one change at a time) move it towards something better. Review status: 0 of 25 files reviewed at latest revision, 11 unresolved discussions, some commit checks failed. .gitignore, line 13 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
+1 If you are using vscode, you also use those settings. package.json, line 3 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
This is very unusual - can you elaborate a bit on Looking at popular js libraries, they use regular version (e.g. https://github.com/vuejs/vue/blob/dev/package.json#L3). The consensus is to update package.version only when we publish new version to npm. If people get confused by this, we can revisit. So far, we've had no issues. demos/package.json, line 55 at r1 (raw file):
curious, what was the problem with I agree on the part that demos should use the models dl-knn-image-classifier and dl-squeezenet at HEAD/latest demos/package.json, line 84 at r1 (raw file):
no need for demos/tsconfig.json, line 6 at r1 (raw file):
+1 to not mixing demos output with core lib output models/package.json, line 1 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
+1 this is important and should stay. this is basically a peerDeps when building standalone module for the browser. browserify-shim avoids putting core deeplearn library twice in the bundle when we package standalone knn-image-classifier in the browser. knn-image-classifier depends on both dl and squeezenet (squeezenet depends on dl) as well. models/knn_image_classifier/package.json, line 9 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
+1 We want to keep models/** separated from our latest published version, since we publish them on npm, and we want to update them at our own pace, and not break people over night. demos/ on the other hand are never meant to be published on npm, so we make them depend at master. models/yolo_mobilenet/package.json, line 8 at r1 (raw file):
peerDep is the correct thing to do here, otherwise we'll end up with several copies of core dljs, because of transitive deps and when you bundle, you'll have 3x bundle sizes. Also models SHOULD share the same core dljs engine. Comments from Reviewable |
Also let's aim to have a build system that requires the least amount of changes to scripts/workflow when we migrate models/* to its own repo and demos to its own repo. In the current system at HEAD you can replace file:// with npm-pck-name when you migrate out. In the new proposed system we will have to remove "localprep" and localbuild" and change our habits when we transition. Review status: 0 of 25 files reviewed at latest revision, 11 unresolved discussions, some commit checks failed. Comments from Reviewable |
cc @tafsiri who has experience with the JS OSS setup and community consensus |
Thanks for the helpful comments! First of all I want to be clear that I'm not trying to be disruptive-- sorry if it came across that way! There are a couple of things actually blocking me in here, and the rest was just stuff I happened across along the way. I agree these could be split up into simpler PRs, but also thought it might be easier to discuss all in one place first. The motivation is that I'm simultaneously trying to add features to DLJS and to use those features in a separate package that depends on DLJS. Thus I'll have open branches in both repos. For a given feature, I'll ultimately want to submit a DLJS PR first, followed by the dependent PR in my project repo-- but I don't want to submit either one until I'm confident that they work together correctly. So during development, I want to be able to make a coordinated change in both repos/branches, build DLJS, build my project, and test the combined result. This is exactly the situation that DLJS will be in if you put demos and models in separate repos as Daniel said, so this can be seen as preparing for that eventuality. NPM/Yarn/etc. seems to have poor support for this use case. How might we solve it? Some options:
Most of the changes here follow from the general logic of option 4. If there is a better way to do this, I'm all ears. Thanks! Review status: 0 of 20 files reviewed at latest revision, 12 unresolved discussions, some commit checks failed. .gitignore, line 13 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Oops, I confused myself because I had made changes there that were personal preferences, not to be checked in. Fixed. package.json, line 3 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Between releases, the code is neither the prior release version nor the following one. If we add a feature to DLJS and then want to use it in the development of a different package, how can we specify the dependency? If we depend on 0.5.0, it will not work (in the absence of a 'yarn link' to HEAD) because the feature is not present. If we depend on 0.5.1, it doesn't work because that version doesn't exist. See also point 9 at semver.org. I didn't look at the versioning scripts yet but would be happy to update those too to take this into account. demos/package.json, line 55 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
For deeplearn, 'latest' amounts to the same thing as file:./ here, because of the link setup. I only changed it for consistency and to look forward to separating demos into their own repo, at which point file: deps don't make sense anyway. For the model dependencies, I thought the file: style a bit weird because they're published packages, but I don't think it actually makes a difference there either for now. (Where it wouldn't work is e.g. knn-image-classifier depending on squeezenet, because knn-image-classifier is published). demos/package.json, line 84 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Yes, except that breaks when x happens to be a yarn command. The 'yarn run x' form is unambiguous so I'm much less confused about what will happen. demos/tsconfig.json, line 6 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
This one blocks 'yarn link deeplearn' entirely and so is critical for me. demos/game_of_life/game_of_life.ts, line 82 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
I agree, but without it I get a lint error at "x1 + pad" below. Maybe there's a tslint version issue...?? models/knn_image_classifier/package.json, line 9 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
+1, I get it now. I mistakenly thought that yarn-lock.json and/or package-lock.json would pin the version at publication time, but apparently those aren't published, so I agree package.json has to pin the version. That produces a really confusing situation, though, because the demos should depend on DLJS at head (whether specified as file:../ or latest), and they also depend on models/*, which may in turn depend on an older DLJS. I understand the whole point of NPM is that both versions of DLJS get installed in this situation and it actually works. Still, for this to be happening within a single repo seems unexpected. What I was trying to do, more or less, was to let the models break locally during development. It seems to me that would be informative-- i.e. it would be reassuring to see continuous verification that the models are not breaking due to core changes, and useful to be notified when a breakage does occur. In this case a breaking change would force either a) updating the model right away, or b) pinning the version if/when a breakage actually happens. So I think a good thing to do might be to let models depend on deeplearn ~0.5.0, but to try to make these dependencies track the deeplearn version instead of falling behind. In particular, it would be good to update them as part of any breaking release. I think this would cause the demos to install only the latest DLJS and not also an older one. WDYT? models/yolo_mobilenet/package.json, line 8 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
+1, got it, thanks for the explanation and sorry for my confusion! Fixed. starter/es6/package.json, line 36 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
The idea was that localprep uses the local working directory of DLJS via the link, whereas prep doesn't rely on that and can just download DLJS if needed. Normal users will want prep, but cross-repo developers will want localprep. build_and_lint_all uses the local* versions since it's clearly aimed at the cross-package (future cross-repo) integration case. One hiccup is that if you run localprep and then later just prep, you'll still have the link. Maybe there should also be a prep script that specifically unlinks things. Then localprep could be called "linkprep" and the converse could be "unlinkprep", or some such. models/package.json, line 1 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
I am starting to understand the browserify-shim stuff (i.e. now I get the reasoning for peerDeps). However I don't see how this file helps. What do you mean "the other packages extend?" There is no inheritance among nested package.jsons as far as I can tell. It appears to me that this file isn't doing anything, both because I don't see any mechanism for it to have an effect, and because the models/* package.json files already inline all of the content anyway (including, in particular, the browserify-shim entry). Am I missing something? Aha, update: browserify-shim complains if this is not here, but only because of models/util.ts. I've reverted it now, but see my comment below about ditching models/util.ts in another PR. src/util.ts, line 42 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
OK. I was trying to get rid of models/util.ts because the models/* packages were directly including that as a source file outside of their local tree (i.e., import '../util.ts'), which seemed dodgy to me. If you don't want it in DLJS yet, I see two other solutions:
I think I'd favor b; WDYT? In any case, this issue is orthogonal to everything else so I reverted all of it (except the little type update, now in models/util.ts, for 0.5.0 compatibility). Comments from Reviewable |
P.S. I know the Travis test failed, but I think the reasons are minor hiccups (not worth addressing until/unless we agree on the overall approach). Review status: 0 of 20 files reviewed at latest revision, 11 unresolved discussions, some commit checks failed. Comments from Reviewable |
Oh, one more thing: Yarn Workspaces are supposed to solve much of this (https://yarnpkg.com/lang/en/docs/workspaces/). At some point along the way I convinced myself that they wouldn't work, but now I can't figure out why, so maybe it's a great solution! If so, I think that would basically automate all of the 'yarn link's in one swoop, and would remove the need for the local* scripts. There's also Lerna (https://lernajs.io/) and other similar tools specifically addressing this problem. I was just hoping we could solve it without throwing yet another package manager into the mix. Review status: 0 of 20 files reviewed at latest revision, 11 unresolved discussions, some commit checks failed. Comments from Reviewable |
@dsmilkov @nsthorat @davidsoergel lets chat in person today. First impressions are that automating yarn link seems like a good idea rather than depending on file urls which will break as we move things into other repos. I'd have a preference for specific versions in the package.json over latest, but that mainly ends up being a workflow issue. |
OK so the offline consensus, IIUC, is:
However: in the interim, before we get to that state, I think we still need the Travis build to use deeplearn head when building demos and models (but not starters!). So I updated build_and_lint_all to reflect the minimum necessary yarn links given the status quo. Review status: 0 of 20 files reviewed at latest revision, 12 unresolved discussions, some commit checks failed. package.json, line 3 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
OK it sounds like the convention is just to leave the version string at the old value while developing towards a new release. This still smells wrong to me, because this package.json is making an assertion about the version of the code that is not true at head. But, in practice, using 'yarn link' or depending on a specific commit does work around this, so I'll drop the issue. I reverted all these -dev versions. demos/package.json, line 55 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Per offline discussion the plan is now to ditch demos/package.json at some point. In the meantime there's no harm in leaving the file: dependency here. starter/es6/package.json, line 36 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Offline consensus is to ditch the local* scripts and just make developers manage their yarn links manually (or via a workspace). I think we still need some yarn links in build_and_run_all, though, for the sake of Travis. Comments from Reviewable |
Reviewed 1 of 12 files at r2, 2 of 16 files at r3. package.json, line 46 at r3 (raw file):
if the dist directory doesn't exist, I think yarn build/tsc might fail? (since tsconfig.outDir is './dist') demos/package.json, line 55 at r3 (raw file):
i think this is dangerous, since it will include all ../node_modules (all deps of the main lib, and significantly slow down compilation). could also be related to spurious lint errors you are getting. demos/tsconfig.json, line 6 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Yup, I was +1ing your change ;) demos/game_of_life/game_of_life.ts, line 82 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Yeah, strange that you are getting that error. Try to npm unlink everything and see if you are still getting those errors? Also see comment above in demos/package.json where you did s / models/util.ts, line 18 at r3 (raw file):
strange that none of us are getting compilation error here. make sure you are using tsc 2.7.2. models/knn_image_classifier/package.json, line 9 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
Per offline discussion, models should be ideally pinned to an exact version, so we can update them at our own pace (imagine if models/* is something we don't have control over, like a third-party library using us) models/knn_image_classifier/package.json, line 9 at r3 (raw file):
let's not update this yet, since we haven't migrated the code for knn_image_classifier to use 0.5.0, nor tested it manually. models/knn_image_classifier/package.json, line 21 at r3 (raw file):
let's not update this yet, since we haven't migrated the code to use 0.5.0 yet models/knn_image_classifier/package.json, line 30 at r3 (raw file):
if you don't make a dist directory, the next command (yarn build) will fail, since tsc has -o dist/bundle.js flag models/mobilenet/package.json, line 9 at r3 (raw file):
let's not update this yet, since we haven't migrated the code to use 0.5.0 yet models/mobilenet/package.json, line 27 at r3 (raw file):
same here, i think if dist doesn't exist (new user) , yarn build might fail. models/squeezenet/package.json, line 9 at r3 (raw file):
let's not update this yet, since we haven't migrated the code to use 0.5.0 yet models/yolo_mobilenet/package.json, line 9 at r3 (raw file):
same here, revert to 0.3.15 (last version we tested this model on) scripts/build_and_lint_all, line 26 at r3 (raw file):
let's not build models againts head, since they are/will be published on npm. Let's think of them as something we don't control (like a thiry-party lib that happens to use dljs) src/util.ts, line 42 at r1 (raw file): Previously, davidsoergel (David Soergel) wrote…
I'm fine with 2), but we can push this to a later PR Comments from Reviewable |
Review status: 3 of 20 files reviewed at latest revision, 18 unresolved discussions, some commit checks failed. package.json, line 46 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
No problem-- tsc creates ./dist automatically. demos/package.json, line 55 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Depending directly on dist/ is invalid since there is no package.json there. Depending on .. should be fine, because the package.json includes "main": "dist/index.js". Also, node_modules is always ignored per the package.json docs (https://docs.npmjs.com/files/package.json#files). demos/tsconfig.json, line 6 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Yep and I was +1ing your +1-- sorry that was unclear! :) demos/game_of_life/game_of_life.ts, line 82 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
I'm running tsc 2.7.2, and just updated tslint to ~5.9.1. Still getting "(restrict-plus-operands) ... Operands of '+' operation must either be both strings or both numbers". VSCode understands that x1 and x2 are numbers already, so I can't explain it :( models/util.ts, line 18 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
This is specifically for Mobilenet, and I think the reason for this is its DLJS dependency version. mobilenet.ts line 141 has "model_util.topK(await predictions.data(), topK);", where (at HEAD) predictions.data() is a TypedArray. Previously Mobilenet was building against DLJS 0.3.15, where data() provided just a Float32Array. See thread below about whether we should build models against head or not. If we don't, we could leave this unchanged, but we'd just have to make the change again when updating Mobilenet anyway. ¯_(ツ)_/¯ models/knn_image_classifier/package.json, line 9 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Obsoleted by #769 models/knn_image_classifier/package.json, line 30 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Works for me. tsc creates ./dist as needed. models/mobilenet/package.json, line 9 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. models/mobilenet/package.json, line 27 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
no problem scripts/build_and_lint_all, line 26 at r3 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
I'd think it's still a good idea to build and lint them, just to get early notification of breaking changes. If we didn't build them, then the name "build_and_lint_all" would be a bit misleading. However I agree about not using these head builds for anything. Further down I commented out the "yarn link" entries for these, so that the demos will be built against the latest published npm version. Does that make sense? src/util.ts, line 42 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Sounds good, will do a followup PR Comments from Reviewable |
Abandoning this for now per offline discussion; we'll roll whatever useful bits remain into a cleanup later. |
There may be a lot to discuss here. This works great for me locally, and we'll see if it's OK on Travis.
One thing I don't like about this, but seems unavoidable, is that 'yarn link' doesn't work if we bump the dependency version number (See yarnpkg/yarn#2611). E.g., since the models/* packages now require the util.ts update in this PR, they can't depend on DLJS 0.5.0. I wanted to make them depend on ~0.5.1-dev and rely on 'yarn link' to resolve that version-- yet 'yarn' still complains that the version doesn't exist because it's not published to NPM. That's one reason to just depend on 'latest' for packages within the same repo. The actual version should get pinned in yarn.lock at the time of publication anyway.
This change is