Skip to content

Commit

Permalink
write directly to pv to test job
Browse files Browse the repository at this point in the history
  • Loading branch information
asmacdo committed Nov 11, 2024
1 parent 3e18a37 commit 0fa5ece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
19 changes: 11 additions & 8 deletions .github/scripts/du.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import subprocess
import sys
import json
from datetime import date

OUTPUT_FILE = "/output/du_report.json"
OUTPUT_DIR = "/home/asmacdo/du_reports/"
SIZE_THRESHOLD_GB = 1
SIZE_THRESHOLD_BYTES = SIZE_THRESHOLD_GB * 1024 * 1024 * 1024

Expand Down Expand Up @@ -41,11 +42,12 @@ def prepare_report(directory):
for user, data in report.items():
data["disk_usage_human_readable"] = bytes_to_human_readable(data["disk_usage_bytes"])

os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True)
with open(OUTPUT_FILE, 'w') as f:
json.dump(report, f, indent=4)

print(f"Disk usage report generated at {os.path.abspath(OUTPUT_FILE)}")
# os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True)
# output_file =
# with open(OUTPUT_FILE, 'w') as f:
# json.dump(report, f, indent=4)
#
# print(f"Disk usage report generated at {os.path.abspath(OUTPUT_FILE)}")


if __name__ == "__main__":
Expand All @@ -55,7 +57,8 @@ def prepare_report(directory):
path = sys.argv[1]
directories = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]

os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True)
with open(OUTPUT_FILE, 'w') as f:
os.makedirs(os.path.dirname(OUTPUT_DIR), exist_ok=True)
current_date = date.today().strftime('%Y-%m-%d')
with open(f"OUTPUT_DIR/{current_date}.json", "w") as f:
f.write("\n".join(directories))
# prepare_report(directory)
7 changes: 0 additions & 7 deletions .github/workflows/report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ jobs:
kubectl wait --for=condition=complete job/disk-usage-report-job --timeout=360s -n jupyterhub
continue-on-error: true

- name: Retrieve generated report file
run: |
POD_NAME=$(kubectl get pods -n jupyterhub --selector=job-name=disk-usage-report-job -o jsonpath='{.items[0].metadata.name}')
kubectl cp $POD_NAME:/output/du_report.json du_report.json -n jupyterhub
cat du_report.json
continue-on-error: true

# continue-on-error for previous steps so we delete the job
- name: Delete Disk Usage Report Job
run: |
Expand Down

0 comments on commit 0fa5ece

Please sign in to comment.