From 8561196f0df60a45e082065d00ac0501aa80ceea Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Wed, 28 Aug 2024 10:39:16 +0200 Subject: [PATCH] add new system base in python for services --- main.py | 23 +++++++++++++++++++++++ services/__init__.py | 2 ++ utils.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 main.py create mode 100644 services/__init__.py create mode 100644 utils.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..36f4bb2 --- /dev/null +++ b/main.py @@ -0,0 +1,23 @@ +import logging +import os +import sys + +PYTHON_EXEC = 'python3.10' +PATH = os.path.dirname(os.path.abspath(__file__)) +ROCM_VERSION = "6.1.2" + +# Set up logging +LEVEL = logging.DEBUG +logger = logging.getLogger('ai-suite-rocm') +if not logger.hasHandlers(): + handler_with_formatter = logging.StreamHandler(stream=sys.stdout) + handler_with_formatter.setFormatter(logging.Formatter('[%(levelname)s] : %(message)s')) + logger.addHandler(handler_with_formatter) +logger.setLevel(LEVEL) + +if __name__ == '__main__': + logger.info("Starting AI Suite for ROCM") + + from services import TextGeneration + + test = TextGeneration().start() diff --git a/services/__init__.py b/services/__init__.py new file mode 100644 index 0000000..f7af8e2 --- /dev/null +++ b/services/__init__.py @@ -0,0 +1,2 @@ +from services.services import Stack +from services.txtgen import TextGeneration \ No newline at end of file diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..5f24ba7 --- /dev/null +++ b/utils.py @@ -0,0 +1,28 @@ +import json +import urllib + +from main import ROCM_VERSION, logger + + +def get_prebuilts(repo_owner: str = "M4TH1EU", repo_name: str = "ai-suite-rocm-local", + release_tag: str = f"prebuilt-whl-{ROCM_VERSION}") -> list: + + api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/tags/{release_tag}" + + try: + with urllib.request.urlopen(api_url) as response: + if response.status != 200: + logger.error(f"Failed to fetch data: HTTP Status {response.status}") + return [] + + release_data = json.load(response) + + assets = release_data.get('assets', []) + if not assets: + logger.error("No assets found in release data") + return [] + + return assets + + except urllib.error.URLError as e: + logger.error(f"Error fetching release data: {e}")