-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move examples from ml5-example to the core ml5-library repo #831
Conversation
Hi @bomanimc - Super cool what you've done here! A few notes: in "examples:serve": "live-server ./examples --port=8081 --mount=/:./examples",
My vote would be to merge this in and refine as needed! 💯 |
Thanks for the comments @joeyklee! Good idea to run One question!
@joeyklee just to make sure I understand, would the goal of this change be to ensure that people who run |
fb5c6de
to
634ea88
Compare
19f960f
to
a660ab7
Compare
If we run So the idea of not specifically serving the |
Ahh okay, I think I understand! So the That said, the development process still requires people to remember to run Let me know if that makes sense and/or addresses what you were mentioning! |
I can see the advantages and disadvantages of both. I would be more prone to option A for now, and keep the |
OH! okay I fully understand now! The benefit of serving the examples folder instead of the interface is that people don't have to worry about running the I agree with you! Option A sounds like the best bet. I'll update this PR to use: |
|
Updated! I'll wait to see if anyone has feedback before moving forward here. Taken from #809, here are some of the next steps I think we can take (in order): I'll start with number #2 of this process!
|
|
Thanks for the suggestion @joeyklee and for your comments on ml5js/ml5-examples#262 and #790! I thought about the process a bit more, and I think it may make sense to follow your suggestion of archiving the repo sooner rather than later. Instead of trying to merge multiple PRs into the examples repo now as I suggested in my process above, it probably is safer to reopen PRs for those changes in this repository once the transition is complete. This reduces the number of changes we're working with for this examples-library merger, avoids forcing us to merge in anything we still might want to polish before releasing, and saves time fixing conflicts on the ml5-examples repo. I think what would make sense is to:
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bomanimc - based on our discussions and the current roadmap I approve this PR!
a660ab7
to
78fd1e3
Compare
abd7c78
to
4202f82
Compare
@joeyklee I think that the changes in #846 should fix the test errors we're seeing on this build. That's because one of the errors here related to a batch normalization bug that's discussed in tensorflow/tfjs#2170 that was later fixed in tensorflow/tfjs#2174, which was released in a version of tfjs higher than the one that we've been using. Once #846 is merged, I'll rebase these branches and see if it helps! |
78fd1e3
to
c562b2b
Compare
…public to keep the URL clean
…can reference development ml5.js build
…on during production build process
… instead of ml5-examples
4202f82
to
9662522
Compare
Finally got the tests to pass! Merging this in now. |
Woohoo!!! Big moves! 🙏 Super great effort here! |
Context
This is PR proposes significant changes to the library structure and deployment process! See full context on the reasoning behind these changes in #809.
This PR focuses on preparing
The base branch is
bomani.add-examples
, which is a branch off of thedevelopment
branch in this repository which contains a direct copy of the contents for thedevelopment
branch on theml5-examples
repo. The reason I did things this way was to make it easier to see relevant changes in this PR by separating out the hundreds/thousands of files involved in porting over code fromml5-examples
into this repo.Changes
Summary of the important changes:
ml5-examples
repo into a folder namedexamples/
in this repo.examples/
folder into a static-deployment-ready folder calleddist_examples/
. During this process, all references to the locally served version of the ml5.js library are automatically replaced with a reference to the @latest UNPKG version of ml5.js.It's important to also note that this change, in its current form, increases the size of this repository from 793MB (on the current development branch) to 1.6GB (on this branch). Both numbers are measured after node_modules have been installed on my MacBook Pro running Mojave. These numbers are probably rough and may differ between devices, but adding them here to give a sense of the difference.
I verified that the size of the bundle served to NPM through the
dist
folder has not increased as a result of these changes.Updated Workflow
You can start a server or your machine to view a local version of the ml5 examples index web page that links to every example in the project. You can use this local version of the examples index to test new and old examples against changes you're making to the core library.
Open your terminal
After running the above commands, a local version of the ml5 examples index web site should open at http://localhost:8081/ in your default browser. The page will automatically refresh itself each time a change is made to any file in the
examples/
directory. Additionally, thenpm run develop
command triggerswebpack-dev-server
to build theml5.js
core library file and serve it at http://localhost:8080/. Since all of the examples load their copies ofml5.js
from http://localhost:8080/ml5.js, you'll be able to see how core library changes influence your examples in real-time.For example, if I change
ml5-library/examples/p5js/BodyPix/BodyPix_Image/index.html
, the browser will refresh automatically. If I changeml5-library/src/BodyPix/index.js
the browser will also refresh (in the future, we can consider adding hot module reloading for this case).Deploying Examples
After these changes, we'll also need to switch the deployment process, since we'll no longer be using GH Pages to deploy the examples site.
Suggest approach: Create a new Netlify project to serve the examples online (e.g. examples.ml5js.org) and trigger builds when new changes are pushed to the release branch. We should specify Netlify to run the
npm run examples:build
command and serve the resultingdist_examples/
folder. I'd suggest serving it at examples.ml5js.org, and I'm happy to set this up if I can be given access to the Netlify team.Next Steps & Open Questions
Please see #809 for further discussion on the merits and drawbacks of this high-level approach. I've left recent comments there with my remaining concerns about how a change like this influence the library in the long-term.
Furthermore, we also should consider how to decrease the overall repository size. Currently, we have a variety of model files that are over 5MB: