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

Remove reference to run name for clients and use Table #97

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

nafiz1001
Copy link
Collaborator

No description provided.

@nafiz1001 nafiz1001 changed the title Remove reference to run name for Triton clients Remove reference to run name for Triton clients and use Table Oct 1, 2024
@nafiz1001 nafiz1001 changed the title Remove reference to run name for Triton clients and use Table Remove reference to run name for clients and use Table Oct 1, 2024
title: "",
dataIndex: "id",
key: "metric",
width: "1%",
Copy link
Collaborator

Choose a reason for hiding this comment

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

manually assigning css related values at this level is not good frontend dev practice. its good to have the styling centralized at either the each level of interest, (in the index.scss file, global.scss, etc)

Copy link
Collaborator

Choose a reason for hiding this comment

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

all the components logic was crammed into this file, i strongly suggest refactoring this to be more modular

Copy link
Collaborator

Choose a reason for hiding this comment

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

i dont think the name is indicative of what is truly happening within the component, there is useDatasetColumns hook, the MetricButton, the StagingButton and Expiration components with each their own respective logic in the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I could create other files like "hook.ts" or "helpers.ts"

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes for the hooks.ts but no need to have a helper file, you could use the other components folder structure as an example, ie : the StagingButton is a component in itself with its interface and logic.

currentRequest.status !== "FAILED"
) {
const { type, status } = currentRequest
const actions: ActionDropdownProps["actions"] = [
Copy link
Collaborator

@samouzegar10 samouzegar10 Oct 16, 2024

Choose a reason for hiding this comment

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

this dropdown can be simplified, an example can be found in src\components\ProjectActionsDropdown\index.tsx

Copy link
Collaborator

@samouzegar10 samouzegar10 Oct 16, 2024

Choose a reason for hiding this comment

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

although i am ambivalent towards this change, i dont think it is necessary
using the imported ExternalProjectID type in order to assign string into the already string assigned variable unless the ExternalProjectID has some extra conditions, i dont see the relevance.

Copy link
Collaborator Author

@nafiz1001 nafiz1001 Oct 17, 2024

Choose a reason for hiding this comment

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

It's mainly in case external project id changes type from string to something else. It indeed has no relevance currently, but imo type is a great way of enforcing the meaning of a variable despite what @UlysseFG would say.

}, [])
}

interface MetricProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there are multiple interfaces in this file. i suggest to refactor this file to be more modular, as per my previous comment.

Comment on lines +19 to +54
useEffect(() => {
;(async () => {
const datasets = await dispatch(fetchDatasets(externalProjectID))
setDataSource(
datasets.map((dataset) => ({
id: dataset.id,
lane: dataset.lane,
external_project_id: dataset.external_project_id,
latest_release_update: new Date(
dataset.latest_release_update,
),
isFetchingRequest: true,
activeRequest: undefined,
totalSize: 0, // size of 0 indicates that the size is not yet fetched
})),
)
setIsFetching(false)
const readsets = await dispatch(
fetchReadsets(datasets.map((dataset) => dataset.id)),
)
const requests = await dispatch(
fetchRequests(datasets.map((dataset) => dataset.id)),
)
const totalSizeByDatasets = readsets.reduce<
Record<TritonDataset["id"], number>
>((acc, readset) => {
acc[readset.dataset] =
(acc[readset.dataset] || 0) + readset.total_size
return acc
}, {})
const activeRequestByDatasets = requests.reduce<
Record<TritonDataset["id"], TritonRequest | undefined>
>((acc, request) => {
acc[request.dataset_id] = request
return acc
}, {})
Copy link
Collaborator

Choose a reason for hiding this comment

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

this single useEffect hook function has a lot of logic in it. it would be good to create functions in order to compartmentalize the logic into their own functions (the same approach as with the components but at the function level)

@samouzegar10
Copy link
Collaborator

this branch needs a rebase and there are some conflicts to resolve

Comment on lines +301 to +320
onClick={() => {
if (status === "SUCCESS") {
Modal.info({
title: `Dataset successfully staged`,
content: [
`You can now download the dataset by following the instructions sent to your email.
If you don't see the email, please check your spam folder.
If it's still missing, try resetting your password and checking again.
For further assistance, feel free to contact us at`,
" ",
<a
key={0}
href={`mailto:${config.supportEmail}`}
>
{config.supportEmail}
</a>,
],
})
}
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this entire section can be compartmentalized into a more sophisticated component, the newly created component could also handle errors from the received status

Comment on lines +290 to +295
let statusDescription: ReactNode
if (status === "SUCCESS") {
statusDescription = "DOWNLOAD"
} else {
statusDescription = "QUEUED"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this section can be {status === "SUCCESS" ? "DOWNLOAD": "QUEUED"} instead of assigning the statusDescription variable and then using it as a string inside the component

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.

2 participants