Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #43 from jina-ai/fix-mod-path
Browse files Browse the repository at this point in the history
fix: mod loading with dot in name
  • Loading branch information
deepankarm authored Apr 25, 2023
2 parents 1a96ae2 + 9b377f9 commit d80d119
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lcserve/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ def _add_to_path():
sys.path.append(os.path.join(os.path.dirname(__file__), 'apps', app))


def _get_parent_dir(modname: str, filename: str) -> str:
parts = modname.split('.')
parent_dir = os.path.dirname(filename)
for _ in range(len(parts) - 1):
parent_dir = os.path.dirname(parent_dir)
return parent_dir


def push_app_to_hubble(
mod: str,
tag: str = 'latest',
Expand All @@ -185,7 +193,7 @@ def push_app_to_hubble(
app = import_module(mod)
file = app.__file__
if file.endswith('.py'):
appdir = os.path.dirname(file)
appdir = _get_parent_dir(mod, file)
else:
print(f'Unknown file type for module {mod}')
sys.exit(1)
Expand Down

0 comments on commit d80d119

Please sign in to comment.