Skip to content

Commit 073a81c

Browse files
authored
Pipeline params (#25)
* feat: Display and edit pipeline params * chore: Disable Application Type as it is not used at the moment
1 parent 9692127 commit 073a81c

File tree

8 files changed

+35
-15
lines changed

8 files changed

+35
-15
lines changed

src/components/create-job/steps/specifications/ServiceSpecifications.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { APPLICATION_TYPES } from '@data/applicationTypes';
21
import { serviceContainerTypes } from '@data/containerResources';
32
import { SlateCard } from '@shared/cards/SlateCard';
43
import ContainerResourcesInfo from '@shared/jobs/ContainerResourcesInfo';
54
import SelectContainerOrWorkerType from '@shared/jobs/SelectContainerOrWorkerType';
65
import JobTags from '@shared/jobs/target-nodes/JobTags';
76
import NumberInputWithLabel from '@shared/NumberInputWithLabel';
8-
import SelectWithLabel from '@shared/SelectWithLabel';
97

108
export default function ServiceSpecifications({ isEditingRunningJob }: { isEditingRunningJob?: boolean }) {
119
return (
@@ -25,11 +23,11 @@ export default function ServiceSpecifications({ isEditingRunningJob }: { isEditi
2523
<div className="flex gap-4">
2624
<NumberInputWithLabel name="specifications.targetNodesCount" label="Target Nodes Count" isDisabled />
2725

28-
<SelectWithLabel
26+
{/* <SelectWithLabel
2927
name="specifications.applicationType"
3028
label="Application Type"
3129
options={APPLICATION_TYPES}
32-
/>
30+
/> */}
3331
</div>
3432

3533
<JobTags />

src/components/edit-job/JobEditFormWrapper.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default function JobEditFormWrapper({
134134
const getBaseSchemaDefaults = (config: JobConfig = jobConfig) => ({
135135
jobType: job.resources.jobType,
136136
specifications: {
137-
applicationType: APPLICATION_TYPES[0], // TODO: Get from job after the API update
137+
applicationType: APPLICATION_TYPES[0], // Disabled for now
138138
targetNodesCount: Number(job.numberOfNodesRequested),
139139
jobTags: !job.jobTags ? [] : job.jobTags.filter((tag) => !tag.startsWith('CT:')),
140140
nodesCountries: !job.jobTags
@@ -173,7 +173,7 @@ export default function JobEditFormWrapper({
173173
},
174174
deployment: {
175175
...getBaseSchemaDeploymentDefaults(),
176-
pipelineParams: [], // TODO: Missing from the API response
176+
pipelineParams: getPipelineParams(),
177177
pipelineInputType: job.pipelineData.TYPE,
178178
pipelineInputUri: job.pipelineData.URL,
179179
chainstoreResponse: BOOLEAN_TYPES[1],
@@ -194,6 +194,10 @@ export default function JobEditFormWrapper({
194194
},
195195
});
196196

197+
const getPipelineParams = () => {
198+
return !job.pipelineParams ? [] : Object.entries(job.pipelineParams).map(([key, value]) => ({ key, value }));
199+
};
200+
197201
const getPortMappings = (config: JobConfig) => {
198202
return !config.CONTAINER_RESOURCES.ports
199203
? []

src/components/job/config/JobDeploymentSection.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CopyableValue } from '@shared/CopyableValue';
44
import ItemWithBoldValue from '@shared/jobs/ItemWithBoldValue';
55
import { JobType, RunningJobWithResources } from '@typedefs/deeploys';
66
import { isEmpty } from 'lodash';
7+
import JobKeyValueSection from '../JobKeyValueSection';
78
import JobSimpleTagsSection from '../JobSimpleTagsSection';
89
import ConfigSectionTitle from './ConfigSectionTitle';
910

@@ -14,8 +15,6 @@ export default function JobDeploymentSection({ job }: { job: RunningJobWithResou
1415

1516
const pipelineData = job.pipelineData;
1617

17-
// console.log('Pipeline Data', pipelineData);
18-
1918
return (
2019
<BorderedCard isLight={false} disableWrapper>
2120
<div className="col gap-3 p-4">
@@ -107,6 +106,17 @@ export default function JobDeploymentSection({ job }: { job: RunningJobWithResou
107106
<div className="grid grid-cols-2 gap-3">
108107
<ItemWithBoldValue label="Pipeline Input Type" value={pipelineData.TYPE} />
109108
<ItemWithBoldValue label="Pipeline Input URI" value={pipelineData.URL ?? '—'} />
109+
110+
<ItemWithBoldValue
111+
label="Pipeline Parameters"
112+
value={
113+
isEmpty(job.pipelineParams) ? (
114+
'—'
115+
) : (
116+
<JobKeyValueSection obj={job.pipelineParams} displayShortValues={false} />
117+
)
118+
}
119+
/>
110120
</div>
111121
</>
112122
)}

src/lib/contexts/deployment/deployment-provider.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const DeploymentProvider = ({ children }) => {
245245
return null;
246246
}
247247

248-
return {
248+
const jobWithDetails: RunningJobWithDetails = {
249249
alias,
250250
projectName: specs.project_name,
251251
allowReplicationInTheWild: specs.allow_replication_in_the_wild,
@@ -257,6 +257,12 @@ export const DeploymentProvider = ({ children }) => {
257257
pipelineData,
258258
...job,
259259
};
260+
261+
if (specs.job_config?.pipeline_params) {
262+
jobWithDetails.pipelineParams = specs.job_config.pipeline_params;
263+
}
264+
265+
return jobWithDetails;
260266
})
261267
.filter((job) => job !== null)
262268
.value();

src/schemas/steps/specifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const getRequiredIntegerSchema = (max: number) => {
1818

1919
const baseSpecificationsSchema = z.object({
2020
gpuType: z.union([z.literal(''), z.enum(gpuTypes.map((type) => type.name) as [string, ...string[]])]).optional(),
21-
applicationType: z.enum(APPLICATION_TYPES, { required_error: 'Application type is required' }),
21+
applicationType: z.enum(APPLICATION_TYPES, { required_error: 'Application type is required' }).optional(), // Disabled for now
2222
targetNodesCount: getRequiredIntegerSchema(100),
2323
jobTags: z.array(z.string()),
2424
nodesCountries: z.array(z.string()),

src/shared/jobs/SpecsNodesSection.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { APPLICATION_TYPES } from '@data/applicationTypes';
21
import { ContainerOrWorkerType, genericContainerTypes, nativeWorkerTypes } from '@data/containerResources';
32
import { SlateCard } from '@shared/cards/SlateCard';
43
import NumberInputWithLabel from '@shared/NumberInputWithLabel';
5-
import SelectWithLabel from '@shared/SelectWithLabel';
64
import { JobType } from '@typedefs/deeploys';
75
import { useEffect, useRef, useState } from 'react';
86
import { useFormContext } from 'react-hook-form';
@@ -105,11 +103,11 @@ export default function SpecsNodesSection({
105103
hasWarning={hasWarning}
106104
/>
107105

108-
<SelectWithLabel
106+
{/* <SelectWithLabel
109107
name="specifications.applicationType"
110108
label="Application Type"
111109
options={APPLICATION_TYPES}
112-
/>
110+
/> */}
113111
</div>
114112

115113
<div className="col gap-2">

src/typedefs/deeployApi.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ type DeeploySpecs = {
2323
date_created: number;
2424
date_updated: number;
2525
initial_target_nodes: R1Address[];
26+
job_config?: {
27+
pipeline_params?: Record<string, string>;
28+
};
2629
job_id: number;
2730
job_tags: string[];
2831
nr_target_nodes: number;

src/typedefs/deeploys.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ enum ProjectPage {
2323

2424
// Specifications
2525
type BaseJobSpecifications = {
26-
applicationType: (typeof APPLICATION_TYPES)[number];
26+
applicationType: (typeof APPLICATION_TYPES)[number]; // Disabled for now
2727
targetNodesCount: number;
2828
jobTags: string[];
2929
nodesCountries: string[];
@@ -106,6 +106,7 @@ type RunningJob = {
106106
balance: bigint;
107107
lastAllocatedEpoch: bigint;
108108
activeNodes: readonly EthAddress[];
109+
pipelineParams?: Record<string, string>;
109110
};
110111

111112
type RunningJobWithDetails = RunningJob & {

0 commit comments

Comments
 (0)