Spaces:
Running
on
Zero
Running
on
Zero
| """ | |
| File: requirements_app.py | |
| Author: Dmitry Ryumin, Maxim Markitantov, Elena Ryumina, Anastasia Dvoynikova, and Alexey Karpov | |
| Description: Project requirements for the Gradio app. | |
| License: MIT License | |
| """ | |
| import base64 | |
| import requests | |
| import polars as pl | |
| # Importing necessary components for the Gradio app | |
| from app.config import config_data | |
| def encode_image_to_base64(image_data: str) -> str: | |
| return base64.b64encode(image_data).decode("utf-8") | |
| def fetch_pypi_badge_base64(package_name: str) -> str: | |
| url = f"https://img.shields.io/pypi/v/{package_name}" | |
| response = requests.get(url) | |
| response.raise_for_status() | |
| base64_image = encode_image_to_base64(response.content) | |
| return ( | |
| f"<a href='https://pypi.org/project/{package_name}' target='_blank'>" | |
| f"<img src='data:image/svg+xml;base64,{base64_image}' alt='PyPI' /></a>" | |
| ) | |
| def read_requirements(file_path="requirements.txt"): | |
| with open(file_path, "r") as file: | |
| lines = file.readlines() | |
| data = [ | |
| { | |
| config_data.Requirements_LIBRARY: split_line[0], | |
| config_data.Requirements_RECOMMENDED_VERSION: split_line[1], | |
| # config_data.Requirements_CURRENT_VERSION: fetch_pypi_badge_base64( | |
| # split_line[0] | |
| # ), | |
| } | |
| for line in lines | |
| if (split_line := line.strip().split("==")) and len(split_line) == 2 | |
| ] | |
| df = pl.DataFrame(data) | |
| return df | |