Skip to content

Commit

Permalink
use of pkg ressources to get file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
FadyCoding committed Jul 12, 2024
1 parent 3beb5e1 commit 8da0c2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions debiaiServer/config/init_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from configparser import ConfigParser
from termcolor import colored

import pkg_resources
import os

config_path = "debiaiServer/config/config.ini"
config_path = pkg_resources.resource_filename("debiaiServer", "config/config.ini")
config_parser = ConfigParser()

DEBUG_COLOR = "light_blue"
Expand Down
5 changes: 4 additions & 1 deletion debiaiServer/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import time
import yaml
import pkg_resources
from yaml.loader import SafeLoader
from urllib.parse import urlparse


def get_app_version():
# Read the version from the API YAML file
yaml_path = pkg_resources.resource_filename("debiaiServer", "swagger.yaml")

try:
with open("debiaiServer/swagger.yaml") as f:
with open(yaml_path, "r") as f:
data = yaml.load(f, Loader=SafeLoader)
return data["info"]["version"]
except Exception as e:
Expand Down

0 comments on commit 8da0c2d

Please sign in to comment.