mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-10 20:11:49 +00:00
cleanup of inference jobs
This commit is contained in:
1 parent
2bf9889634
commit
f7f6a28e12
7 files changed
+21
-85
No files matched your search
@@ -1,16 +1,11 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
// import { a } from '@react-spring/web';
|
||||
import {
|
||||
GetPendingTtsJobCount,
|
||||
GetPendingTtsJobCountIsOk,
|
||||
GetPendingTtsJobCountSuccessResponse,
|
||||
GetPendingTtsJobCount, GetPendingTtsJobCountIsOk, GetPendingTtsJobCountSuccessResponse
|
||||
} from "@storyteller/components/src/api/tts/GetPendingTtsJobCount";
|
||||
|
||||
import { JobState } from "@storyteller/components/src/jobs/JobStates";
|
||||
|
||||
import { InferenceJob } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
// import { springs } from "resources";
|
||||
// import { useInferenceJobs } from "hooks";
|
||||
import { useInferenceJobs } from "hooks";
|
||||
import { Button } from 'components/common';
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faChevronRight, faHourglass1, faRemove, faTrophy, faWarning } from "@fortawesome/free-solid-svg-icons";
|
||||
@@ -18,16 +13,14 @@ import { faChevronRight, faHourglass1, faRemove, faTrophy, faWarning } from "@fo
|
||||
const DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS = 15000;
|
||||
|
||||
interface JobsListProps{
|
||||
filter?: (job:any) => any,
|
||||
jobType: FrontendInferenceJobType,
|
||||
onSelect?: (e:any) => any,
|
||||
statusTxt: any,
|
||||
t: any,
|
||||
inferenceJobs?: any
|
||||
}
|
||||
|
||||
export default function InferenceJobsList({ filter, onSelect, statusTxt, t, inferenceJobs }: JobsListProps) {
|
||||
// const { inferenceJobs = [] } = useInferenceJobs({ type: 0 });
|
||||
// const oldJobs = thejobs || inferenceJobs;
|
||||
export default function InferenceJobsList({ jobType, onSelect, statusTxt, t }: JobsListProps) {
|
||||
const { inferenceJobs = [] } = useInferenceJobs(jobType);
|
||||
|
||||
const [pending, pendingSet] = useState<GetPendingTtsJobCountSuccessResponse>({
|
||||
success: true,
|
||||
@@ -45,31 +38,6 @@ export default function InferenceJobsList({ filter, onSelect, statusTxt, t, infe
|
||||
}
|
||||
};
|
||||
|
||||
const processStatus = (job: InferenceJob) => {
|
||||
switch (job.jobState) {
|
||||
case JobState.PENDING:
|
||||
case JobState.UNKNOWN: return 0;
|
||||
case JobState.STARTED: return 1
|
||||
case JobState.ATTEMPT_FAILED: return 2;
|
||||
case JobState.COMPLETE_FAILURE:
|
||||
case JobState.DEAD: return 3;
|
||||
case JobState.COMPLETE_SUCCESS: return 4;
|
||||
default: return -1;
|
||||
}
|
||||
};
|
||||
|
||||
const jobs = inferenceJobs.map((job: InferenceJob, i: number) => ({
|
||||
...job!,
|
||||
statusIndex: processStatus(job!)
|
||||
}));
|
||||
|
||||
// const transitions = useTransition(inferenceJobs, { // not today
|
||||
// ...springs.soft,
|
||||
// from: { opacity: 0, position: "absolute" },
|
||||
// enter: { opacity: 1, position: "relative" },
|
||||
// leave: { opacity: 0, position: "absolute" },
|
||||
// });
|
||||
|
||||
useEffect(() => {
|
||||
const fetch = async () => {
|
||||
const response = await GetPendingTtsJobCount();
|
||||
@@ -92,11 +60,9 @@ export default function InferenceJobsList({ filter, onSelect, statusTxt, t, infe
|
||||
return () => clearInterval(interval);
|
||||
}, [pending]);
|
||||
|
||||
return jobs.length ? <div {...{ className: "face-animator-jobs panel" }}>
|
||||
return inferenceJobs.length ? <div {...{ className: "face-animator-jobs panel" }}>
|
||||
<h5>{ t("headings.yourJobs") }</h5>
|
||||
{ jobs
|
||||
// .filter(filter)
|
||||
.map((job: any, key: number) => {
|
||||
{ inferenceJobs.map((job: any, key: number) => {
|
||||
return <div {...{ className: "panel face-animator-job", key }}>
|
||||
<FontAwesomeIcon {...{ className: `job-status-icon job-status-${job.statusIndex}`, icon: statusIcons[job.statusIndex] }}/>
|
||||
<div {...{ className: "job-details" }}>
|
||||
|
||||
@@ -6,10 +6,9 @@ import { InferenceJobsContext } from 'context';
|
||||
interface Props {
|
||||
children?: any;
|
||||
byCategory?: any;
|
||||
sessionWrapper?: any;
|
||||
}
|
||||
|
||||
export default function InferenceJobs({ children, byCategory, sessionWrapper }: Props) {
|
||||
export default function InferenceJobs({ children, byCategory }: Props) {
|
||||
const processStatus = (job: InferenceJob) => {
|
||||
switch (job.jobState) {
|
||||
case JobState.PENDING:
|
||||
@@ -22,7 +21,7 @@ export default function InferenceJobs({ children, byCategory, sessionWrapper }:
|
||||
default: return -1;
|
||||
}
|
||||
};
|
||||
return <InferenceJobsContext.Provider {...{ value: { byCategory, processStatus, sessionWrapper } }}>
|
||||
return <InferenceJobsContext.Provider {...{ value: { byCategory, processStatus } }}>
|
||||
{ children }
|
||||
</InferenceJobsContext.Provider>
|
||||
};
|
||||
@@ -2,18 +2,11 @@ import { useContext } from 'react';
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import { InferenceJobsContext } from 'context';
|
||||
|
||||
|
||||
interface Props {
|
||||
inferenceJobsByCategory?: any;
|
||||
type: number;
|
||||
}
|
||||
|
||||
export default function useInferenceJobs({ inferenceJobsByCategory, type }: Props) {
|
||||
export default function useInferenceJobs(jobType: FrontendInferenceJobType) {
|
||||
const { byCategory, processStatus } = useContext(InferenceJobsContext);
|
||||
const jbs = byCategory.get(FrontendInferenceJobType.FaceAnimation) || [];
|
||||
|
||||
return {
|
||||
inferenceJobs: jbs.map((job,i) => ({
|
||||
inferenceJobs: (byCategory.get(jobType) || []).map((job,i) => ({
|
||||
...job!,
|
||||
statusIndex: processStatus(job!)
|
||||
})),
|
||||
|
||||
@@ -709,16 +709,7 @@ class PageContainer extends React.Component<
|
||||
</Route>
|
||||
|
||||
<Route path="/voice-designer">
|
||||
<VoiceDesignerMainPage
|
||||
{...{
|
||||
sessionWrapper: this.props.sessionWrapper,
|
||||
sessionSubscriptionsWrapper:
|
||||
this.props.sessionSubscriptionsWrapper,
|
||||
enqueueInferenceJob: this.props.enqueueInferenceJob,
|
||||
inferenceJobs: this.props.inferenceJobs,
|
||||
inferenceJobsByCategory: this.props.inferenceJobsByCategory,
|
||||
}}
|
||||
/>
|
||||
<VoiceDesignerMainPage />
|
||||
</Route>
|
||||
|
||||
<Route path="/generate-speech">
|
||||
|
||||
@@ -170,7 +170,7 @@ export default function FaceAnimator({ enqueueInferenceJob, sessionSubscription
|
||||
<InferenceJobsList {...{
|
||||
t,
|
||||
onSelect: () => Analytics.voiceConversionClickDownload(),
|
||||
inferenceJobs: inferenceJobsByCategory.get(FrontendInferenceJobType.FaceAnimation),
|
||||
jobType: FrontendInferenceJobType.FaceAnimation,
|
||||
statusTxt
|
||||
}}/>
|
||||
<div {...{ className: "face-animator-mobile-sample" }}>
|
||||
|
||||
@@ -11,11 +11,12 @@ import { Button } from 'components/common';
|
||||
import { Analytics } from "common/Analytics";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faChevronRight, faHourglass1, faRemove, faTrophy, faWarning } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
|
||||
const DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS = 15000;
|
||||
|
||||
export default function FaceAnimatorJobs({ t }: { t: any }) {
|
||||
const { inferenceJobs = [] } = useInferenceJobs({ type: 0 });
|
||||
const { inferenceJobs = [] } = useInferenceJobs(FrontendInferenceJobType.FaceAnimation);
|
||||
const [pending, pendingSet] = useState<GetPendingTtsJobCountSuccessResponse>({
|
||||
success: true,
|
||||
pending_job_count: 0,
|
||||
|
||||
@@ -20,22 +20,12 @@ import useVoiceRequests from "./useVoiceRequests";
|
||||
import { usePrefixedDocumentTitle } from "common/UsePrefixedDocumentTitle";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faMicrophone } from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
import {
|
||||
FrontendInferenceJobType,
|
||||
// InferenceJob,
|
||||
} from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
|
||||
import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session/SessionSubscriptionsWrapper";
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import { useSession } from "hooks";
|
||||
|
||||
interface Props {
|
||||
sessionWrapper: SessionWrapper;
|
||||
sessionSubscriptionsWrapper: SessionSubscriptionsWrapper;
|
||||
inferenceJobsByCategory: any;
|
||||
}
|
||||
// interface Props {}
|
||||
|
||||
function VoiceDesignerMainPage(props: Props) {
|
||||
function VoiceDesignerMainPage() {
|
||||
usePrefixedDocumentTitle("AI Voice Designer");
|
||||
const { pathname } = useLocation();
|
||||
const { t } = useLocalize("FaceAnimator");
|
||||
@@ -44,9 +34,7 @@ function VoiceDesignerMainPage(props: Props) {
|
||||
requestVoices: true,
|
||||
});
|
||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const view = ["/voice-designer/datasets", "/voice-designer/voices"].indexOf(
|
||||
pathname
|
||||
);
|
||||
const view = ["/voice-designer/datasets", "/voice-designer/voices"].indexOf(pathname);
|
||||
const [deleteItem, setDeleteItem] = useState("");
|
||||
const [deleteType, setDeleteType] = useState("");
|
||||
const [deleteText, setDeleteText] = useState({
|
||||
@@ -204,10 +192,8 @@ function VoiceDesignerMainPage(props: Props) {
|
||||
<>
|
||||
<InferenceJobsList
|
||||
{...{
|
||||
jobType: FrontendInferenceJobType.VoiceDesignerCreateVoice,
|
||||
t,
|
||||
inferenceJobs: props.inferenceJobsByCategory.get(
|
||||
FrontendInferenceJobType.VoiceDesignerCreateVoice
|
||||
),
|
||||
statusTxt,
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user