Skip to content

Commit

Permalink
fixed get_root_directory funct
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyjohnson1 committed Jul 8, 2024
1 parent 10d28da commit 90c9c74
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
Binary file added _conv_cache/cache__shAfFEN2sdSn.pkl
Binary file not shown.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ emoji = "0.6.0"
pyyaml = "6.0.1"
python-dotenv = "1.0.0"
openai = "1.30.4"
<<<<<<< Updated upstream
neo4j = "^5.20.0"
nltk = "^3.8.1"
scikit-learn = "^1.5.0"
Expand All @@ -39,9 +38,7 @@ pyjwt = "^2.8.0"
python-multipart = "^0.0.9"
pytest-asyncio = "^0.23.7"
textblob = "^0.18.0.post0"
=======
tk = "0.1.0"
>>>>>>> Stashed changes

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down
2 changes: 1 addition & 1 deletion topos/services/basic_analytics/token_classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from topos.utilities.utils import get_root_directory

# Assuming the config.yaml is in ./topos/ relative to setup.py directory
config_path = os.path.join(get_root_directory(), 'topos', 'config.yaml')
config_path = os.path.join(get_root_directory(), 'config.yaml')

with open(config_path, 'r') as file:
settings = yaml.safe_load(file)
Expand Down
32 changes: 13 additions & 19 deletions topos/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@
import os

def get_root_directory():
def find_setup_py_upwards(start_path):
current_path = start_path
while True:
if 'setup.py' in os.listdir(current_path):
return current_path
parent_path = os.path.abspath(os.path.join(current_path, os.pardir))
if parent_path == current_path: # Reached the root directory
return None
current_path = parent_path

# Starting from the current directory
current_directory = os.path.abspath('.')
setup_py_dir = find_setup_py_upwards(current_directory)

if setup_py_dir is None:
raise FileNotFoundError("setup.py not found in the directory tree.")

return setup_py_dir

# Get the current file's directory
current_file_directory = os.path.dirname(os.path.abspath(__file__))

# Find the first occurrence of "monster" from the right
monster_index = current_file_directory.rfind("topos")

if monster_index != -1:
# Get the path up to the first "monster" directory
base_monster_directory = current_file_directory[:monster_index + len("topos")]
return base_monster_directory
else:
raise ValueError("The 'topos' directory was not found in the path.")

def parse_json(data):
import json
return json.loads(data)
Expand Down

0 comments on commit 90c9c74

Please sign in to comment.