Skip to content

Commit

Permalink
SUBMARINE-1236. Fix patch strategy
Browse files Browse the repository at this point in the history
### What is this PR for?
There are four patch strategies in the k8s generic API. Replace the `PATCH_FORMAT_JSON_PATCH` with `PATCH_FORMAT_APPLY_YAML`.

### What type of PR is it?
[Bug Fix]

### Todos
* [x] - Task

### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-1236

### How should this be tested?

### Screenshots (if appropriate)

### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No

Author: KUAN-HSUN-LI <b06209027@ntu.edu.tw>

Signed-off-by: Kevin Su <pingsutw@apache.org>

Closes #915 from KUAN-HSUN-LI/SUBMARINE-1236 and squashes the following commits:

506a644 [KUAN-HSUN-LI] SUBMARINE-1236. fix patch strategy
  • Loading branch information
KUAN-HSUN-LI authored and pingsutw committed Mar 29, 2022
1 parent 42b2380 commit 46a6f07
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ public Experiment patchExperiment(ExperimentSpec spec) throws SubmarineRuntimeEx
mlJob.getMetadata().setNamespace(getServerNamespace());
Object object = mlJob.getPlural().equals(TFJob.CRD_TF_PLURAL_V1)
? tfJobClient.patch(getServerNamespace(), mlJob.getMetadata().getName(),
V1Patch.PATCH_FORMAT_JSON_PATCH,
V1Patch.PATCH_FORMAT_APPLY_YAML,
new V1Patch(new Gson().toJson(((TFJob) mlJob).getSpec()))).throwsApiException().getObject()
: pyTorchJobClient.patch(getServerNamespace(), mlJob.getMetadata().getName(),
V1Patch.PATCH_FORMAT_JSON_PATCH,
V1Patch.PATCH_FORMAT_APPLY_YAML,
new V1Patch(new Gson().toJson(((PyTorchJob) mlJob).getSpec()))).throwsApiException().getObject()
;
experiment = parseExperimentResponseObject(object, ParseOp.PARSE_OP_RESULT);
Expand All @@ -341,20 +341,20 @@ public Experiment deleteExperiment(ExperimentSpec spec) throws SubmarineRuntimeE
try {
MLJob mlJob = ExperimentSpecParser.parseJob(spec);
mlJob.getMetadata().setNamespace(getServerNamespace());

AgentPod agentPod = new AgentPod(getServerNamespace(), spec.getMeta().getName(),
mlJob.getPlural().equals(TFJob.CRD_TF_PLURAL_V1)
? CustomResourceType.TFJob : CustomResourceType.PyTorchJob,
spec.getMeta().getExperimentId());

Object object = mlJob.getPlural().equals(TFJob.CRD_TF_PLURAL_V1)
? tfJobClient.delete(getServerNamespace(), mlJob.getMetadata().getName(),
MLJobConverter.toDeleteOptionsFromMLJob(mlJob))
.throwsApiException().getStatus()
: pyTorchJobClient.delete(getServerNamespace(), mlJob.getMetadata().getName(),
MLJobConverter.toDeleteOptionsFromMLJob(mlJob))
.throwsApiException().getStatus();

LOG.info(String.format("Experiment:%s had been deleted, start to delete agent pod:%s",
spec.getMeta().getName(), agentPod.getMetadata().getName()));
podClient.delete(agentPod.getMetadata().getNamespace(), agentPod.getMetadata().getName());
Expand Down

0 comments on commit 46a6f07

Please sign in to comment.