Skip to content

Commit 4d317a3

Browse files
authored
Refactoring workload list parsing to Python (#1089)
* Refactoring workload list parsing to Python * Fix goldens to use [0] instead of [*] in refactoring branch * Remove _sum_counts from refactoring branch * Update goldens * Update goldens with PYTHONPATH=src * Remove test-queued-job and move super_slicing test to wildcard * Address refactoring feedback: fix row delimiter, restore headers, use case-insensitive matching * Address refactoring feedback: add ROW_DELIMITER const, render <empty> row when empty * Rename delimiter and fix cluster delete workloads parsing * Migrate to JSON parsing and use _WorkloadListRow dataclass
1 parent 989ba24 commit 4d317a3

5 files changed

Lines changed: 523 additions & 91 deletions

File tree

recipes/Cluster_delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ gcloud container clusters list --project=golden-project --filter=name=golden-clu
1717
gcloud container clusters get-credentials golden-cluster --location=us-central1 --dns-endpoint --project=golden-project && kubectl config view && kubectl config set-context --current --namespace=default
1818
[XPK] Get the name of the workloads in the cluster.
1919
[XPK] Task: `List Jobs with filter-by-status=EVERYTHING` is implemented by the following command not running since it is a dry run.
20-
kubectl get workloads --ignore-not-found -o=custom-columns="Jobset Name:.metadata.ownerReferences[0].name,Created Time:.metadata.creationTimestamp,Priority:.spec.priorityClassName,TPU VMs Needed:.spec.podSets[0].count,TPU VMs Running/Ran:.status.admission.podSetAssignments[-1].count,TPU VMs Done:.status.reclaimablePods[0].count,Status:.status.conditions[-1].type,Status Message:.status.conditions[-1].message,Status Time:.status.conditions[-1].lastTransitionTime"
20+
kubectl get workloads --ignore-not-found -o=json
2121
[XPK] Task: `Cluster Delete` is implemented by the following command not running since it is a dry run.
2222
gcloud beta container clusters delete golden-cluster --project=golden-project --location=us-central1 --quiet
2323
[XPK] Task: `Get All Subnets` is implemented by the following command not running since it is a dry run.

recipes/Workload_list.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ gcloud container clusters get-credentials golden-cluster --location=us-central1
1717
[XPK] Task: `Test kubectl credentials` is implemented by the following command not running since it is a dry run.
1818
kubectl get pods
1919
[XPK] Finished get-credentials and kubectl setup.
20-
[XPK] Task: `List Jobs with filter-by-status=EVERYTHING with filter-by-job=None` is implemented by the following command not running since it is a dry run.
21-
kubectl get workloads --ignore-not-found -o=custom-columns="Jobset Name:.metadata.ownerReferences[0].name,Created Time:.metadata.creationTimestamp,Priority:.spec.priorityClassName,TPU VMs Needed:.spec.podSets[0].count,TPU VMs Running/Ran:.status.admission.podSetAssignments[-1].count,TPU VMs Done:.status.reclaimablePods[0].count,Status:.status.conditions[-1].type,Status Message:.status.conditions[-1].message,Status Time:.status.conditions[-1].lastTransitionTime"
20+
[XPK] Task: `List Jobs with filter-by-status=EVERYTHING` is implemented by the following command not running since it is a dry run.
21+
kubectl get workloads --ignore-not-found -o=json
2222
[XPK] Workload List Output:
23-
0
23+
Jobset Name Created Time Priority TPU VMs Needed TPU VMs Running/Ran TPU VMs Done Status Status Message Status Time
2424
[XPK] See your workloads in Cloud Console: https://console.cloud.google.com/kubernetes/aiml/deployments/jobs?project=golden-project
2525
[XPK] Exiting XPK cleanly
2626
-->

recipes/comprehensive-demo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ gcloud container clusters get-credentials foo --location=us-central1 --dns-endpo
5353
[XPK] Task: `Test kubectl credentials` is implemented by the following command not running since it is a dry run.
5454
kubectl get pods
5555
[XPK] Finished get-credentials and kubectl setup.
56-
[XPK] Task: `List Jobs with filter-by-status=EVERYTHING with filter-by-job=None` is implemented by the following command not running since it is a dry run.
57-
kubectl get workloads --ignore-not-found -o=custom-columns="Jobset Name:.metadata.ownerReferences[0].name,Created Time:.metadata.creationTimestamp,Priority:.spec.priorityClassName,TPU VMs Needed:.spec.podSets[0].count,TPU VMs Running/Ran:.status.admission.podSetAssignments[-1].count,TPU VMs Done:.status.reclaimablePods[0].count,Status:.status.conditions[-1].type,Status Message:.status.conditions[-1].message,Status Time:.status.conditions[-1].lastTransitionTime"
56+
[XPK] Task: `List Jobs with filter-by-status=EVERYTHING` is implemented by the following command not running since it is a dry run.
57+
kubectl get workloads --ignore-not-found -o=json
5858
[XPK] Workload List Output:
59-
0
59+
Jobset Name Created Time Priority TPU VMs Needed TPU VMs Running/Ran TPU VMs Done Status Status Message Status Time
6060
[XPK] See your workloads in Cloud Console: https://console.cloud.google.com/kubernetes/aiml/deployments/jobs?project=bar
6161
[XPK] Exiting XPK cleanly
6262
-->

0 commit comments

Comments
 (0)