Files
wehub-resource-sync 85742ab165
CPU Test / Lint - next (push) Waiting to run
Dashboard / Chromatic (push) Waiting to run
CPU Test / Lint - fast (push) Waiting to run
CPU Test / Build documentation (push) Waiting to run
CPU Test / Test (Store, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Utilities, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Weave, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (AgentOps, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (LLM proxy, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Others, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Store, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Utilities, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Weave, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (AgentOps, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (LLM proxy, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Others, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Store, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Utilities, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Weave, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (AgentOps, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (LLM proxy, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Others, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Store, latest, Python 3.13) (push) Waiting to run
CPU Test / Lint - slow (push) Waiting to run
CPU Test / Lint - JavaScript (push) Waiting to run
CPU Test / Test (AgentOps, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (LLM proxy, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Others, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Utilities, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Weave, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (JavaScript) (push) Waiting to run
Deploy Documentation / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:44:17 +08:00

88 lines
2.5 KiB
Python

# Copyright (c) Microsoft. All rights reserved.
import os
import requests
from openai import OpenAI
# Most common Azure OpenAI setup:
# AZURE_OPENAI_ENDPOINT="https://<resource>.openai.azure.com"
# AZURE_OPENAI_API_KEY="..."
# Optional (only if your endpoint requires it):
# AZURE_OPENAI_API_VERSION="2025-xx-xx"
#
# This script treats "delete finetune job" as "cancel finetune job"
# because fine-tune jobs are typically cancellable, not deletable.
def _client() -> OpenAI:
# This script assumes AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY are set in the environment.
endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
api_key = os.environ["AZURE_OPENAI_API_KEY"]
return OpenAI(api_key=api_key, base_url=endpoint)
def list_data_files():
c = _client()
return c.files.list(limit=100)
def list_finetune_jobs():
c = _client()
return c.fine_tuning.jobs.list(limit=100)
def delete_data_file(file_id: str):
c = _client()
return c.files.delete(file_id)
def cancel_finetune_job(job_id: str):
c = _client()
return c.fine_tuning.jobs.cancel(job_id)
def delete_finetune_job(job_id: str):
# This script assumes AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY are set in the environment.
endpoint = os.environ["AZURE_OPENAI_ENDPOINT"].rstrip("/")
api_key = os.environ["AZURE_OPENAI_API_KEY"]
root = endpoint.split("/openai")[0]
url = f"{root}/openai/fine_tuning/jobs/{job_id}"
params = {"api-version": os.environ["AZURE_OPENAI_API_VERSION"]}
resp = requests.delete(url, headers={"api-key": api_key}, params=params, timeout=60)
resp.raise_for_status()
return resp.content
if __name__ == "__main__":
# Quick demo: print IDs you could delete
jobs = list_finetune_jobs().data
files = list_data_files().data
print("JOBS:")
for j in jobs:
print(f" {j.id} {getattr(j, 'status', '')} {getattr(j, 'model', '')}")
print("\nFILES:")
for f in files:
print(f" {f.id} {getattr(f, 'filename', '')} {getattr(f, 'status', '')}")
# Delete them all WITHOUT CONFIRMATION!
for j in jobs:
print(f"Deleting job {j.id}")
try:
if j.status == "running":
cancel_finetune_job(j.id)
delete_finetune_job(j.id)
except Exception as exc:
print(f" Error deleting job {j.id}: {exc}")
for f in files:
print(f"Deleting file {f.id}")
try:
delete_data_file(f.id)
except Exception as exc:
print(f" Error deleting file {f.id}: {exc}")