fix: resolve volcengine package quota parsing and status filtering
This commit is contained in:
+7
-2
@@ -153,17 +153,22 @@ def process_packages_breakdown(packages):
|
|||||||
target_raw = raw_code if raw_code else raw_name
|
target_raw = raw_code if raw_code else raw_name
|
||||||
model_name = normalize_volc_name(target_raw)
|
model_name = normalize_volc_name(target_raw)
|
||||||
|
|
||||||
|
status = pkg.get("Status", "")
|
||||||
|
if status == "Effective":
|
||||||
available = pkg.get("AvailableAmount", 0)
|
available = pkg.get("AvailableAmount", 0)
|
||||||
|
else:
|
||||||
|
available = 0
|
||||||
|
|
||||||
unit = pkg.get("Unit", "token")
|
unit = pkg.get("Unit", "token")
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"Pkg: Code='{raw_code}', Name='{raw_name}' -> Norm='{model_name}', Avail={available} {unit}"
|
f"Pkg: Code='{raw_code}', Name='{raw_name}' -> Norm='{model_name}', Avail={available} {unit} (Effective: {status == 'Effective'})"
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if unit.lower() == "token":
|
if unit.lower() == "token":
|
||||||
model_counts[model_name] = model_counts.get(model_name, 0) + int(
|
model_counts[model_name] = model_counts.get(model_name, 0) + int(
|
||||||
available
|
float(available)
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -209,15 +209,21 @@ def analyze_packages(packages):
|
|||||||
raw_name = pkg.get("ConfigurationName", "Unknown")
|
raw_name = pkg.get("ConfigurationName", "Unknown")
|
||||||
raw_code = pkg.get("ConfigurationCode", "")
|
raw_code = pkg.get("ConfigurationCode", "")
|
||||||
spec_code = pkg.get("SpecificationCode", "")
|
spec_code = pkg.get("SpecificationCode", "")
|
||||||
|
|
||||||
|
status = pkg.get("Status", "")
|
||||||
|
if status == "Effective":
|
||||||
avail = pkg.get("AvailableAmount", 0)
|
avail = pkg.get("AvailableAmount", 0)
|
||||||
|
else:
|
||||||
|
avail = 0
|
||||||
|
|
||||||
unit = pkg.get("Unit", "token")
|
unit = pkg.get("Unit", "token")
|
||||||
|
|
||||||
target_raw = raw_code if raw_code else raw_name
|
target_raw = raw_code if raw_code else raw_name
|
||||||
norm_name = normalize_volc_name(target_raw)
|
norm_name = normalize_volc_name(target_raw)
|
||||||
|
|
||||||
print(f"📦 Pkg: Name='{raw_name}', Code='{raw_code}', Spec='{spec_code}'")
|
print(f"📦 Pkg: Name='{raw_name}', Code='{raw_code}', Spec='{spec_code}', Status='{status}'")
|
||||||
print(f" -> Target='{target_raw}' -> Norm='{norm_name}'")
|
print(f" -> Target='{target_raw}' -> Norm='{norm_name}'")
|
||||||
print(f" -> Avail={avail} {unit}")
|
print(f" -> Avail={avail} {unit} (Effective: {status == 'Effective'})")
|
||||||
|
|
||||||
if r:
|
if r:
|
||||||
# Check Redis Key that SHOULD be set
|
# Check Redis Key that SHOULD be set
|
||||||
|
|||||||
@@ -811,7 +811,12 @@ def process_packages_breakdown(packages):
|
|||||||
# 1. Normalize name (strips suffixes, handles case/hyphens)
|
# 1. Normalize name (strips suffixes, handles case/hyphens)
|
||||||
norm_result = normalize_volc_name(target_raw)
|
norm_result = normalize_volc_name(target_raw)
|
||||||
|
|
||||||
|
status = pkg.get("Status", "")
|
||||||
|
if status == "Effective":
|
||||||
available = pkg.get("AvailableAmount", 0)
|
available = pkg.get("AvailableAmount", 0)
|
||||||
|
else:
|
||||||
|
available = 0
|
||||||
|
|
||||||
unit = pkg.get("Unit", "token")
|
unit = pkg.get("Unit", "token")
|
||||||
|
|
||||||
# 2. Resolve to monitored upstream models.
|
# 2. Resolve to monitored upstream models.
|
||||||
|
|||||||
Reference in New Issue
Block a user