Skip to content
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

JS package reorganization #565

Merged
merged 16 commits into from
Sep 24, 2021
Merged

JS package reorganization #565

merged 16 commits into from
Sep 24, 2021

Conversation

pringshia
Copy link
Contributor

@pringshia pringshia commented Sep 17, 2021

Implements #501

Overview

4 new user-facing packages added as a replacement to annotation-toolkit:

  • @annotated/shell
  • @annotated/bbox
  • @annotated/keypoint
  • @annotated/video-player

1 new dev-facing package added:

  • annotated/dev-scripts

Updated Storybook w/ new packages

An updated storybook added that refers to these new packages has been added to docs/sb.
docs/storybook currently exists during this transition phase, and will be deleted in an upcoming PR.

yarn 3 workspaces will now be required for package administration

A GitHub action has been setup to validate the monorepo configuration.

Acceptance criteria

Successfully run the storybook project with all components being pulled in from @annotated/* as opposed to the monolithic annotation-toolkit package.

# Before this PR:
$ cd packages/annotation-toolkit
$ npm run dev
$ cd ../../docs/storybook
$ npm run start

# After this PR:
$ yarn install
$ yarn build-all
$ yarn sb

Details & methodology

A subpackage can now invoke the build process from dev-scripts instead of re-implementing on it's own.

Example: @annotated/shell's package.json:

{
  "scripts": {
     "build": "dev-scripts build", // default is production build
     "build:dev": "BUILD_END=development dev-scripts build",
  }
}

To-Do

  • Lay out directory structure
  • Set up yarn workspaces w/ Lerna (guide)
    • Can we get it working with React Storybook? Yarn 2: Support Yarn v2 "Berry" storybookjs/storybook#9527
      • UPDATE - got it working, albeit with many bumps along the way. Will post an issue up highlighting these with the storybook team later.
      • Is this critical? Should this be timeboxed?
      • If we cannot is there a mitigation strategy to adapt non-workspace projects to work with workspace projects?
      • Barring all else, do we rollback and use just lerna instead, giving up on yarn workspace?
    • Migrate existing storybook configuration to new yarn berry-enabled setup
  • Consolidate build scripts and common logic into @annotated/dev-scripts. Inspo: kcd-scripts
  • Set up a GitHub Action to test monorepo setup. (Add a Github Action for testing Yarn 3 #574)

Future Work

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 17, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2021

Codecov Report

Merging #565 (0def984) into main (dfc9857) will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #565      +/-   ##
==========================================
+ Coverage   65.31%   65.36%   +0.05%     
==========================================
  Files          79       79              
  Lines        7297     7297              
==========================================
+ Hits         4766     4770       +4     
+ Misses       2531     2527       -4     
Impacted Files Coverage Δ
mephisto/abstractions/architects/mock_architect.py 91.50% <0.00%> (+2.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfc9857...0def984. Read the comment docs.

@pringshia pringshia changed the title [WIP] JS package reorganization JS package reorganization Sep 23, 2021
pringshia and others added 3 commits September 23, 2021 10:53
* Layout base folder structure

* rename scripts pkg to dev-scripts

* Add base README

* Get dev-scripts working

* Wire up new transition storybook under docs/sb

* Fix up .yarnrc.yml

* Set up @annotated/bbox package

* Add @annotated/video-player pkg

* Add more stories to the storybook

* Typo fix (#564)

* Cleaning up todo labels (#569)

* Creating required files for pypi release (#548)

* Create annotated-pks.yml

* Remove yarn version specificiation from install

* Remove random echo statements

* Update build command

* Update wrapper import

* Remove cra scripts from package.json

* Add foreach build command

* change job name

Co-authored-by: Jack Urbanek <jju@fb.com>
Copy link
Contributor

@JackUrb JackUrb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I'm a huge fan of this refactor. I think this gives us a lot of room for growth moving forward, while also maintaining plenty of flexibility for people who want to use parts of annotated for their own projects.

Some questions inline (potentially short discussions) on documentation and possibly dead commented code.

.github/workflows/annotated-pkgs.yml Show resolved Hide resolved
.gitignore Show resolved Hide resolved
docs/sb/README.md Outdated Show resolved Hide resolved
docs/sb/public/manifest.json Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
# shell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO?

packages/annotated/keypoint/src/Keypoints.jsx Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
# @annotated/dev-scripts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also TODO? Overall I think that the structure of this lends well to us having strong component-based documentation, but I don't know how much of that you'd prefer to offload into the storybook (in which case perhaps we can do some kind of generator for these readmes, or via docusaurus?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think we need to figure out where to go from here. I do like how tools like radix and blueprintjs do their documentation, e.g. https://www.radix-ui.com/docs/primitives/components/switch

Docusaurus 2.0 has MDX integration with could allow us to write markdown docs with inline components. I'm leaning towards this option.

Definitely need to have a doc day soon lol

packages/annotated/bbox/src/RRRR/index.js Outdated Show resolved Hide resolved
@@ -0,0 +1,308 @@
import React from "react";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a generic version that I derived from this code be useful in this package?

https://github.com/fairinternal/sketch_rig/blob/main/ui/www/src/components/PoseEditor.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.. this looks great! the only thing is that I don't have typescript support set up yet in @annotated/dev-scripts. I'd like to add that in, but it will most likely be a follow up PR. I'll update to your version of the PoseEditor in a follow-up PR along with that (this also makes for a great test case).

Copy link

@s0mya s0mya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for work Pratik! I'm looking forward to easily pulling in these components for the next project.

@pringshia
Copy link
Contributor Author

Thanks for the feedback guys. A second and third set of eyes is especially helpful in large PRs like these where it's easy to be distracted by the forest over the trees.

I cleaned up comments, added some development docs for Yarn, cleaned up stray initialization artifacts from create-react-app that was used for bootstrapping the storybook, and also finished the migration and replacement of the old storybook.

Also using this issue to track some of the larger documentation initiatives: #505

@pringshia pringshia merged commit 47c6fa5 into main Sep 24, 2021
@pringshia pringshia deleted the package-reorg branch September 24, 2021 19:31
@pringshia pringshia linked an issue Jan 5, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Package reorganization
5 participants