Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
try {
setQualificationsOptions(await getQualifications(jobRequest.chainId));
} catch (error) {
console.error('Error fetching data:', error);

Check warning on line 65 in packages/apps/job-launcher/client/src/components/Jobs/Create/CvatJobRequestForm.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
}
}
};
Expand Down Expand Up @@ -99,6 +99,7 @@
gtPath,
userGuide,
accuracyTarget,
jobBounty,
}: ReturnType<typeof mapCvatFormValues>) => {
let bp = undefined;
if (type === CvatJobType.IMAGE_BOXES_FROM_POINTS) {
Expand Down Expand Up @@ -154,7 +155,8 @@
path: gtPath,
},
userGuide,
accuracyTarget,
accuracyTarget: Number(accuracyTarget),
jobBounty: Number(jobBounty),
},
});
goToNextStep();
Expand Down Expand Up @@ -830,6 +832,35 @@
/>
</FormControl>
</Grid>
<Grid item xs={12} sm={12} md={6}>
<FormControl fullWidth>
<TextField
name="jobBounty"
label="Job bounty"
placeholder="Job bounty"
type="number"
value={values.jobBounty}
onChange={(e) =>
setFieldValue('jobBounty', e.target.value)
}
onBlur={handleBlur}
error={touched.jobBounty && Boolean(errors.jobBounty)}
helperText={errors.jobBounty}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Tooltip title="Reward per CVAT job chunk used in the manifest.">
<HelpOutlineIcon
color="secondary"
sx={{ cursor: 'pointer' }}
/>
</Tooltip>
</InputAdornment>
),
}}
/>
</FormControl>
</Grid>
</Grid>
</Grid>
</AccordionDetails>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const mapCvatFormValues = (
: [],
userGuide: cvatRequest?.userGuide || '',
accuracyTarget: cvatRequest?.accuracyTarget || 80,
jobBounty: cvatRequest?.jobBounty || 0,
dataProvider: cvatRequest?.data?.dataset?.provider || StorageProviders.AWS,
dataRegion:
(cvatRequest?.data?.dataset?.region as AWSRegions | GCSRegions) || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const CvatJobRequestValidationSchema = Yup.object().shape({
.required('Accuracy target is required')
.moreThan(0, 'Accuracy target must be greater than 0')
.max(100, 'Accuracy target must be less than or equal to 100'),
jobBounty: Yup.number()
.typeError('Job bounty is required')
.required('Job bounty is required')
.moreThan(0, 'Job bounty must be greater than 0'),
qualifications: Yup.array().of(Yup.object()),
});

Expand Down
2 changes: 2 additions & 0 deletions packages/apps/job-launcher/client/src/constants/cvat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const CVAT_JOB_SIZE = 10;
export const CVAT_VAL_SIZE = 2;
81 changes: 65 additions & 16 deletions packages/apps/job-launcher/client/src/services/job.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,88 @@
import { ChainId } from '@human-protocol/sdk';
import { CVAT_JOB_SIZE, CVAT_VAL_SIZE } from '../constants/cvat';
import {
CreateFortuneJobRequest,
CreateCvatJobRequest,
CreateJobRequest,
FortuneRequest,
CvatRequest,
JobStatus,
JobDetailsResponse,
FortuneFinalResult,
FortuneManifest,
CvatManifest,
JobType,
StorageProviders,
} from '../types';
import api from '../utils/api';
import { getFilenameFromContentDisposition } from '../utils/string';

const buildFortuneManifest = (data: FortuneRequest): FortuneManifest => ({
submissionsRequired: Number(data.fortunesRequested),
requesterTitle: data.title,
requesterDescription: data.description,
requestType: JobType.FORTUNE,
qualifications: data.qualifications,
});

const buildBucketUrl = ({
provider,
region,
bucketName,
path,
}: CvatRequest['data']['dataset']) => {
if (provider === StorageProviders.AWS) {
return `https://${bucketName}.s3.${region}.amazonaws.com${
path ? `/${path.replace(/\/$/, '')}` : ''
}`;
}

return `https://${bucketName}.storage.googleapis.com${path ? `/${path}` : ''}`;
};

const buildCvatManifest = (data: CvatRequest): CvatManifest => ({
data: {
dataUrl: buildBucketUrl(data.data.dataset),
...(data.data.points && {
pointsUrl: buildBucketUrl(data.data.points),
}),
...(data.data.boxes && {
boxesUrl: buildBucketUrl(data.data.boxes),
}),
},
annotation: {
labels: data.labels,
description: data.description,
userGuide: data.userGuide,
type: data.type,
jobSize: CVAT_JOB_SIZE,
...(data.qualifications?.length && {
qualifications: data.qualifications,
}),
},
validation: {
minQuality: Number(data.accuracyTarget) / 100,
valSize: CVAT_VAL_SIZE,
gtUrl: buildBucketUrl(data.groundTruth),
},
jobBounty: String(data.jobBounty),
});

export const createFortuneJob = async (
chainId: number,
data: FortuneRequest,
paymentCurrency: string,
paymentAmount: number | string,
escrowFundToken: string,
) => {
const body: CreateFortuneJobRequest = {
const body: CreateJobRequest<FortuneManifest> = {
chainId,
submissionsRequired: Number(data.fortunesRequested),
requesterTitle: data.title,
requesterDescription: data.description,
requestType: JobType.FORTUNE,
paymentCurrency,
paymentAmount: Number(paymentAmount),
escrowFundToken,
qualifications: data.qualifications,
manifest: buildFortuneManifest(data),
};
await api.post('/job/fortune', body);
await api.post('/job', body);
};

export const createCvatJob = async (
Expand All @@ -38,21 +92,16 @@ export const createCvatJob = async (
paymentAmount: number | string,
escrowFundToken: string,
) => {
const body: CreateCvatJobRequest = {
const body: CreateJobRequest<CvatManifest> = {
chainId,
requesterDescription: data.description,
requestType: data.type,
paymentCurrency,
paymentAmount: Number(paymentAmount),
escrowFundToken,
data: data.data,
labels: data.labels,
minQuality: Number(data.accuracyTarget) / 100,
groundTruth: data.groundTruth,
userGuide: data.userGuide,
type: data.type,
qualifications: data.qualifications,
manifest: buildCvatManifest(data),
};
await api.post('/job/cvat', body);
await api.post('/job', body);
};

export const getJobList = async ({
Expand Down
46 changes: 32 additions & 14 deletions packages/apps/job-launcher/client/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,47 @@ export type FiatPaymentRequest = {
paymentMethodId: string;
};

export type CreateFortuneJobRequest = {
chainId: number;
export type FortuneManifest = {
submissionsRequired: number;
requesterTitle: string;
requesterDescription: string;
paymentCurrency: string;
paymentAmount: number;
escrowFundToken: string;
fundAmount?: number;
requestType: JobType.FORTUNE;
qualifications?: string[];
};

export type CreateCvatJobRequest = {
export type JobRequestType = JobType.FORTUNE | JobType.HCAPTCHA | CvatJobType;

export type CreateJobRequest<TManifest = Record<string, unknown>> = {
chainId: number;
requesterDescription: string;
qualifications?: string[];
requestType: JobRequestType;
paymentCurrency: string;
paymentAmount: number;
escrowFundToken: string;
data: CvatData;
labels: Label[];
minQuality: number;
groundTruth: CvatDataSource;
userGuide: string;
type: CvatJobType;
qualifications?: string[];
manifest: TManifest;
};

export type CvatManifest = {
data: {
dataUrl: string;
pointsUrl?: string;
boxesUrl?: string;
};
annotation: {
labels: Label[];
description: string;
userGuide: string;
type: CvatJobType;
jobSize: number;
qualifications?: string[];
};
validation: {
minQuality: number;
valSize: number;
gtUrl: string;
};
jobBounty: string;
};

export enum CreateJobStep {
Expand Down Expand Up @@ -215,6 +232,7 @@ export type CvatRequest = {
groundTruth: CvatDataSource;
userGuide: string;
accuracyTarget: number;
jobBounty: number;
};

export type JobRequest = {
Expand Down
10 changes: 0 additions & 10 deletions packages/apps/job-launcher/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,3 @@ PAYMENT_PROVIDER_APP_INFO_URL=http://local.app

# Sendgrid
SENDGRID_API_KEY=sendgrid-disabled

# Vision
GOOGLE_PROJECT_ID=disabled
GOOGLE_PRIVATE_KEY=disabled
GOOGLE_CLIENT_EMAIL=disabled
GCV_MODERATION_RESULTS_FILES_PATH=disabled
GCV_MODERATION_RESULTS_BUCKET=disabled

# Slack
SLACK_ABUSE_NOTIFICATION_WEBHOOK_URL=disabled
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { S3ConfigService } from './s3-config.service';
import { SendgridConfigService } from './sendgrid-config.service';
import { PaymentProviderConfigService } from './payment-provider-config.service';
import { Web3ConfigService } from './web3-config.service';
import { SlackConfigService } from './slack-config.service';
import { VisionConfigService } from './vision-config.service';

@Global()
@Module({
Expand All @@ -28,8 +26,6 @@ import { VisionConfigService } from './vision-config.service';
CvatConfigService,
PGPConfigService,
NetworkConfigService,
SlackConfigService,
VisionConfigService,
],
exports: [
ConfigService,
Expand All @@ -43,8 +39,6 @@ import { VisionConfigService } from './vision-config.service';
CvatConfigService,
PGPConfigService,
NetworkConfigService,
SlackConfigService,
VisionConfigService,
],
})
export class EnvConfigModule {}
13 changes: 0 additions & 13 deletions packages/apps/job-launcher/server/src/common/config/env-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ export const envValidator = Joi.object({
SENDGRID_API_KEY: Joi.string().required(),
SENDGRID_FROM_EMAIL: Joi.string(),
SENDGRID_FROM_NAME: Joi.string(),
// CVAT
CVAT_JOB_SIZE: Joi.string(),
CVAT_MAX_TIME: Joi.string(),
CVAT_VAL_SIZE: Joi.string(),
CVAT_SKELETONS_JOB_SIZE_MULTIPLIER: Joi.string(),
//PGP
PGP_ENCRYPT: Joi.boolean(),
PGP_PRIVATE_KEY: Joi.string().optional(),
Expand All @@ -82,12 +77,4 @@ export const envValidator = Joi.object({
//COIN API KEYS
RATE_CACHE_TIME: Joi.number().optional(),
COINGECKO_API_KEY: Joi.string().optional(),
// Google
GOOGLE_PROJECT_ID: Joi.string().required(),
GOOGLE_PRIVATE_KEY: Joi.string().required(),
GOOGLE_CLIENT_EMAIL: Joi.string().required(),
GCV_MODERATION_RESULTS_FILES_PATH: Joi.string().required(),
GCV_MODERATION_RESULTS_BUCKET: Joi.string().required(),
// Slack
SLACK_ABUSE_NOTIFICATION_WEBHOOK_URL: Joi.string().required(),
});

This file was deleted.

Loading
Loading