Skip to content

Commit

Permalink
Support apiextensions.k8s.io/v1 and admissionregistration.k8s.io/v1 (#…
Browse files Browse the repository at this point in the history
…118)

* first conversion to v1

* disable CR pruning

* add adaptdl SA

* add status to schema

* comply to ray-project/ray#21852
  • Loading branch information
odp authored Apr 19, 2022
1 parent 4d8afa5 commit 16bc63c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 59 deletions.
85 changes: 46 additions & 39 deletions helm/adaptdl-sched/templates/adaptdl-crd.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: adaptdljobs.adaptdl.petuum.com
spec:
group: adaptdl.petuum.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
plural: adaptdljobs
singular: adaptdljob
kind: AdaptDLJob
additionalPrinterColumns:
shortNames:
- adljob
- adljobs
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
required: ["spec"]
properties:
metadata:
type: object
properties:
# Name is used as label values which have a 63 character limit.
name:
type: string
maxLength: 63
spec:
type: object
required: ["template"]
properties:
maxReplicas:
type: integer
minimum: 1
minReplicas:
type: integer
minimum: 0
preemptible:
type: boolean
template:
type: object
x-kubernetes-preserve-unknown-fields: true
status:
type: object
x-kubernetes-preserve-unknown-fields: true
subresources:
status: {}
additionalPrinterColumns:
- name: Ready
type: integer
JSONPath: .status.readyReplicas
jsonPath: .status.readyReplicas
- name: Replicas
type: string
JSONPath: .status.replicas
jsonPath: .status.replicas
- name: Restarts
type: integer
JSONPath: .status.group
jsonPath: .status.group
- name: Status
type: string
JSONPath: .status.phase
jsonPath: .status.phase
- name: Age
type: date
JSONPath: .metadata.creationTimestamp
subresources:
status: {}
validation:
openAPIV3Schema:
type: object
properties:
metadata:
type: object
properties:
# Name is used as label values which have a 63 character limit.
name:
type: string
maxLength: 63
spec:
type: object
properties:
maxReplicas:
type: integer
minimum: 1
minReplicas:
type: integer
minimum: 0
preemptible:
type: boolean
template:
type: object
required: ["template"]
required: ["spec"]
jsonPath: .metadata.creationTimestamp
1 change: 1 addition & 0 deletions helm/adaptdl-sched/templates/validator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
app: adaptdl-validator
release: {{ .Release.Name }}
spec:
serviceAccountName: adaptdl
volumes:
- name: tls
secret:
Expand Down
6 changes: 3 additions & 3 deletions helm/adaptdl-sched/templates/validator-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
tls.crt: {{ $cert.Cert | b64enc }}
tls.key: {{ $cert.Key | b64enc }}
---
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: {{ .Release.Name }}-validator
Expand All @@ -32,8 +32,8 @@ webhooks:
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["adaptdl.petuum.com"]
apiVersions: ["v1beta1"]
apiVersions: ["v1"]
resources: ["adaptdljobs"]
admissionReviewVersions:
- v1beta1
- v1
sideEffects: None
17 changes: 0 additions & 17 deletions ray/adaptdl_ray/tune/adaptdl_trial_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

from ray import tune
from ray.tune.ray_trial_executor import RayTrialExecutor
from ray.tune.trial import Trial
from ray.tune.suggest import BasicVariantGenerator
from .adaptdl_trial import AdaptDLTrial
from .adaptdl_trainable import AdaptDLTrainableCreator, _train_simple


Expand All @@ -37,19 +35,6 @@ def setUp(self):
def tearDown(self):
ray.shutdown()

def testTrialStatus(self):
ray.init(num_cpus=2)
trainable_cls = AdaptDLTrainableCreator(_train_simple, num_workers=2)
trial = AdaptDLTrial(trainable_cls.__name__, trial_id="0")
trial_executor = RayTrialExecutor()
assert trial.status == Trial.PENDING
trial_executor.start_trial(trial)
assert trial.status == Trial.RUNNING
trial_executor.stop_trial(trial)
assert trial.status == Trial.TERMINATED
trial_executor.stop_trial(trial, error=True)
assert trial.status == Trial.ERROR

def testExperimentTagTruncation(self):
ray.init(num_cpus=2)
trainable_cls = AdaptDLTrainableCreator(_train_simple, num_workers=1)
Expand All @@ -72,7 +57,5 @@ def testExperimentTagTruncation(self):
if not trial:
break
trial_executor.start_trial(trial)
assert trial.status == Trial.RUNNING
assert len(os.path.basename(trial.logdir)) <= 200
trial_executor.stop_trial(trial)
assert trial.status == Trial.TERMINATED

0 comments on commit 16bc63c

Please sign in to comment.