|
|
|
|
@ -292,8 +292,8 @@ class Prediksi:
|
|
|
|
|
# append record using the difference for raw_cm_interval
|
|
|
|
|
records_to_insert.append(
|
|
|
|
|
(
|
|
|
|
|
str(uuid4()),
|
|
|
|
|
int(max_seq),
|
|
|
|
|
str(uuid4()), # id
|
|
|
|
|
int(max_seq), # seq
|
|
|
|
|
float(row["pm_interval"]) if not pd.isna(row.get("pm_interval", None)) else 0.0,
|
|
|
|
|
float(row["year"]) if not pd.isna(row.get("year", None)) else 0.0,
|
|
|
|
|
equipment_id,
|
|
|
|
|
@ -312,8 +312,6 @@ class Prediksi:
|
|
|
|
|
float(row["predictive_material_cost"]) if not pd.isna(row.get("predictive_material_cost", None)) else 0.0,
|
|
|
|
|
float(row["predictive_labor_time"]) if not pd.isna(row.get("predictive_labor_time", None)) else 0.0,
|
|
|
|
|
float(row["predictive_labor_human"]) if not pd.isna(row.get("predictive_labor_human", None)) else 0.0,
|
|
|
|
|
float(row["loss_output_mw"]) if not pd.isna(row.get("loss_output_mw", None)) else 0.0,
|
|
|
|
|
float(row["loss_price"]) if not pd.isna(row.get("loss_price", None)) else 0.0,
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -651,7 +649,7 @@ class Prediksi:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Authentication: sign-in and refresh helpers
|
|
|
|
|
async def sign_in(self, username: str = "Admin", password: str = "password") -> dict:
|
|
|
|
|
async def sign_in(self, username: str = "lcca_admin", password: str = "password") -> dict:
|
|
|
|
|
"""Sign in to AUTH_APP_URL/sign-in using provided username/password.
|
|
|
|
|
|
|
|
|
|
Stores access_token and refresh_token on the instance when successful and returns the parsed response dict.
|
|
|
|
|
@ -673,6 +671,21 @@ class Prediksi:
|
|
|
|
|
return data
|
|
|
|
|
except httpx.HTTPError as e:
|
|
|
|
|
print(f"Sign-in failed: {e}")
|
|
|
|
|
# Try to sign out if sign-in failed
|
|
|
|
|
try:
|
|
|
|
|
signout_url = f"{self.AUTH_APP_URL}/sign-out"
|
|
|
|
|
async with httpx.AsyncClient() as client:
|
|
|
|
|
await client.get(signout_url, timeout=10.0)
|
|
|
|
|
print("Signed out due to sign-in failure.")
|
|
|
|
|
except Exception as signout_exc:
|
|
|
|
|
print(f"Sign-out failed: {signout_exc}")
|
|
|
|
|
# Try to sign in again
|
|
|
|
|
try:
|
|
|
|
|
signin_res = await self.sign_in()
|
|
|
|
|
if getattr(self, "access_token", None):
|
|
|
|
|
return signin_res
|
|
|
|
|
except Exception as signin_exc:
|
|
|
|
|
print(f"Sign-in failed after sign-out: {signin_exc}")
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
async def refresh_access_token(self) -> str:
|
|
|
|
|
|