Skip to content

Commit

Permalink
Revert "Gpu refactor" (#4029)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdess09 authored Nov 28, 2023
1 parent bed3788 commit fc9a5e6
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 171 deletions.
26 changes: 0 additions & 26 deletions dashboard/src/lib/porter-apps/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ export const serviceValidator = z.object({
cpuCores: serviceNumberValidator,
ramMegabytes: serviceNumberValidator,
gpuCoresNvidia: serviceNumberValidator,
gpu: z.object({
enabled: serviceBooleanValidator,
gpuCoresNvidia: serviceNumberValidator,
}),
smartOptimization: serviceBooleanValidator.optional(),
terminationGracePeriodSeconds: serviceNumberValidator.optional(),
config: z.discriminatedUnion("type", [
Expand Down Expand Up @@ -121,10 +117,6 @@ export type SerializedService = {
ramMegabytes: number;
smartOptimization?: boolean;
gpuCoresNvidia: number;
gpu: {
enabled: boolean;
gpuCoresNvidia: number;
};
terminationGracePeriodSeconds?: number;
config:
| {
Expand Down Expand Up @@ -204,10 +196,6 @@ export function defaultSerialized({
cpuCores: defaultCPU,
ramMegabytes: defaultRAM,
gpuCoresNvidia: 0,
gpu: {
enabled: false,
gpuCoresNvidia: 0,
},
smartOptimization: true,
};

Expand Down Expand Up @@ -276,10 +264,6 @@ export function serializeService(service: ClientService): SerializedService {
ramMegabytes: Math.round(service.ramMegabytes.value), // RAM must be an integer
smartOptimization: service.smartOptimization?.value,
gpuCoresNvidia: service.gpuCoresNvidia.value,
gpu: {
enabled: service.gpu.enabled.value,
gpuCoresNvidia: service.gpu.gpuCoresNvidia.value,
},
terminationGracePeriodSeconds: service.terminationGracePeriodSeconds?.value,
config: match(service.config)
.with({ type: "web" }, (config) =>
Expand Down Expand Up @@ -352,16 +336,6 @@ export function deserializeService({
instances: ServiceField.number(service.instances, override?.instances),
port: ServiceField.number(service.port, override?.port),
cpuCores: ServiceField.number(service.cpuCores, override?.cpuCores),
gpu: {
enabled: ServiceField.boolean(
service.gpu?.enabled,
override?.gpu.enabled
),
gpuCoresNvidia: ServiceField.number(
service.gpu?.gpuCoresNvidia,
override?.gpu?.gpuCoresNvidia
),
},
gpuCoresNvidia: ServiceField.number(
service.gpuCoresNvidia,
override?.gpuCoresNvidia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const ServiceContainer: React.FC<ServiceProps> = ({
{service.name.value.trim().length > 0
? service.name.value
: "New Service"}
{service.gpu.enabled.value && (
{service.gpuCoresNvidia.value > 0 && (
<>
<Spacer inline x={1.5} />
<TagContainer>
Expand Down Expand Up @@ -276,7 +276,7 @@ const ServiceHeader = styled.div<{
border-radius: 20px;
margin-left: -10px;
transform: ${(props: { showExpanded?: boolean }) =>
props.showExpanded ? "" : "rotate(-90deg)"};
props.showExpanded ? "" : "rotate(-90deg)"};
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,27 @@ const Resources: React.FC<ResourcesProps> = ({
<>
<Spacer y={1} />
<Controller
name={`app.services.${index}.gpu`}
name={`app.services.${index}.gpuCoresNvidia`}
control={control}
render={({ field: { value, onChange } }) => (
<>
<Container row>
<Switch
size="small"
color="primary"
checked={value.enabled.value}
checked={value.value > 0}
disabled={!clusterContainsGPUNodes}
onChange={() => {
onChange({
...value,
enabled: {
...value.enabled,
value: !value.enabled.value,
},
gpuCoresNvidia: {
...value.gpuCoresNvidia,
value: value.enabled.value ? 0 : 1,
}
});
if (value.value > 0) {
onChange({
...value,
value: 0,
});
} else
onChange({
...value,
value: 1,
});
}}
inputProps={{ "aria-label": "controlled" }}
/>
Expand All @@ -265,7 +264,7 @@ const Resources: React.FC<ResourcesProps> = ({
You cluster has no GPU nodes available.
</Text>
<Spacer inline x={0.5} />
{currentCluster.status !== "UPDATING" && <Tag>
<Tag>
<Link
onClick={() => {
setClusterModalVisible(true);
Expand All @@ -274,7 +273,7 @@ const Resources: React.FC<ResourcesProps> = ({
<TagIcon src={addCircle} />
Add GPU nodes
</Link>
</Tag>}
</Tag>
</>
)}
</Container>
Expand All @@ -291,22 +290,23 @@ const Resources: React.FC<ResourcesProps> = ({
</>
)}
/>
{(currentCluster.status === "UPDATING" && !clusterContainsGPUNodes) && (
<CheckItemContainer>
<CheckItemTop>
<Loading offset="0px" width="20px" height="20px" />
<Spacer inline x={1} />
<Text>{"Cluster is updating..."}</Text>
<Spacer inline x={1} />
<Tag>
<Link to={`/cluster-dashboard`}>
<TagIcon src={infra} />
View Status
</Link>
</Tag>
</CheckItemTop>
</CheckItemContainer>
)}
{currentCluster.status === "UPDATING" &&
clusterContainsGPUNodes && (
<CheckItemContainer>
<CheckItemTop>
<Loading offset="0px" width="20px" height="20px" />
<Spacer inline x={1} />
<Text>{"Creating GPU nodes..."}</Text>
<Spacer inline x={1} />
<Tag>
<Link to={`/cluster-dashboard`}>
<TagIcon src={infra} />
View Status
</Link>
</Tag>
</CheckItemTop>
</CheckItemContainer>
)}
</>
)}
{match(service.config)
Expand Down
28 changes: 0 additions & 28 deletions internal/porter_app/test/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ var result_nobuild = &porterv1.PorterApp{
Port: 8080,
CpuCores: 0.1,
RamMegabytes: 256,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_WebConfig{
WebConfig: &porterv1.WebServiceConfig{
Autoscaling: &porterv1.Autoscaling{
Expand Down Expand Up @@ -91,10 +87,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0.1,
RamMegabytes: 256,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_WorkerConfig{
WorkerConfig: &porterv1.WorkerServiceConfig{
Autoscaling: nil,
Expand All @@ -108,10 +100,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0.1,
RamMegabytes: 256,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_JobConfig{
JobConfig: &porterv1.JobServiceConfig{
AllowConcurrentOptional: pointer.Bool(true),
Expand All @@ -131,10 +119,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0.1,
RamMegabytes: 256,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_WebConfig{
WebConfig: &porterv1.WebServiceConfig{
Autoscaling: &porterv1.Autoscaling{
Expand Down Expand Up @@ -168,10 +152,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0.1,
RamMegabytes: 256,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_WorkerConfig{
WorkerConfig: &porterv1.WorkerServiceConfig{
Autoscaling: nil,
Expand All @@ -185,10 +165,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0.1,
RamMegabytes: 256,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_JobConfig{
JobConfig: &porterv1.JobServiceConfig{
AllowConcurrentOptional: pointer.Bool(true),
Expand All @@ -206,10 +182,6 @@ var result_nobuild = &porterv1.PorterApp{
CpuCores: 0,
RamMegabytes: 0,
GpuCoresNvidia: 0,
Gpu: &porterv1.GPU{
Enabled: false,
GpuCoresNvidia: 0,
},
Config: &porterv1.Service_JobConfig{},
Type: 3,
},
Expand Down
65 changes: 31 additions & 34 deletions internal/porter_app/testdata/v1_input_no_build_no_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apps:
example-job:
type: job
run: echo 'hello world'
gpu: {}
config:
allowConcurrent: true
resources:
Expand All @@ -12,54 +11,52 @@ apps:
memory: 256Mi
schedule:
enabled: true
value: "*/10 * * * *"
value: '*/10 * * * *'
paused: true
cloudsql:
enabled: false
connectionName: ""
dbPort: "5432"
serviceAccountJSON: ""
connectionName: ''
dbPort: '5432'
serviceAccountJSON: ''
example-wkr:
type: worker
run: "echo 'work'"
gpu: {}
config:
replicaCount: "1"
replicaCount: '1'
container:
port: "80"
port: '80'
resources:
requests:
cpu: 100m
memory: 256Mi
autoscaling:
enabled: false
minReplicas: "1"
maxReplicas: "10"
targetCPUUtilizationPercentage: "50"
targetMemoryUtilizationPercentage: "50"
minReplicas: '1'
maxReplicas: '10'
targetCPUUtilizationPercentage: '50'
targetMemoryUtilizationPercentage: '50'
cloudsql:
enabled: false
connectionName: ""
dbPort: "5432"
serviceAccountJSON: ""
connectionName: ''
dbPort: '5432'
serviceAccountJSON: ''
example-web:
type: web
run: node index.js
gpu: {}
config:
replicaCount: "0"
replicaCount: '0'
resources:
requests:
cpu: 100m
memory: 256Mi
container:
port: "8080"
port: '8080'
autoscaling:
enabled: true
minReplicas: "1"
maxReplicas: "3"
targetCPUUtilizationPercentage: "60"
targetMemoryUtilizationPercentage: "60"
minReplicas: '1'
maxReplicas: '3'
targetCPUUtilizationPercentage: '60'
targetMemoryUtilizationPercentage: '60'
ingress:
enabled: true
custom_domain: true
Expand All @@ -69,30 +66,30 @@ apps:
porter_hosts: []
annotations:
service:
port: "8080"
port: '8080'
health:
startupProbe:
enabled: false
failureThreshold: "3"
failureThreshold: '3'
path: /startupz
periodSeconds: "5"
periodSeconds: '5'
readinessProbe:
enabled: true
failureThreshold: "3"
failureThreshold: '3'
path: /healthz
initialDelaySeconds: "0"
initialDelaySeconds: '0'
livenessProbe:
enabled: true
failureThreshold: "3"
failureThreshold: '3'
path: /healthz
periodSeconds: "5"
periodSeconds: '5'
cloudsql:
enabled: false
connectionName: ""
dbPort: "5432"
serviceAccountJSON: ""
connectionName: ''
dbPort: '5432'
serviceAccountJSON: ''
release:
run: ls
env:
PORT: "8080"
NODE_ENV: "production"
PORT: '8080'
NODE_ENV: 'production'
Loading

0 comments on commit fc9a5e6

Please sign in to comment.