Update: Config configuration

oh_security
alka 5 months ago
parent 35ff567473
commit 895c50eebb

@ -3,9 +3,10 @@ import numpy as np
import pandas as pd import pandas as pd
from datetime import timedelta from datetime import timedelta
from collections import defaultdict from collections import defaultdict
from src.config import BASE_URL
class OptimumCostModel: class OptimumCostModel:
def __init__(self, token, last_oh_date, next_oh_date,interval =30, base_url: str = "http://192.168.1.82:8000"): def __init__(self, token, last_oh_date, next_oh_date,interval =30, base_url: str = f"{BASE_URL}"):
self.api_base_url = base_url self.api_base_url = base_url
self.token = token self.token = token
self.last_oh_date = last_oh_date self.last_oh_date = last_oh_date

@ -41,6 +41,7 @@ from datetime import datetime, date
import asyncio import asyncio
import json import json
# from src.utils import save_to_pastebin # from src.utils import save_to_pastebin
from src.config import BASE_URL, REALIBILITY_SERVICE_API
client = httpx.AsyncClient(timeout=300.0) client = httpx.AsyncClient(timeout=300.0)
@ -50,7 +51,7 @@ class OptimumCostModelWithSpareparts:
def __init__(self, token: str, last_oh_date: date, next_oh_date: date, def __init__(self, token: str, last_oh_date: date, next_oh_date: date,
sparepart_manager, sparepart_manager,
time_window_months: Optional[int] = None, time_window_months: Optional[int] = None,
base_url: str = "http://192.168.1.82:8000"): base_url: str = f"{BASE_URL}"):
""" """
Initialize the Optimum Cost Model with sparepart management Initialize the Optimum Cost Model with sparepart management
""" """
@ -1152,7 +1153,7 @@ async def get_calculation_by_assetnum(
async def get_number_of_failures(location_tag, start_date, end_date, token, max_interval=24): async def get_number_of_failures(location_tag, start_date, end_date, token, max_interval=24):
url_prediction = ( url_prediction = (
f"http://192.168.1.82:8000/reliability/main/number-of-failures/" f"{REALIBILITY_SERVICE_API}/main/number-of-failures/"
f"{location_tag}/{start_date.strftime('%Y-%m-%d')}/{end_date.strftime('%Y-%m-%d')}" f"{location_tag}/{start_date.strftime('%Y-%m-%d')}/{end_date.strftime('%Y-%m-%d')}"
) )
@ -1219,7 +1220,7 @@ async def get_equipment_foh(
token: str token: str
): ):
url_mdt = ( url_mdt = (
f"http://192.168.1.82:8000/reliability/asset/mdt/{location_tag}" f"{REALIBILITY_SERVICE_API}/asset/mdt/{location_tag}"
) )
try: try:

@ -85,6 +85,7 @@ AUTH_SERVICE_API = config("AUTH_SERVICE_API")
REALIBILITY_SERVICE_API = config("REALIBILITY_SERVICE_API") REALIBILITY_SERVICE_API = config("REALIBILITY_SERVICE_API")
RBD_SERVICE_API = config("RBD_SERVICE_API") RBD_SERVICE_API = config("RBD_SERVICE_API")
TEMPORAL_URL = config("TEMPORAL_URL") TEMPORAL_URL = config("TEMPORAL_URL")
BASE_URL = config("BASE_URL")
API_KEY = config("API_KEY") API_KEY = config("API_KEY")

@ -5,7 +5,7 @@ from typing import Optional
import pytz import pytz
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from src.config import TIMEZONE from src.config import TIMEZONE, REALIBILITY_SERVICE_API
def parse_relative_expression(date_str: str) -> Optional[datetime]: def parse_relative_expression(date_str: str) -> Optional[datetime]:
@ -95,7 +95,7 @@ import requests
def get_latest_numOfFail(location_tag, token) -> float: def get_latest_numOfFail(location_tag, token) -> float:
today = datetime.today().strftime("%Y-%m-%d") today = datetime.today().strftime("%Y-%m-%d")
url_today = f"http://192.168.1.82:8000/reliability/main/number-of-failures/{location_tag}/2016-01-01/{today}" url_today = f"{REALIBILITY_SERVICE_API}/main/number-of-failures/{location_tag}/2016-01-01/{today}"
try: try:
response = requests.get( response = requests.get(

Loading…
Cancel
Save