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

Initial React Frontend #1819

Merged
merged 5 commits into from
Oct 3, 2023
Merged

Initial React Frontend #1819

merged 5 commits into from
Oct 3, 2023

Conversation

mkly
Copy link
Contributor

@mkly mkly commented Aug 29, 2023

  • Add initial react frontend to be deployed via github pages.
  • Include GitHub action to deploy site.
  • Base is set to /helm/ to align with current deployment
  • Environment variables will need to be set in CI:
    • VITE_HELM_BENCHMARKS_ENDPOINT
    • VITE_HELM_BENCHMARKS_SUITE
  • Routes make use of HashRouter

* Add initial react frontend to be deployed via github pages.
* Include GitHub action to deploy site.
* Base is set to `/helm/` to align with current deployment
* Enviroment variables will need to be set in CI:
  - VITE_HELM_BENCHMARKS_ENDPOINT
  - VITE_HELM_BENCHMARKS_SUITE
* Routes make use of `HashRouter`
@mkly
Copy link
Contributor Author

mkly commented Aug 29, 2023

Can be viewed on the forked branch here:
https://mkly.github.io/helm/

@yifanmai
Copy link
Collaborator

This is awesome, thank you! I'll send you a review in a day or two :)

@percyliang
Copy link
Contributor

Great work - thank you!

Copy link
Collaborator

@yifanmai yifanmai left a comment

Choose a reason for hiding this comment

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

Sorry this is taking me longer to review than expected, but I left some initial comments first.

src/helm-frontend/src/components/MardownValue.test.tsx Outdated Show resolved Hide resolved
src/helm-frontend/src/components/MetricsList.tsx Outdated Show resolved Hide resolved
src/helm-frontend/src/types/GroupMetadata.ts Outdated Show resolved Hide resolved
src/helm-frontend/src/types/Metric.ts Outdated Show resolved Hide resolved
@tailwind utilities;

/**
* @TODO move me to component
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you move this to the components now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is a bit of an odd one. I added that comment originally for a reminder to look into potentially moving those styles to the components and neglected to remove it. I was unable to uncover a method to do that without introducing significant additional complexity. I am open to suggestions you may have as it is very possible I am not aware of ways to make that happen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, I'm fine with having this be here. We don't have very much component-specific CSS anyway.

src/helm-frontend/README.md Outdated Show resolved Hide resolved
.github/workflows/frontend.yml Outdated Show resolved Hide resolved
"types": ["vitest/globals", "vite/client"]
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit confused how the references field here works, and also the include field in tsconfig.node.json... could you give a quick explanation or link for my benefit? Or is this auto-generated scaffolding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does appear to be part of the template when creating the project:

https://github.com/vitejs/vite/blob/ab5c421571485df861119e1f2366a84cc12b212d/packages/create-vite/template-react-ts/tsconfig.json#L24

I am not sure why the node specific config needs to referenced.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, if it's auto-generated, then it should be okay. Maybe I will investigate further later.

prob: number;
robustness: boolean;
source_class: string;
target_class: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if TypeScript supports this, but perturbation could contain extra fields of arbitrary type.

Also I think this definition can be combined with the Perturbation.ts earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I admittedly did a bit of best guessing with some of these types. Were you thinking about something like this?

export default interface Perturbation {
  [key: string]: string | number | boolean | undefined;
  name?: string;
  display_name?: string;
  description?: string;
  computed_on?: string;
  fairness?: boolean;
  name_file_path?: string;
  person_name_type?: string;
  preserve_gender?: boolean;
  prob?: number;
  robustness?: boolean;
  source_class?: string;
  target_class?: string;
}

And then using that type in types/Stat?

That would have the benefit of still providing some additional hinting within the IDE, while still allowing for additional values.

In a related note, I did notice that there are several typos where Perturbation is written as Peturbation. I will update that once we align on the best path forward here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think [key: string]: string | number | boolean | undefined; is a good idea. And it would be a good idea to resolve the typos as well.

@mkly
Copy link
Contributor Author

mkly commented Sep 6, 2023

No problem! Thank you for the feedback and I'll address those for tomorrow.

* Fix MarkdownValue test filename
* Correct semantic markdown on homepage lists
* Fix `GroupMetaData` typo
* Fix `IMetric` typo
* Remove incorrect readme info about pre-built static files
* Add `paths` filter to only test and build within `src/helm-frontend`
* Remove incorrect readme info about pre-built static files (this was
  missed in previous commit)
Copy link
Collaborator

@yifanmai yifanmai left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, I got pre-empted by other things. Almost done with the review; only have a few components left to look through, which I should be able to finish up tomorrow.


return await displayPrediction.json() as DisplayPrediction[];
} catch (error) {
console.log(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

console.error instead of console.log (same for the other services).

@tailwind utilities;

/**
* @TODO move me to component
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, I'm fine with having this be here. We don't have very much component-specific CSS anyway.

"types": ["vitest/globals", "vite/client"]
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, if it's auto-generated, then it should be okay. Maybe I will investigate further later.

prob: number;
robustness: boolean;
source_class: string;
target_class: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think [key: string]: string | number | boolean | undefined; is a good idea. And it would be a good idea to resolve the typos as well.

Copy link
Collaborator

@yifanmai yifanmai left a comment

Choose a reason for hiding this comment

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

I think this is nearly ready for merging; just have some minor stuff left. I'm okay with punting some stuff to future PRs, if desired.

value: string;
}

export default function PreView({ value }: Props) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Preview instead of PreView (same for file name)

{subGroups.filter((subGroup) =>
(topLevelGroup.subgroups || []).includes(subGroup.name)
).map((subGroup, idx) => (
subGroup.todo
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can just do const classNames = subGroup.todo ? "ml-4 text-slate-300" : "ml-4" since the rest of the element is the same

@yifanmai
Copy link
Collaborator

Hi Mike, I am thinking of merging the current as is, because this would allow other folks to start playing around with the React Frontend and building on top of it. The remaining suggestions can be resolved in a subsequent PR. WDYT?

Fix typos and cleanup

* Fix naming typos
* Update npm package for security warning
* Remove leftover comments
@mkly
Copy link
Contributor Author

mkly commented Oct 1, 2023

I pushed some additional adjustments based on the review discussion. Please feel free to merge this in at any time. Thank you again for all your time to review the work.

@mkly
Copy link
Contributor Author

mkly commented Oct 1, 2023

As a reminder, this line will need to be adjusted in the CI/CD Github action for moving to the main branch for deployment. I did not change it because if I did this branch would no build the example site for review.

https://github.com/stanford-crfm/helm/pull/1819/files#diff-ffe3a297ed15e9a79846161a3731a580511bf13c6b5cc5a9e03ddcbd8515fdeeR38-R39

@yifanmai
Copy link
Collaborator

yifanmai commented Oct 3, 2023

Sounds good, I will change the branch name for CI/CD in a separate PR. Thanks again!

@yifanmai yifanmai merged commit d3a0cc1 into stanford-crfm:main Oct 3, 2023
6 checks passed
@yifanmai
Copy link
Collaborator

yifanmai commented Oct 3, 2023

Merged - and this is one of the biggest PRs we've merged so far. Congrats and thanks again @mkly !

@percyliang
Copy link
Contributor

Thank you for the great work, @mkly !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants