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

Refactor tasks into components #470

Merged
merged 3 commits into from
Jan 7, 2023

Conversation

kostiak
Copy link
Contributor

@kostiak kostiak commented Jan 7, 2023

Another draft for refactoring the tasks into components. Related to #433

Copy link
Collaborator

@AbdBarho AbdBarho 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 the PR!

pathname: "/evaluate/rank_initial_prompts",
type: "rank_initial_prompts",
},
];
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would make more sense to split this array into 2.
One for create and one for evaluate.

category could be an enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming we will have more than 2 categories, this makes it future proof. Plus, this is array is used to determine which category of component to render for random.

Regarding enum good idea, will do.

<div className={`p-12 ${mainBgClasses}`}>
<TwoColumnsWithCards>
<>
<h5 className="text-lg font-semibold">Reply as the assistant</h5>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am assuming this still needs to be updated right?

Copy link
Contributor Author

@kostiak kostiak Jan 7, 2023

Choose a reason for hiding this comment

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

Correct. On it.

Edit: added those to the TaskType and loading them from there now.

Comment on lines 5 to 20
export const Task = ({ tasks, trigger, mutate, mainBgClasses }) => {
const task = tasks[0].task;

function taskTypeComponent(type) {
const category = TaskTypes.find((taskType) => taskType.type === type).category;

switch (category) {
case "create":
return <CreateTask tasks={tasks} trigger={trigger} mutate={mutate} mainBgClasses={mainBgClasses} />;
case "evaluate":
return <EvaluateTask tasks={tasks} trigger={trigger} mutate={mutate} mainBgClasses={mainBgClasses} />;
}
}

return taskTypeComponent(task.type);
};
Copy link
Collaborator

@AbdBarho AbdBarho Jan 7, 2023

Choose a reason for hiding this comment

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

nit:

This component adds an extra level of indirection that is not necessary.
I would argue that you can directly use CreateTask or EvaluateTask in the corresponding task page.

That being said, I understand its value for the random task type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I make a unified component and also combined everything into one array is because I'm assuming we will have more tasks in future, so we will need to know how to handle any type, given the response from the backend.

@fozziethebeat
Copy link
Collaborator

This looks pretty good. I'll approve and merge after you've marked it ready for review and comment on or address @AbdBarho's comments.

@kostiak kostiak requested a review from AbdBarho January 7, 2023 15:35
@AbdBarho AbdBarho marked this pull request as ready for review January 7, 2023 15:58
Copy link
Collaborator

@AbdBarho AbdBarho left a comment

Choose a reason for hiding this comment

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

thanks

@AbdBarho AbdBarho merged commit 4ecdc57 into LAION-AI:main Jan 7, 2023
@kostiak kostiak deleted the website-tasks-refactor-2 branch January 7, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants