Skip to content

Commit

Permalink
Merge pull request #943 from singnet/training
Browse files Browse the repository at this point in the history
Training
  • Loading branch information
MarinaFedy authored Nov 19, 2024
2 parents 8d99571 + 374ac46 commit c61e5da
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
18 changes: 17 additions & 1 deletion src/Redux/actionCreators/ServiceDetailsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getAPI, initializeAPIOptions } from "../../utility/API";
import { fetchAuthenticatedUser } from "./UserActions";
import { loaderActions } from "./";
import { LoaderContent } from "../../utility/constants/LoaderContent";
// import { cacheS3Url } from "../../utility/image";
import { isEmpty } from "lodash";

export const UPDATE_SERVICE_DETAILS = "UPDATE_SERVICE_DETAILS";
export const RESET_SERVICE_DETAILS = "RESET_SERVICE_DETAILS";
Expand Down Expand Up @@ -87,3 +87,19 @@ export const fetchMeteringData =
const usageData = await meteringAPI(token, orgId, serviceId, groupId, email);
return dispatch(fetchMeteringDataSuccess(usageData));
};

export const getIsTrainingAvailable = (detailsTraining, isLoggedIn) => {
if (isEmpty(detailsTraining)) {
return false;
}

if (!Object.prototype.hasOwnProperty.call(detailsTraining, "trainingMethods")) {
return false;
}

return (
process.env.REACT_APP_TRAINING_ENABLE === "true" &&
Object.keys(detailsTraining.trainingMethods).length &&
isLoggedIn
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ModelDetails = ({ classes, openEditModel, model, address }) => {
</div>
</div>
<div className={classes.actionButtons}>
<Button className={classes.testBtn} onClick={handleSetModel} disabled={!isInferenceAvailable}>
<Button className={classes.inferenceBtn} onClick={handleSetModel} disabled={!isInferenceAvailable}>
<NearMeOutlinedIcon />
<span>Inference</span>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@ export const useStyles = (theme) => ({
},
},
updateBtn: { color: theme.palette.text.darkShadedGray },
testBtn: {
inferenceBtn: {
background: theme.palette.text.primary,
color: theme.palette.text.white,
"&:hover": {
background: theme.palette.text.customHoverBlue,
},
"&:disabled": {
backgroundColor: theme.palette.text.lightGray,
color: theme.palette.text.white,
},
},
deleteBtn: { color: theme.palette.text.redBtnText },
deleteModalContent: {
Expand Down
11 changes: 7 additions & 4 deletions src/components/ServiceDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import AboutService from "./AboutService";
import InstallAndRunService from "./InstallAndRunService";
import NotificationBar, { notificationBarTypes } from "../common/NotificationBar";

import { fetchTrainingModel, fetchServiceDetails } from "../../Redux/actionCreators/ServiceDetailsActions";
import {
fetchTrainingModel,
fetchServiceDetails,
getIsTrainingAvailable,
} from "../../Redux/actionCreators/ServiceDetailsActions";
import {
pricing as getPricing,
serviceDetails as getServiceDetails,
Expand All @@ -43,7 +47,7 @@ const ServiceDetails = ({ classes }) => {
const { orgId, serviceId, tabId } = useParams();

const isLoggedIn = useSelector((state) => state.userReducer.login.isLoggedIn);
const training = useSelector((state) => state.serviceDetailsReducer.detailsTraining);
const detailsTraining = useSelector((state) => state.serviceDetailsReducer.detailsTraining);
const service = useSelector((state) => getServiceDetails(state, orgId, serviceId));
const groupInfo = useSelector((state) => getGroupInfo(state));
const pricing = useSelector((state) => getPricing(state));
Expand Down Expand Up @@ -89,8 +93,7 @@ const ServiceDetails = ({ classes }) => {
);
}

const isTrainingAvailable =
process.env.REACT_APP_TRAINING_ENABLE === "true" && Object.keys(training).length && isLoggedIn;
const isTrainingAvailable = getIsTrainingAvailable(detailsTraining, isLoggedIn);

const tabs = [
{
Expand Down

0 comments on commit c61e5da

Please sign in to comment.