Skip to content

Commit

Permalink
rewrite generator. tempfix
Browse files Browse the repository at this point in the history
  • Loading branch information
thearyadev committed Feb 28, 2024
1 parent 87aaba1 commit fb87c34
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions utils/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

sys.path.append(".")
import os
from concurrent.futures import ThreadPoolExecutor, as_completed

import dotenv
from PIL import Image
from rich.console import Console
from rich.progress import Progress, track
from rich.prompt import Prompt

import database
import leaderboards
from utils.raise_for_missing_env import raise_for_missing_env_vars
from PIL import Image

dotenv.load_dotenv()

console = Console()
dba = database.DatabaseAccess(
host=os.getenv("MYSQLHOST") or raise_for_missing_env_vars(),
user=os.getenv("MYSQLUSER") or raise_for_missing_env_vars(),
Expand All @@ -31,44 +26,32 @@ def worker(file: str):
role = leaderboards.Role.by_name(role)
region = leaderboards.Region.by_name(region)

results = leaderboards.parse( # parse the leaderboard
image_path=os.path.join("./assets/leaderboard_images", file),
assets_path="./assets/hero_images",
role=role,
region=region,
model_name=model_name,
)
results = leaderboards.parse_leaderboard_to_leaderboard_entries(
leaderboard_image=Image.open(f"./assets/leaderboard_images/{file}"),
region=region, # type: ignore
role=role, # type: ignore
model_name="thearyadev-initial-15-02-2024",
)


for i in results:
if i.heroes[0].name != "Blank":
if i.heroes[0] != "Blank":
dba.add_leaderboard_entry(seasonNumber=target_season, leaderboard_entry=i)


def main():
global target_season, model_name # globals so the worker threads can access them
# sorry

target_season = "8_8"
model_name = "thearyadev-2023-12-20"
target_season = "9"
dba.create_season(seasonNumber=target_season)

files = os.listdir("./assets/leaderboard_images")
max_workers = 1
progress = Progress()

with progress:
progress_bar = progress.add_task(
"[red]Parsing Leaderboard Images...", total=len(files)
)
for file in files:
worker(file)

# with ThreadPoolExecutor(max_workers=max_workers) as executor:
# futures = [executor.submit(worker, file) for file in files]
# for future in as_completed(futures):
# progress.advance(progress_bar)
for file in files:
worker(file)


if __name__ == "__main__":
dba.add_info_entry("season_8_8", None, None )
main()
dba.add_info_entry("season_9", "This season is a test of the new top 500 hero classifier model. There may be issues with this page. This dataset was recorded on Febuary 29, 2AM EDT.", None )
# main()

0 comments on commit fb87c34

Please sign in to comment.