Skip to content

Commit b8ab83f

Browse files
authored
Services refactoring (#27)
* refactor: Remove 'description' from container resources * refactor: Container/worker specifications
1 parent 74f280d commit b8ab83f

16 files changed

+93
-93
lines changed

src/components/create-job/steps/CostAndDuration.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { ContainerOrWorkerType } from '@data/containerResources';
1+
import { ContainerOrWorkerType, formatResourcesSummary } from '@data/containerResources';
22
import { environment } from '@lib/config';
33
import {
44
addTimeFn,
55
formatUsdc,
66
getContainerOrWorkerType,
7-
getContainerOrWorkerTypeDescription,
87
getGpuType,
98
getResourcesCostPerEpoch,
109
} from '@lib/deeploy-utils';
@@ -52,7 +51,7 @@ function CostAndDuration() {
5251
},
5352
{
5453
label: 'Resources',
55-
value: getContainerOrWorkerTypeDescription(containerOrWorkerType),
54+
value: formatResourcesSummary(containerOrWorkerType),
5655
},
5756
{
5857
label: 'Target Nodes',

src/components/draft/job-lists/GenericDraftJobsList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ContainerOrWorkerType } from '@data/containerResources';
1+
import { ContainerOrWorkerType, formatResourcesSummary } from '@data/containerResources';
22
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
3-
import { getContainerOrWorkerType, getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
3+
import { getContainerOrWorkerType } from '@lib/deeploy-utils';
44
import { applyWidthClasses } from '@lib/utils';
55
import DraftJobsList from '@shared/jobs/drafts/DraftJobsList';
66
import { SmallTag } from '@shared/SmallTag';
@@ -11,7 +11,7 @@ const widthClasses = [
1111
'min-w-[138px]', // alias
1212
'min-w-[80px]', // duration
1313
'min-w-[90px]', // targetNodes
14-
'min-w-[50px]', // type
14+
'min-w-[90px]', // type
1515
'min-w-[310px]', // resources
1616
];
1717

@@ -59,7 +59,7 @@ export default function GenericDraftJobsList({ jobs }: { jobs: GenericDraftJob[]
5959
</div>
6060

6161
<div className={widthClasses[4]}>
62-
{containerOrWorkerType.name} ({getContainerOrWorkerTypeDescription(containerOrWorkerType)})
62+
{containerOrWorkerType.name} ({formatResourcesSummary(containerOrWorkerType)})
6363
</div>
6464
</>
6565
);

src/components/draft/job-lists/NativeDraftJobsList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ContainerOrWorkerType } from '@data/containerResources';
1+
import { ContainerOrWorkerType, formatResourcesSummary } from '@data/containerResources';
22
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
3-
import { getContainerOrWorkerType, getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
3+
import { getContainerOrWorkerType } from '@lib/deeploy-utils';
44
import { applyWidthClasses } from '@lib/utils';
55
import DraftJobsList from '@shared/jobs/drafts/DraftJobsList';
66
import { SmallTag } from '@shared/SmallTag';
@@ -11,7 +11,7 @@ const widthClasses = [
1111
'min-w-[138px]', // alias
1212
'min-w-[80px]', // duration
1313
'min-w-[90px]', // targetNodes
14-
'min-w-[50px]', // type
14+
'min-w-[90px]', // type
1515
'min-w-[310px]', // resources
1616
];
1717

@@ -57,7 +57,7 @@ export default function NativeDraftJobsList({ jobs }: { jobs: NativeDraftJob[] }
5757
</div>
5858

5959
<div className={widthClasses[4]}>
60-
{containerOrWorkerType.name} ({getContainerOrWorkerTypeDescription(containerOrWorkerType)})
60+
{containerOrWorkerType.name} ({formatResourcesSummary(containerOrWorkerType)})
6161
</div>
6262
</>
6363
);

src/components/draft/job-lists/ServiceDraftJobsList.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { Service } from '@data/containerResources';
1+
import { Service, formatResourcesSummary } from '@data/containerResources';
22
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
3-
import { getContainerOrWorkerType, getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
3+
import { getContainerOrWorkerType } from '@lib/deeploy-utils';
44
import { applyWidthClasses } from '@lib/utils';
55
import DraftJobsList from '@shared/jobs/drafts/DraftJobsList';
66
import { SmallTag } from '@shared/SmallTag';
77
import { JobType, ServiceDraftJob } from '@typedefs/deeploys';
88
import { RiDatabase2Line } from 'react-icons/ri';
99

1010
const widthClasses = [
11-
'min-w-[128px]', // alias
11+
'min-w-[138px]', // alias
1212
'min-w-[80px]', // duration
1313
'min-w-[90px]', // targetNodes
14-
'min-w-[82px]', // database
14+
'min-w-[90px]', // type
1515
'min-w-[310px]', // resources
1616
];
1717

@@ -27,7 +27,7 @@ export default function ServiceDraftJobsList({ jobs }: { jobs: ServiceDraftJob[]
2727
</div>
2828
}
2929
tableHeader={
30-
<>{applyWidthClasses(['Alias', 'Duration', 'Target Nodes', 'Database', 'Container Type'], widthClasses)}</>
30+
<>{applyWidthClasses(['Alias', 'Duration', 'Target Nodes', 'Type', 'Container Type'], widthClasses)}</>
3131
}
3232
jobs={jobs}
3333
renderJob={(job) => {
@@ -50,11 +50,11 @@ export default function ServiceDraftJobsList({ jobs }: { jobs: ServiceDraftJob[]
5050
<div className={widthClasses[2]}>{serviceJob.specifications.targetNodesCount}</div>
5151

5252
<div className={widthClasses[3]}>
53-
<SmallTag variant={containerOrWorkerType.notesColor}>{containerOrWorkerType.dbSystem}</SmallTag>
53+
<SmallTag variant={containerOrWorkerType.notesColor}>{containerOrWorkerType.serviceName}</SmallTag>
5454
</div>
5555

5656
<div className={widthClasses[4]}>
57-
{containerOrWorkerType.name} ({getContainerOrWorkerTypeDescription(containerOrWorkerType)})
57+
{containerOrWorkerType.name} ({formatResourcesSummary(containerOrWorkerType)})
5858
</div>
5959
</>
6060
);

src/components/draft/job-rundowns/GenericJobsCostRundown.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ContainerOrWorkerType, genericContainerTypes, GpuType, gpuTypes } from '@data/containerResources';
2-
import { getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
1+
import { ContainerOrWorkerType, formatResourcesSummary, genericContainerTypes, GpuType, gpuTypes } from '@data/containerResources';
32
import JobsCostRundown from '@shared/jobs/drafts/JobsCostRundown';
43
import { GenericDraftJob } from '@typedefs/deeploys';
54
import { ContainerDeploymentType, DeploymentType, PluginType, WorkerDeploymentType } from '@typedefs/steps/deploymentStepTypes';
@@ -32,11 +31,10 @@ export default function GenericJobsCostRundown({ jobs }: { jobs: GenericDraftJob
3231
{ label: 'Alias', value: genericJob.deployment.jobAlias },
3332

3433
// Specifications
35-
{ label: 'App Type', value: genericJob.specifications.applicationType },
3634
{ label: 'Target Nodes', value: genericJob.specifications.targetNodesCount },
3735
{
3836
label: 'Container Type',
39-
value: `${containerType.name} (${getContainerOrWorkerTypeDescription(containerType)})`,
37+
value: `${containerType.name} (${formatResourcesSummary(containerType)})`,
4038
},
4139
...(gpuType ? [{ label: 'GPU Type', value: `${gpuType.name} (${gpuType.gpus.join(', ')})` }] : []),
4240

src/components/draft/job-rundowns/NativeJobsCostRundown.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ContainerOrWorkerType, GpuType, gpuTypes, nativeWorkerTypes } from '@data/containerResources';
2-
import { getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
1+
import { ContainerOrWorkerType, GpuType, formatResourcesSummary, gpuTypes, nativeWorkerTypes } from '@data/containerResources';
32
import JobsCostRundown from '@shared/jobs/drafts/JobsCostRundown';
43
import { NativeDraftJob } from '@typedefs/deeploys';
54
import { BasePluginType, GenericPlugin, Plugin, PluginType } from '@typedefs/steps/deploymentStepTypes';
@@ -30,15 +29,15 @@ export default function NativeJobsCostRundown({ jobs }: { jobs: NativeDraftJob[]
3029
{ label: 'Alias', value: nativeJob.deployment.jobAlias },
3130

3231
// Specifications
33-
{ label: 'App Type', value: nativeJob.specifications.applicationType },
3432
{ label: 'Target Nodes', value: nativeJob.specifications.targetNodesCount },
35-
{ label: 'Worker Type', value: `${workerType.name} (${getContainerOrWorkerTypeDescription(workerType)})` },
33+
{ label: 'Worker Type', value: `${workerType.name} (${formatResourcesSummary(workerType)})` },
3634
...(gpuType ? [{ label: 'GPU Type', value: `${gpuType.name} (${gpuType.gpus.join(', ')})` }] : []),
3735

3836
// Deployment
3937
{ label: 'Pipeline Input Type', value: nativeJob.deployment.pipelineInputType },
40-
{ label: 'Pipeline Input URI', value: nativeJob.deployment.pipelineInputUri ?? 'None' },
41-
{ label: 'Chainstore Response', value: nativeJob.deployment.chainstoreResponse },
38+
...(nativeJob.deployment.pipelineInputUri
39+
? [{ label: 'Pipeline Input URI', value: nativeJob.deployment.pipelineInputUri }]
40+
: []),
4241
];
4342

4443
if (nativeJob.deployment.plugins?.length) {

src/components/draft/job-rundowns/ServiceJobsCostRundown.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { ContainerOrWorkerType, serviceContainerTypes } from '@data/containerResources';
2-
import { getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
3-
import { getShortAddressOrHash } from '@lib/utils';
1+
import { ContainerOrWorkerType, formatResourcesSummary, serviceContainerTypes } from '@data/containerResources';
42
import JobsCostRundown from '@shared/jobs/drafts/JobsCostRundown';
53
import { ServiceDraftJob } from '@typedefs/deeploys';
64
import { RiDatabase2Line } from 'react-icons/ri';
@@ -25,24 +23,17 @@ export default function ServiceJobsCostRundown({ jobs }: { jobs: ServiceDraftJob
2523
// Alias
2624
{ label: 'Alias', value: serviceJob.deployment.jobAlias },
2725
// Specifications
28-
{ label: 'App Type', value: serviceJob.specifications.applicationType },
2926
{ label: 'Target Nodes', value: serviceJob.specifications.targetNodesCount },
3027
{
3128
label: 'Container Type',
32-
value: `${containerType.name} (${getContainerOrWorkerTypeDescription(containerType)})`,
29+
value: `${containerType.name} (${formatResourcesSummary(containerType)})`,
3330
},
3431

3532
// Deployment
3633
{ label: 'Tunneling', value: serviceJob.deployment.enableTunneling },
3734
...(serviceJob.deployment.enableTunneling === 'True' && serviceJob.deployment.tunnelingLabel
3835
? [{ label: 'Tunneling Label', value: serviceJob.deployment.tunnelingLabel }]
3936
: []),
40-
{
41-
label: 'Service Replica',
42-
value: serviceJob.deployment.serviceReplica
43-
? getShortAddressOrHash(serviceJob.deployment.serviceReplica, 4, true)
44-
: 'None',
45-
},
4637
];
4738

4839
return (

src/components/extend-job/JobExtension.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CspEscrowAbi } from '@blockchain/CspEscrow';
22
import { DeeployFlowModal } from '@components/draft/DeeployFlowModal';
3+
import { formatResourcesSummary } from '@data/containerResources';
34
import { DEEPLOY_FLOW_ACTION_KEYS } from '@data/deeployFlowActions';
45
import { config, environment, getCurrentEpoch, getDevAddress, isUsingDevAddress } from '@lib/config';
56
import { BlockchainContextType, useBlockchainContext } from '@lib/contexts/blockchain';
@@ -116,7 +117,7 @@ export default function JobExtension({ job }: { job: RunningJobWithResources })
116117
},
117118
{
118119
label: 'Resources',
119-
value: job.resources.containerOrWorkerType.description,
120+
value: formatResourcesSummary(job.resources.containerOrWorkerType),
120121
},
121122
{
122123
label: 'Target Nodes',

src/components/job/JobSpecifications.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RunningJobResources } from '@data/containerResources';
1+
import { formatResourcesSummary, RunningJobResources } from '@data/containerResources';
22
import { environment } from '@lib/config';
33
import { getResourcesCostPerEpoch } from '@lib/deeploy-utils';
44
import { fBI } from '@lib/utils';
@@ -14,7 +14,7 @@ export default function JobSpecifications({ resources }: { resources: RunningJob
1414
},
1515
{
1616
label: 'Resources',
17-
value: resources.containerOrWorkerType.description,
17+
value: formatResourcesSummary(resources.containerOrWorkerType),
1818
},
1919
{
2020
label: 'GPU Type',

src/components/project/job-lists/GenericRunningJobsList.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getContainerOrWorkerTypeDescription } from '@lib/deeploy-utils';
1+
import { formatResourcesSummary } from '@data/containerResources';
22
import { applyWidthClasses } from '@lib/utils';
33
import RunningJobsList from '@shared/jobs/projects/RunningJobsList';
44
import { SmallTag } from '@shared/SmallTag';
@@ -52,9 +52,7 @@ function GenericRunningJobsList({ jobs }: { jobs: RunningJobWithResources[] }) {
5252
</div>
5353
</div>
5454

55-
<div className={widthClasses[3]}>
56-
{`${containerOrWorkerType.name} (${getContainerOrWorkerTypeDescription(containerOrWorkerType)})`}
57-
</div>
55+
<div className={widthClasses[3]}>{`${containerOrWorkerType.name} (${formatResourcesSummary(containerOrWorkerType)})`}</div>
5856
</>
5957
);
6058
}}

0 commit comments

Comments
 (0)