| 7 | |
| 8 | |
| 9 | class SampleSet(launch_crd.K8sCR): |
| 10 | |
| 11 | def __init__(self, client=None): |
| 12 | super(SampleSet, self).__init__("batch.paddlepaddle.org", "samplesets", "v1alpha1", client) |
| 13 | |
| 14 | def is_expected_conditions(self, inst, expected_conditions): |
| 15 | conditions = inst.get('status', {}).get("phase") |
| 16 | if not conditions: |
| 17 | return False, "" |
| 18 | if conditions in expected_conditions: |
| 19 | return True, conditions |
| 20 | else: |
| 21 | return False, conditions |
| 22 | |
| 23 | def get_spec(self, spec): |
| 24 | return { |
| 25 | "apiVersion": "%s/%s" % (self.group, self.version), |
| 26 | "kind": "SampleSet", |
| 27 | "metadata": { |
| 28 | "name": "data-center", |
| 29 | "namespace": spec.get("namespace"), |
| 30 | }, |
| 31 | "spec": { |
| 32 | "partitions": spec.get("partitions"), |
| 33 | "noSync": True, |
| 34 | "secretRef": { |
| 35 | "name": "data-center" |
| 36 | } |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | def get_action_status(self, action=None): |
| 41 | return ["Ready"], ["SyncFailed", "PartialReady"] |
| 42 | |
| 43 | |
| 44 | class SampleJob(launch_crd.K8sCR): |